Skip to content

Commit

Permalink
uncommit me
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 committed Oct 11, 2024
1 parent fc45bbb commit 3431e82
Show file tree
Hide file tree
Showing 21 changed files with 3,377 additions and 2,277 deletions.
4 changes: 2 additions & 2 deletions collections/forms/i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-09-09T12:09:30.724Z\n"
"PO-Revision-Date: 2024-09-09T12:09:30.724Z\n"
"POT-Creation-Date: 2024-10-10T14:44:05.644Z\n"
"PO-Revision-Date: 2024-10-10T14:44:05.644Z\n"

msgid "Upload file"
msgstr "Upload file"
Expand Down
39 changes: 39 additions & 0 deletions collections/ui/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ import { Input } from '@dhis2/ui'

|Name|Type|Default|Required|Description|
|---|---|---|---|---|
|ariaLabel|string|||Add an aria-label attribute to the input element *|
|autoComplete|string|||The [native `autocomplete` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete)|
|className|string||||
|dataTest|string|`'dhis2-uicore-input'`|||
Expand Down Expand Up @@ -1844,6 +1845,44 @@ import { SingleSelect } from '@dhis2/ui'
|onFocus|function||||
|onKeyDown|function||||

### Menu

#### Usage

To use `Menu`, you can import the component from the `@dhis2/ui` library


```js
import { Menu } from '@dhis2/ui'
```


#### Props

|Name|Type|Default|Required|Description|
|---|---|---|---|---|
|comboBoxId|string||*||
|idPrefix|string||*||
|options|custom||||
|onChange|function||*||
|disabled|boolean||||
|empty|node||||
|filterLabel|string||||
|filterPlaceholder|string||||
|filterValue|string||||
|filterable|boolean||||
|hidden|boolean||||
|labelledBy|string||||
|loading|boolean||||
|loadingText|string||||
|maxHeight|string||||
|selectRef|instanceOf(HTMLElement)||||
|selected|string||||
|onBlur|function||||
|onClose|function||||
|onFilterChange|function||||
|onKeyDown|function||||

### SingleSelectField

#### Usage
Expand Down
1 change: 1 addition & 0 deletions components/input/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Input } from '@dhis2/ui'

|Name|Type|Default|Required|Description|
|---|---|---|---|---|
|ariaLabel|string|||Add an aria-label attribute to the input element *|
|autoComplete|string|||The [native `autocomplete` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete)|
|className|string||||
|dataTest|string|`'dhis2-uicore-input'`|||
Expand Down
4 changes: 4 additions & 0 deletions components/input/src/input/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export class Input extends Component {
render() {
const {
role,
ariaLabel,
className,
type,
dense,
Expand All @@ -154,6 +155,7 @@ export class Input extends Component {
return (
<div className={cx('input', className)} data-test={dataTest}>
<input
aria-label={ariaLabel}
role={role}
id={name}
name={name}
Expand Down Expand Up @@ -205,6 +207,8 @@ Input.defaultProps = {
}

Input.propTypes = {
/** Add an aria-label attribute to the input element **/
ariaLabel: PropTypes.string,
/** The [native `autocomplete` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete) */
autoComplete: PropTypes.string,
className: PropTypes.string,
Expand Down
20 changes: 13 additions & 7 deletions components/select/i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2021-05-10T11:56:32.496Z\n"
"PO-Revision-Date: 2021-05-10T11:56:32.496Z\n"
"POT-Creation-Date: 2024-10-10T14:39:31.815Z\n"
"PO-Revision-Date: 2024-10-10T14:39:31.816Z\n"

msgid "Clear"
msgstr ""
msgstr "Clear"

msgid "No data found"
msgstr ""
msgstr "No data found"

msgid "Type to filter options"
msgstr ""
msgstr "Type to filter options"

msgid "Loading options"
msgstr ""
msgstr "Loading options"

msgid "No options found"
msgstr ""
msgstr "No options found"

msgid "Search options"
msgstr "Search options"

msgid "{{clearText}}"
msgstr "{{clearText}}"
2 changes: 1 addition & 1 deletion components/select/src/select/filter-input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spacers, colors } from '@dhis2/ui-constants'
import { colors, spacers } from '@dhis2/ui-constants'
import { Input } from '@dhis2-ui/input'
import PropTypes from 'prop-types'
import React from 'react'
Expand Down
42 changes: 42 additions & 0 deletions components/select/src/single-select-a11y/menu-filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { colors, spacers } from '@dhis2/ui-constants'
import { Input } from '@dhis2-ui/input'
import PropTypes from 'prop-types'
import React from 'react'
import i18n from '../locales/index.js'

export function MenuFilter({ value, onChange, placeholder, label }) {
return (
<div>
<Input
ariaLabel={label || i18n.t('Search options')}
dense
value={value}
onChange={({ value }) => onChange(value)}
type="text"
name="filter"
placeholder={placeholder}
initialFocus
/>

<style jsx>{`
div {
position: sticky;
inset-block-start: 0;
background: ${colors.white};
padding-block-start: ${spacers.dp8};
padding-inline-end: ${spacers.dp8};
padding-block-end: ${spacers.dp4};
padding-inline-start: ${spacers.dp8};
z-index: 1;
}
`}</style>
</div>
)
}

MenuFilter.propTypes = {
value: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
label: PropTypes.string,
placeholder: PropTypes.string,
}
116 changes: 116 additions & 0 deletions components/select/src/single-select-a11y/menu-options-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { colors, spacers, theme } from '@dhis2/ui-constants'
import { CircularLoader } from '@dhis2-ui/loader'
import PropTypes from 'prop-types'
import React from 'react'
import { Option } from './option.js'
import { optionsProp } from './shared-prop-types.js'

function Loading({ message }) {
return (
<div className="container">
<div>
<CircularLoader small />
</div>

{message}

<style jsx>{`
.container {
display: flex;
gap: ${spacers.dp16};
align-items: center;
justify-content: center;
color: ${colors.grey700};
font-family: ${theme.fonts};
font-size: 13px;
padding-block: ${spacers.dp8};
padding-inline: ${spacers.dp24};
}
`}</style>
</div>
)
}

Loading.propTypes = {
message: PropTypes.string,
}

export function MenuOptionsList({
comboBoxId,
idPrefix,
labelledBy,
options,
selected,
disabled,
empty,
loading,
loadingText,
onChange,
onBlur,
onKeyDown,
}) {
return (
<div
role="listbox"
id={`listbox-${idPrefix}`}
aria-labelledby={labelledBy}
aria-live="polite"
aria-busy={loading.toString()}
tabIndex="-1"
onBlur={onBlur}
onKeyDown={onKeyDown}
>
{!options.length && empty}

{options.map(
(
{
value,
label,
component,
disabled: optionDisabled = false,
},
index
) => {
const isSelected = value === selected
return (
<Option
key={value}
value={value}
label={label}
index={index}
comboBoxId={comboBoxId}
disabled={disabled || optionDisabled}
selected={isSelected}
onClick={isSelected ? () => null : onChange}
component={component}
/>
)
}
)}

{loading && <Loading message={loadingText} />}

<style jsx>{`
div:empty {
height: 16px;
}
`}</style>
</div>
)
}

MenuOptionsList.propTypes = {
comboBoxId: PropTypes.string.isRequired,
idPrefix: PropTypes.string.isRequired,
options: optionsProp.isRequired,
onChange: PropTypes.func.isRequired,
disabled: PropTypes.bool,
empty: PropTypes.node,
labelledBy: PropTypes.string,
loading: PropTypes.bool,
loadingText: PropTypes.string,
selected: PropTypes.string,
onBlur: PropTypes.func,
onKeyDown: PropTypes.func,
}
Loading

0 comments on commit 3431e82

Please sign in to comment.