@simplybusiness/mobius 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/cjs/components/Checkbox/Checkbox.js +14 -5
- package/dist/cjs/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/cjs/components/Combobox/Combobox.js +129 -0
- package/dist/cjs/components/Combobox/Combobox.js.map +1 -0
- package/dist/cjs/components/Combobox/fixtures.js +244 -0
- package/dist/cjs/components/Combobox/fixtures.js.map +1 -0
- package/dist/cjs/components/Combobox/index.js +21 -0
- package/dist/cjs/components/Combobox/index.js.map +1 -0
- package/dist/cjs/components/Combobox/types.js +6 -0
- package/dist/cjs/components/Combobox/types.js.map +1 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/hooks/useTextField/useTextField.js +1 -0
- package/dist/cjs/hooks/useTextField/useTextField.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/components/Checkbox/Checkbox.js +15 -6
- package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/esm/components/Combobox/Combobox.js +114 -0
- package/dist/esm/components/Combobox/Combobox.js.map +1 -0
- package/dist/esm/components/Combobox/fixtures.js +226 -0
- package/dist/esm/components/Combobox/fixtures.js.map +1 -0
- package/dist/esm/components/Combobox/index.js +4 -0
- package/dist/esm/components/Combobox/index.js.map +1 -0
- package/dist/esm/components/Combobox/types.js +3 -0
- package/dist/esm/components/Combobox/types.js.map +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/hooks/useTextField/types.js.map +1 -1
- package/dist/esm/hooks/useTextField/useTextField.js +1 -0
- package/dist/esm/hooks/useTextField/useTextField.js.map +1 -1
- package/dist/types/components/Combobox/Combobox.d.ts +3 -0
- package/dist/types/components/Combobox/Combobox.stories.d.ts +7 -0
- package/dist/types/components/Combobox/Combobox.test.d.ts +1 -0
- package/dist/types/components/Combobox/fixtures.d.ts +5 -0
- package/dist/types/components/Combobox/index.d.ts +2 -0
- package/dist/types/components/Combobox/types.d.ts +16 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/hooks/useTextField/types.d.ts +3 -2
- package/package.json +1 -1
- package/src/components/Checkbox/Checkbox.test.tsx +1 -2
- package/src/components/Checkbox/Checkbox.tsx +21 -7
- package/src/components/Combobox/Combobox.css +30 -0
- package/src/components/Combobox/Combobox.stories.tsx +26 -0
- package/src/components/Combobox/Combobox.test.tsx +578 -0
- package/src/components/Combobox/Combobox.tsx +154 -0
- package/src/components/Combobox/fixtures.tsx +93 -0
- package/src/components/Combobox/index.tsx +2 -0
- package/src/components/Combobox/types.tsx +20 -0
- package/src/components/index.tsx +1 -0
- package/src/hooks/useTextField/types.tsx +7 -1
- package/src/hooks/useTextField/useTextField.test.tsx +1 -0
- package/src/hooks/useTextField/useTextField.tsx +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- af05836: Adds `role` attribute to `useTextfield` hook
|
|
8
|
+
- ec04e00: Fix `Checkbox` is not checked when clicked
|
|
9
|
+
- a0d927d: Add keyboard events to `useTextField` props
|
|
10
|
+
- cc9aad5: Add `Combobox` component
|
|
11
|
+
- d1b33b1: Add Rocket Lawyer theme
|
|
12
|
+
|
|
3
13
|
## 5.4.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -25,16 +25,26 @@ function _interop_require_default(obj) {
|
|
|
25
25
|
}
|
|
26
26
|
const Checkbox = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
27
27
|
const { id, label, isDisabled, isRequired, validationState, isInvalid, onChange, className, errorMessage, selected, defaultSelected = false, isReadOnly, isLastItem, name, value, ["aria-describedby"]: ariaDescribedBy, ...rest } = props;
|
|
28
|
+
const [checked, setChecked] = (0, _react.useState)(defaultSelected);
|
|
28
29
|
const fallbackRef = (0, _react.useRef)(null);
|
|
29
30
|
const refObj = ref || fallbackRef;
|
|
30
31
|
const inputId = (0, _react.useId)();
|
|
32
|
+
const isControlled = typeof selected === "boolean";
|
|
33
|
+
(0, _react.useEffect)(()=>{
|
|
34
|
+
if (isControlled) {
|
|
35
|
+
setChecked(selected);
|
|
36
|
+
}
|
|
37
|
+
}, [
|
|
38
|
+
selected,
|
|
39
|
+
isControlled
|
|
40
|
+
]);
|
|
31
41
|
const validationClasses = (0, _hooks.useValidationClasses)({
|
|
32
42
|
validationState,
|
|
33
43
|
isInvalid
|
|
34
44
|
});
|
|
35
45
|
const sharedClasses = (0, _dedupe.default)({
|
|
36
46
|
"--is-disabled": isDisabled,
|
|
37
|
-
"--is-selected":
|
|
47
|
+
"--is-selected": checked,
|
|
38
48
|
"--is-required": typeof isRequired === "boolean" && isRequired,
|
|
39
49
|
"--is-optional": typeof isRequired === "boolean" && !isRequired
|
|
40
50
|
}, validationClasses);
|
|
@@ -51,11 +61,11 @@ const Checkbox = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
|
51
61
|
]);
|
|
52
62
|
const labelId = (0, _react.useId)();
|
|
53
63
|
const handleChange = (event)=>{
|
|
64
|
+
setChecked(!checked);
|
|
54
65
|
if (onChange) {
|
|
55
66
|
onChange(event, isLastItem);
|
|
56
67
|
}
|
|
57
68
|
};
|
|
58
|
-
const isControlled = typeof props.selected === "boolean";
|
|
59
69
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_Stack.Stack, {
|
|
60
70
|
gap: "xs",
|
|
61
71
|
className: wrapperClasses,
|
|
@@ -74,8 +84,7 @@ const Checkbox = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
|
74
84
|
className: inputClasses,
|
|
75
85
|
onChange: handleChange,
|
|
76
86
|
type: "checkbox",
|
|
77
|
-
checked:
|
|
78
|
-
defaultChecked: isControlled ? undefined : defaultSelected,
|
|
87
|
+
checked: checked,
|
|
79
88
|
required: isRequired,
|
|
80
89
|
id: id || inputId,
|
|
81
90
|
name: name,
|
|
@@ -83,7 +92,7 @@ const Checkbox = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
|
83
92
|
...rest
|
|
84
93
|
}),
|
|
85
94
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Icon.Icon, {
|
|
86
|
-
icon:
|
|
95
|
+
icon: checked ? _icons.squareTick : _icons.square,
|
|
87
96
|
size: "md",
|
|
88
97
|
className: iconClasses
|
|
89
98
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["\"use client\";\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ChangeEvent,\n forwardRef,\n useRef,\n useId,\n useState,\n useEffect,\n} from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport { squareTick, square } from \"@simplybusiness/icons\";\nimport { ErrorMessage } from \"../ErrorMessage\";\nimport { ForwardedRefComponent } from \"../../types/components\";\nimport { CheckboxElementType, CheckboxProps, CheckboxRef } from \"./types\";\nimport { spaceDelimitedList } from \"../../utils/spaceDelimitedList\";\nimport { useValidationClasses } from \"../../hooks\";\nimport { Icon } from \"../Icon\";\nimport { Stack } from \"../Stack\";\n\nexport const Checkbox: ForwardedRefComponent<\n CheckboxProps,\n CheckboxElementType\n> = forwardRef((props: CheckboxProps, ref: CheckboxRef) => {\n const {\n id,\n label,\n isDisabled,\n isRequired,\n validationState,\n isInvalid,\n onChange,\n className,\n errorMessage,\n selected,\n defaultSelected = false,\n isReadOnly,\n isLastItem,\n name,\n value,\n [\"aria-describedby\"]: ariaDescribedBy,\n ...rest\n } = props;\n const [checked, setChecked] = useState<boolean>(defaultSelected);\n const fallbackRef = useRef<HTMLInputElement>(null);\n const refObj = ref || fallbackRef;\n const inputId = useId();\n\n const isControlled = typeof selected === \"boolean\";\n useEffect(() => {\n if (isControlled) {\n setChecked(selected);\n }\n }, [selected, isControlled]);\n\n const validationClasses = useValidationClasses({\n validationState,\n isInvalid,\n });\n const sharedClasses = classNames(\n {\n \"--is-disabled\": isDisabled,\n \"--is-selected\": checked,\n \"--is-required\": typeof isRequired === \"boolean\" && isRequired,\n \"--is-optional\": typeof isRequired === \"boolean\" && !isRequired,\n },\n validationClasses,\n );\n // Append an additional wrapper class name to differenitate from input\n const wrapperClasses = classNames(\n \"mobius\",\n \"mobius-checkbox\",\n sharedClasses,\n className,\n );\n const labelClasses = classNames(\"mobius-checkbox__label\", sharedClasses);\n const inputClasses = classNames(\"mobius-checkbox__input\", sharedClasses);\n const iconClasses = classNames(\"mobius-checkbox__icon\", sharedClasses);\n const errorMessageId = useId();\n const shouldErrorMessageShow = errorMessage ? errorMessageId : undefined;\n const describedBy = spaceDelimitedList([\n shouldErrorMessageShow,\n ariaDescribedBy,\n ]);\n const labelId = useId();\n\n const handleChange = (event: ChangeEvent<CheckboxElementType>) => {\n setChecked(!checked);\n if (onChange) {\n onChange(event, isLastItem);\n }\n };\n\n return (\n <Stack gap=\"xs\" className={wrapperClasses}>\n <label className={labelClasses}>\n <input\n aria-describedby={describedBy}\n aria-errormessage={shouldErrorMessageShow}\n aria-invalid={isInvalid}\n aria-labelledby={labelId}\n readOnly={isReadOnly}\n disabled={isDisabled}\n ref={refObj}\n className={inputClasses}\n onChange={handleChange}\n type=\"checkbox\"\n checked={checked}\n required={isRequired}\n id={id || inputId}\n name={name}\n value={value}\n {...rest}\n />\n <Icon\n icon={checked ? squareTick : square}\n size=\"md\"\n className={iconClasses}\n />\n <span id={labelId} className=\"mobius-checkbox__visible-label\">\n {label}\n </span>\n </label>\n <ErrorMessage id={errorMessageId} errorMessage={errorMessage} />\n </Stack>\n );\n});\n"],"names":["Checkbox","forwardRef","props","ref","id","label","isDisabled","isRequired","validationState","isInvalid","onChange","className","errorMessage","selected","defaultSelected","isReadOnly","isLastItem","name","value","ariaDescribedBy","rest","checked","setChecked","useState","fallbackRef","useRef","refObj","inputId","useId","isControlled","useEffect","validationClasses","useValidationClasses","sharedClasses","classNames","wrapperClasses","labelClasses","inputClasses","iconClasses","errorMessageId","shouldErrorMessageShow","undefined","describedBy","spaceDelimitedList","labelId","handleChange","event","Stack","gap","input","aria-describedby","aria-errormessage","aria-invalid","aria-labelledby","readOnly","disabled","type","required","Icon","icon","squareTick","square","size","span","ErrorMessage"],"mappings":"AAAA;;;;;+BAoBaA;;;eAAAA;;;;uBAXN;+DACgB;uBACY;8BACN;oCAGM;uBACE;sBAChB;uBACC;;;;;;AAEf,MAAMA,yBAGTC,IAAAA,iBAAU,EAAC,CAACC,OAAsBC;IACpC,MAAM,EACJC,EAAE,EACFC,KAAK,EACLC,UAAU,EACVC,UAAU,EACVC,eAAe,EACfC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,YAAY,EACZC,QAAQ,EACRC,kBAAkB,KAAK,EACvBC,UAAU,EACVC,UAAU,EACVC,IAAI,EACJC,KAAK,EACL,CAAC,mBAAmB,EAAEC,eAAe,EACrC,GAAGC,MACJ,GAAGlB;IACJ,MAAM,CAACmB,SAASC,WAAW,GAAGC,IAAAA,eAAQ,EAAUT;IAChD,MAAMU,cAAcC,IAAAA,aAAM,EAAmB;IAC7C,MAAMC,SAASvB,OAAOqB;IACtB,MAAMG,UAAUC,IAAAA,YAAK;IAErB,MAAMC,eAAe,OAAOhB,aAAa;IACzCiB,IAAAA,gBAAS,EAAC;QACR,IAAID,cAAc;YAChBP,WAAWT;QACb;IACF,GAAG;QAACA;QAAUgB;KAAa;IAE3B,MAAME,oBAAoBC,IAAAA,2BAAoB,EAAC;QAC7CxB;QACAC;IACF;IACA,MAAMwB,gBAAgBC,IAAAA,eAAU,EAC9B;QACE,iBAAiB5B;QACjB,iBAAi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|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Combobox", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Combobox;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
const _react = require("react");
|
|
13
|
+
const _dedupe = /*#__PURE__*/ _interop_require_default(require("classnames/dedupe"));
|
|
14
|
+
const _TextField = require("../TextField");
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const getOptionValue = (option)=>typeof option === "string" ? option : option.value;
|
|
21
|
+
const getOptionLabel = (option)=>typeof option === "string" ? option : option.label;
|
|
22
|
+
const Combobox = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
23
|
+
const { defaultValue, options, onSelected } = props;
|
|
24
|
+
const fallbackRef = (0, _react.useRef)();
|
|
25
|
+
const [inputValue, setInputValue] = (0, _react.useState)(defaultValue || "");
|
|
26
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
27
|
+
const [highlightedIndex, setHighlightedIndex] = (0, _react.useState)(-1);
|
|
28
|
+
const [filteredOptions, setFilteredOptions] = (0, _react.useState)([]);
|
|
29
|
+
const inputRef = ref || fallbackRef;
|
|
30
|
+
const listboxId = (0, _react.useId)();
|
|
31
|
+
(0, _react.useEffect)(()=>{
|
|
32
|
+
const fetchOptions = async ()=>{
|
|
33
|
+
if (typeof options === "function") {
|
|
34
|
+
const result = await options(inputValue);
|
|
35
|
+
setFilteredOptions(result);
|
|
36
|
+
} else {
|
|
37
|
+
setFilteredOptions(options.filter((option)=>getOptionLabel(option).toLowerCase().includes(inputValue.toLowerCase())));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
fetchOptions();
|
|
41
|
+
}, [
|
|
42
|
+
inputValue,
|
|
43
|
+
options
|
|
44
|
+
]);
|
|
45
|
+
const handleFocus = ()=>{
|
|
46
|
+
setIsOpen(true);
|
|
47
|
+
};
|
|
48
|
+
const handleBlur = ()=>{
|
|
49
|
+
setIsOpen(false);
|
|
50
|
+
};
|
|
51
|
+
const handleInputChange = (e)=>{
|
|
52
|
+
const newValue = e.target.value;
|
|
53
|
+
setInputValue(newValue);
|
|
54
|
+
setIsOpen(true);
|
|
55
|
+
setHighlightedIndex(-1);
|
|
56
|
+
};
|
|
57
|
+
const handleOptionSelect = (option)=>{
|
|
58
|
+
const value = getOptionValue(option);
|
|
59
|
+
setIsOpen(false);
|
|
60
|
+
setInputValue(value);
|
|
61
|
+
onSelected === null || onSelected === void 0 ? void 0 : onSelected(value);
|
|
62
|
+
};
|
|
63
|
+
const handleKeyDown = (e)=>{
|
|
64
|
+
switch(e.key){
|
|
65
|
+
case "ArrowDown":
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
setIsOpen(true);
|
|
68
|
+
setHighlightedIndex((prev)=>prev < filteredOptions.length - 1 ? prev + 1 : 0);
|
|
69
|
+
break;
|
|
70
|
+
case "ArrowUp":
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
setIsOpen(true);
|
|
73
|
+
setHighlightedIndex((prev)=>prev > 0 ? prev - 1 : filteredOptions.length - 1);
|
|
74
|
+
break;
|
|
75
|
+
case "Enter":
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
if (isOpen && highlightedIndex >= 0) {
|
|
78
|
+
handleOptionSelect(filteredOptions[highlightedIndex]);
|
|
79
|
+
} else if (isOpen && highlightedIndex === -1 && filteredOptions.length > 0) {
|
|
80
|
+
handleOptionSelect(filteredOptions[0]);
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
case "Escape":
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
setIsOpen(false);
|
|
86
|
+
setHighlightedIndex(-1);
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
92
|
+
className: "mobius mobius-combobox",
|
|
93
|
+
children: [
|
|
94
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_TextField.TextField, {
|
|
95
|
+
className: "mobius-combobox__input",
|
|
96
|
+
role: "combobox",
|
|
97
|
+
value: inputValue,
|
|
98
|
+
onFocus: handleFocus,
|
|
99
|
+
onBlur: handleBlur,
|
|
100
|
+
onKeyDown: handleKeyDown,
|
|
101
|
+
onChange: handleInputChange,
|
|
102
|
+
"aria-autocomplete": "list",
|
|
103
|
+
"aria-haspopup": "listbox",
|
|
104
|
+
"aria-controls": listboxId,
|
|
105
|
+
"aria-expanded": isOpen,
|
|
106
|
+
"aria-activedescendant": highlightedIndex === -1 ? undefined : `${listboxId}-option-${highlightedIndex}`,
|
|
107
|
+
// @ts-expect-error I have no idea how ref typing works
|
|
108
|
+
ref: inputRef
|
|
109
|
+
}),
|
|
110
|
+
isOpen && /*#__PURE__*/ (0, _jsxruntime.jsx)("ul", {
|
|
111
|
+
role: "listbox",
|
|
112
|
+
id: listboxId,
|
|
113
|
+
className: "mobius-combobox__list",
|
|
114
|
+
children: filteredOptions.map((option, index)=>/*#__PURE__*/ (0, _jsxruntime.jsx)("li", {
|
|
115
|
+
role: "option",
|
|
116
|
+
id: `${listboxId}-option-${index}`,
|
|
117
|
+
"aria-selected": highlightedIndex === index,
|
|
118
|
+
onMouseDown: ()=>handleOptionSelect(option),
|
|
119
|
+
className: (0, _dedupe.default)("mobius-combobox__option", {
|
|
120
|
+
"mobius-combobox__option--is-highlighted": highlightedIndex === index
|
|
121
|
+
}),
|
|
122
|
+
children: getOptionLabel(option)
|
|
123
|
+
}, getOptionValue(option)))
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
//# sourceMappingURL=Combobox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import { forwardRef, useId, useRef, useState, useEffect } from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport { TextField } from \"../TextField\";\nimport type {\n ComboboxProps,\n ComboboxElementType,\n ComboboxRef,\n ComboboxOption,\n} from \"./types\";\nimport type { ForwardedRefComponent } from \"../../types\";\n\nconst getOptionValue = (option: ComboboxOption) =>\n typeof option === \"string\" ? option : option.value;\n\nconst getOptionLabel = (option: ComboboxOption) =>\n typeof option === \"string\" ? option : option.label;\n\nexport const Combobox: ForwardedRefComponent<\n ComboboxProps,\n ComboboxElementType\n> = forwardRef((props: ComboboxProps, ref: ComboboxRef) => {\n const { defaultValue, options, onSelected } = props;\n\n const fallbackRef = useRef();\n const [inputValue, setInputValue] = useState(defaultValue || \"\");\n const [isOpen, setIsOpen] = useState(false);\n const [highlightedIndex, setHighlightedIndex] = useState(-1);\n const [filteredOptions, setFilteredOptions] = useState<ComboboxOption[]>([]);\n const inputRef = ref || fallbackRef;\n const listboxId = useId();\n\n useEffect(() => {\n const fetchOptions = async () => {\n if (typeof options === \"function\") {\n const result = await options(inputValue);\n setFilteredOptions(result);\n } else {\n setFilteredOptions(\n options.filter(option =>\n getOptionLabel(option)\n .toLowerCase()\n .includes(inputValue.toLowerCase()),\n ),\n );\n }\n };\n\n fetchOptions();\n }, [inputValue, options]);\n\n const handleFocus = () => {\n setIsOpen(true);\n };\n\n const handleBlur = () => {\n setIsOpen(false);\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n setInputValue(newValue);\n setIsOpen(true);\n setHighlightedIndex(-1);\n };\n\n const handleOptionSelect = (option: ComboboxOption) => {\n const value = getOptionValue(option);\n setIsOpen(false);\n setInputValue(value);\n onSelected?.(value);\n };\n\n const handleKeyDown = (e: React.KeyboardEvent) => {\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n setIsOpen(true);\n setHighlightedIndex(prev =>\n prev < filteredOptions.length - 1 ? prev + 1 : 0,\n );\n break;\n case \"ArrowUp\":\n e.preventDefault();\n setIsOpen(true);\n setHighlightedIndex(prev =>\n prev > 0 ? prev - 1 : filteredOptions.length - 1,\n );\n break;\n case \"Enter\":\n e.preventDefault();\n if (isOpen && highlightedIndex >= 0) {\n handleOptionSelect(filteredOptions[highlightedIndex]);\n } else if (\n isOpen &&\n highlightedIndex === -1 &&\n filteredOptions.length > 0\n ) {\n handleOptionSelect(filteredOptions[0]);\n }\n break;\n case \"Escape\":\n e.preventDefault();\n setIsOpen(false);\n setHighlightedIndex(-1);\n break;\n default:\n // Do nothing\n }\n };\n\n return (\n <div className=\"mobius mobius-combobox\">\n <TextField\n className=\"mobius-combobox__input\"\n role=\"combobox\"\n value={inputValue}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n onChange={handleInputChange}\n aria-autocomplete=\"list\"\n aria-haspopup=\"listbox\"\n aria-controls={listboxId}\n aria-expanded={isOpen}\n aria-activedescendant={\n highlightedIndex === -1\n ? undefined\n : `${listboxId}-option-${highlightedIndex}`\n }\n // @ts-expect-error I have no idea how ref typing works\n ref={inputRef}\n />\n {isOpen && (\n <ul role=\"listbox\" id={listboxId} className=\"mobius-combobox__list\">\n {filteredOptions.map((option, index) => (\n <li\n role=\"option\"\n key={getOptionValue(option)}\n id={`${listboxId}-option-${index}`}\n aria-selected={highlightedIndex === index}\n onMouseDown={() => handleOptionSelect(option)}\n className={classNames(\"mobius-combobox__option\", {\n \"mobius-combobox__option--is-highlighted\":\n highlightedIndex === index,\n })}\n >\n {getOptionLabel(option)}\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n});\n"],"names":["Combobox","getOptionValue","option","value","getOptionLabel","label","forwardRef","props","ref","defaultValue","options","onSelected","fallbackRef","useRef","inputValue","setInputValue","useState","isOpen","setIsOpen","highlightedIndex","setHighlightedIndex","filteredOptions","setFilteredOptions","inputRef","listboxId","useId","useEffect","fetchOptions","result","filter","toLowerCase","includes","handleFocus","handleBlur","handleInputChange","e","newValue","target","handleOptionSelect","handleKeyDown","key","preventDefault","prev","length","div","className","TextField","role","onFocus","onBlur","onKeyDown","onChange","aria-autocomplete","aria-haspopup","aria-controls","aria-expanded","aria-activedescendant","undefined","ul","id","map","index","li","aria-selected","onMouseDown","classNames"],"mappings":";;;;+BAiBaA;;;eAAAA;;;;uBAjBkD;+DACxC;2BACG;;;;;;AAS1B,MAAMC,iBAAiB,CAACC,SACtB,OAAOA,WAAW,WAAWA,SAASA,OAAOC,KAAK;AAEpD,MAAMC,iBAAiB,CAACF,SACtB,OAAOA,WAAW,WAAWA,SAASA,OAAOG,KAAK;AAE7C,MAAML,yBAGTM,IAAAA,iBAAU,EAAC,CAACC,OAAsBC;IACpC,MAAM,EAAEC,YAAY,EAAEC,OAAO,EAAEC,UAAU,EAAE,GAAGJ;IAE9C,MAAMK,cAAcC,IAAAA,aAAM;IAC1B,MAAM,CAACC,YAAYC,cAAc,GAAGC,IAAAA,eAAQ,EAACP,gBAAgB;IAC7D,MAAM,CAACQ,QAAQC,UAAU,GAAGF,IAAAA,eAAQ,EAAC;IACrC,MAAM,CAACG,kBAAkBC,oBAAoB,GAAGJ,IAAAA,eAAQ,EAAC,CAAC;IAC1D,MAAM,CAACK,iBAAiBC,mBAAmB,GAAGN,IAAAA,eAAQ,EAAmB,EAAE;IAC3E,MAAMO,WAAWf,OAAOI;IACxB,MAAMY,YAAYC,IAAAA,YAAK;IAEvBC,IAAAA,gBAAS,EAAC;QACR,MAAMC,eAAe;YACnB,IAAI,OAAOjB,YAAY,YAAY;gBACjC,MAAMkB,SAAS,MAAMlB,QAAQI;gBAC7BQ,mBAAmBM;YACrB,OAAO;gBACLN,mBACEZ,QAAQmB,MAAM,CAAC3B,CAAAA,SACbE,eAAeF,QACZ4B,WAAW,GACXC,QAAQ,CAACjB,WAAWgB,WAAW;YAGxC;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gBACdC,iBAAe9B;gBACf+B,iBAAetC;gBACfuC,yBACErC,qBAAqB,CAAC,IAClBsC,YACA,GAAGjC,UAAU,QAAQ,EAAEL,kBAAkB;gBAE/C,uDAAuD;gBACvDX,KAAKe;;YAENN,wBACC,qBAACyC;gBAAGX,MAAK;gBAAUY,IAAInC;gBAAWqB,WAAU;0BACzCxB,gBAAgBuC,GAAG,CAAC,CAAC1D,QAAQ2D,sBAC5B,qBAACC;wBACCf,MAAK;wBAELY,IAAI,GAAGnC,UAAU,QAAQ,EAAEqC,OAAO;wBAClCE,iBAAe5C,qBAAqB0C;wBACpCG,aAAa,IAAM1B,mBAAmBpC;wBACtC2C,WAAWoB,IAAAA,eAAU,EAAC,2BAA2B;4BAC/C,2CACE9C,qBAAqB0C;wBACzB;kCAECzD,eAAeF;uBATXD,eAAeC;;;;AAgBlC"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
FRUITS: function() {
|
|
13
|
+
return FRUITS;
|
|
14
|
+
},
|
|
15
|
+
FRUITS_OBJECTS: function() {
|
|
16
|
+
return FRUITS_OBJECTS;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const FRUITS = [
|
|
20
|
+
"Apple",
|
|
21
|
+
"Apricot",
|
|
22
|
+
"Avocado",
|
|
23
|
+
"Banana",
|
|
24
|
+
"Blackberry",
|
|
25
|
+
"Blueberry",
|
|
26
|
+
"Cantaloupe",
|
|
27
|
+
"Cherry",
|
|
28
|
+
"Clementine",
|
|
29
|
+
"Coconut",
|
|
30
|
+
"Cranberry",
|
|
31
|
+
"Date",
|
|
32
|
+
"Dragonfruit",
|
|
33
|
+
"Durian",
|
|
34
|
+
"Elderberry",
|
|
35
|
+
"Fig",
|
|
36
|
+
"Grape",
|
|
37
|
+
"Grapefruit",
|
|
38
|
+
"Guava",
|
|
39
|
+
"Honeydew",
|
|
40
|
+
"Jackfruit",
|
|
41
|
+
"Kiwi",
|
|
42
|
+
"Kumquat",
|
|
43
|
+
"Lemon",
|
|
44
|
+
"Lime",
|
|
45
|
+
"Lychee",
|
|
46
|
+
"Mango",
|
|
47
|
+
"Mulberry",
|
|
48
|
+
"Nectarine",
|
|
49
|
+
"Orange",
|
|
50
|
+
"Papaya",
|
|
51
|
+
"Passionfruit",
|
|
52
|
+
"Peach",
|
|
53
|
+
"Pear",
|
|
54
|
+
"Persimmon",
|
|
55
|
+
"Pineapple",
|
|
56
|
+
"Plum",
|
|
57
|
+
"Pomegranate",
|
|
58
|
+
"Raspberry",
|
|
59
|
+
"Redcurrant",
|
|
60
|
+
"Starfruit",
|
|
61
|
+
"Strawberry",
|
|
62
|
+
"Tangerine",
|
|
63
|
+
"Watermelon"
|
|
64
|
+
];
|
|
65
|
+
const FRUITS_OBJECTS = [
|
|
66
|
+
{
|
|
67
|
+
label: "Apple",
|
|
68
|
+
value: "apple"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
label: "Apricot",
|
|
72
|
+
value: "apricot"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: "Avocado",
|
|
76
|
+
value: "avocado"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
label: "Banana",
|
|
80
|
+
value: "banana"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: "Blackberry",
|
|
84
|
+
value: "blackberry"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
label: "Blueberry",
|
|
88
|
+
value: "blueberry"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
label: "Cantaloupe",
|
|
92
|
+
value: "cantaloupe"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
label: "Cherry",
|
|
96
|
+
value: "cherry"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
label: "Clementine",
|
|
100
|
+
value: "clementine"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
label: "Coconut",
|
|
104
|
+
value: "coconut"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: "Cranberry",
|
|
108
|
+
value: "cranberry"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
label: "Date",
|
|
112
|
+
value: "date"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
label: "Dragonfruit",
|
|
116
|
+
value: "dragonfruit"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
label: "Durian",
|
|
120
|
+
value: "durian"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
label: "Elderberry",
|
|
124
|
+
value: "elderberry"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
label: "Fig",
|
|
128
|
+
value: "fig"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
label: "Grape",
|
|
132
|
+
value: "grape"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
label: "Grapefruit",
|
|
136
|
+
value: "grapefruit"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
label: "Guava",
|
|
140
|
+
value: "guava"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
label: "Honeydew",
|
|
144
|
+
value: "honeydew"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
label: "Jackfruit",
|
|
148
|
+
value: "jackfruit"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
label: "Kiwi",
|
|
152
|
+
value: "kiwi"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
label: "Kumquat",
|
|
156
|
+
value: "kumquat"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
label: "Lemon",
|
|
160
|
+
value: "lemon"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
label: "Lime",
|
|
164
|
+
value: "lime"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
label: "Lychee",
|
|
168
|
+
value: "lychee"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
label: "Mango",
|
|
172
|
+
value: "mango"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
label: "Mulberry",
|
|
176
|
+
value: "mulberry"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
label: "Nectarine",
|
|
180
|
+
value: "nectarine"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
label: "Orange",
|
|
184
|
+
value: "orange"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
label: "Papaya",
|
|
188
|
+
value: "papaya"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
label: "Passionfruit",
|
|
192
|
+
value: "passionfruit"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
label: "Peach",
|
|
196
|
+
value: "peach"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
label: "Pear",
|
|
200
|
+
value: "pear"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
label: "Persimmon",
|
|
204
|
+
value: "persimmon"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
label: "Pineapple",
|
|
208
|
+
value: "pineapple"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
label: "Plum",
|
|
212
|
+
value: "plum"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
label: "Pomegranate",
|
|
216
|
+
value: "pomegranate"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
label: "Raspberry",
|
|
220
|
+
value: "raspberry"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
label: "Redcurrant",
|
|
224
|
+
value: "redcurrant"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
label: "Starfruit",
|
|
228
|
+
value: "starfruit"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
label: "Strawberry",
|
|
232
|
+
value: "strawberry"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
label: "Tangerine",
|
|
236
|
+
value: "tangerine"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
label: "Watermelon",
|
|
240
|
+
value: "watermelon"
|
|
241
|
+
}
|
|
242
|
+
];
|
|
243
|
+
|
|
244
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Combobox/fixtures.tsx"],"sourcesContent":["export const FRUITS = [\n \"Apple\",\n \"Apricot\",\n \"Avocado\",\n \"Banana\",\n \"Blackberry\",\n \"Blueberry\",\n \"Cantaloupe\",\n \"Cherry\",\n \"Clementine\",\n \"Coconut\",\n \"Cranberry\",\n \"Date\",\n \"Dragonfruit\",\n \"Durian\",\n \"Elderberry\",\n \"Fig\",\n \"Grape\",\n \"Grapefruit\",\n \"Guava\",\n \"Honeydew\",\n \"Jackfruit\",\n \"Kiwi\",\n \"Kumquat\",\n \"Lemon\",\n \"Lime\",\n \"Lychee\",\n \"Mango\",\n \"Mulberry\",\n \"Nectarine\",\n \"Orange\",\n \"Papaya\",\n \"Passionfruit\",\n \"Peach\",\n \"Pear\",\n \"Persimmon\",\n \"Pineapple\",\n \"Plum\",\n \"Pomegranate\",\n \"Raspberry\",\n \"Redcurrant\",\n \"Starfruit\",\n \"Strawberry\",\n \"Tangerine\",\n \"Watermelon\",\n];\n\nexport const FRUITS_OBJECTS = [\n { label: \"Apple\", value: \"apple\" },\n { label: \"Apricot\", value: \"apricot\" },\n { label: \"Avocado\", value: \"avocado\" },\n { label: \"Banana\", value: \"banana\" },\n { label: \"Blackberry\", value: \"blackberry\" },\n { label: \"Blueberry\", value: \"blueberry\" },\n { label: \"Cantaloupe\", value: \"cantaloupe\" },\n { label: \"Cherry\", value: \"cherry\" },\n { label: \"Clementine\", value: \"clementine\" },\n { label: \"Coconut\", value: \"coconut\" },\n { label: \"Cranberry\", value: \"cranberry\" },\n { label: \"Date\", value: \"date\" },\n { label: \"Dragonfruit\", value: \"dragonfruit\" },\n { label: \"Durian\", value: \"durian\" },\n { label: \"Elderberry\", value: \"elderberry\" },\n { label: \"Fig\", value: \"fig\" },\n { label: \"Grape\", value: \"grape\" },\n { label: \"Grapefruit\", value: \"grapefruit\" },\n { label: \"Guava\", value: \"guava\" },\n { label: \"Honeydew\", value: \"honeydew\" },\n { label: \"Jackfruit\", value: \"jackfruit\" },\n { label: \"Kiwi\", value: \"kiwi\" },\n { label: \"Kumquat\", value: \"kumquat\" },\n { label: \"Lemon\", value: \"lemon\" },\n { label: \"Lime\", value: \"lime\" },\n { label: \"Lychee\", value: \"lychee\" },\n { label: \"Mango\", value: \"mango\" },\n { label: \"Mulberry\", value: \"mulberry\" },\n { label: \"Nectarine\", value: \"nectarine\" },\n { label: \"Orange\", value: \"orange\" },\n { label: \"Papaya\", value: \"papaya\" },\n { label: \"Passionfruit\", value: \"passionfruit\" },\n { label: \"Peach\", value: \"peach\" },\n { label: \"Pear\", value: \"pear\" },\n { label: \"Persimmon\", value: \"persimmon\" },\n { label: \"Pineapple\", value: \"pineapple\" },\n { label: \"Plum\", value: \"plum\" },\n { label: \"Pomegranate\", value: \"pomegranate\" },\n { label: \"Raspberry\", value: \"raspberry\" },\n { label: \"Redcurrant\", value: \"redcurrant\" },\n { label: \"Starfruit\", value: \"starfruit\" },\n { label: \"Strawberry\", value: \"strawberry\" },\n { label: \"Tangerine\", value: \"tangerine\" },\n { label: \"Watermelon\", value: \"watermelon\" },\n];\n"],"names":["FRUITS","FRUITS_OBJECTS","label","value"],"mappings":";;;;;;;;;;;IAAaA,MAAM;eAANA;;IA+CAC,cAAc;eAAdA;;;AA/CN,MAAMD,SAAS;IACpB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;I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YC,OAAO;IAAW;IACvC;QAAED,OAAO;QAAaC,OAAO;IAAY;IACzC;QAAED,OAAO;QAAUC,OAAO;IAAS;IACnC;QAAED,OAAO;QAAUC,OAAO;IAAS;IACnC;QAAED,OAAO;QAAgBC,OAAO;IAAe;IAC/C;QAAED,OAAO;QAASC,OAAO;IAAQ;IACjC;QAAED,OAAO;QAAQC,OAAO;IAAO;IAC/B;QAAED,OAAO;QAAaC,OAAO;IAAY;IACzC;QAAED,OAAO;QAAaC,OAAO;IAAY;IACzC;QAAED,OAAO;QAAQC,OAAO;IAAO;IAC/B;QAAED,OAAO;QAAeC,OAAO;IAAc;IAC7C;QAAED,OAAO;QAAaC,OAAO;IAAY;IACzC;QAAED,OAAO;QAAcC,OAAO;IAAa;IAC3C;QAAED,OAAO;QAAaC,OAAO;IAAY;IACzC;QAAED,OAAO;QAAcC,OAAO;IAAa;IAC3C;QAAED,OAAO;QAAaC,OAAO;IAAY;IACzC;QAAED,OAAO;QAAcC,OAAO;IAAa;CAC5C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./Combobox"), exports);
|
|
6
|
+
_export_star(require("./types"), exports);
|
|
7
|
+
function _export_star(from, to) {
|
|
8
|
+
Object.keys(from).forEach(function(k) {
|
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
+
Object.defineProperty(to, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return from[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return from;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Combobox/index.tsx"],"sourcesContent":["export * from \"./Combobox\";\nexport * from \"./types\";\n"],"names":[],"mappings":";;;;qBAAc;qBACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Combobox/types.tsx"],"names":[],"mappings":""}
|
|
@@ -8,6 +8,7 @@ _export_star(require("./Box"), exports);
|
|
|
8
8
|
_export_star(require("./Breadcrumbs"), exports);
|
|
9
9
|
_export_star(require("./Button"), exports);
|
|
10
10
|
_export_star(require("./Checkbox"), exports);
|
|
11
|
+
_export_star(require("./Combobox"), exports);
|
|
11
12
|
_export_star(require("./Container"), exports);
|
|
12
13
|
_export_star(require("./Divider"), exports);
|
|
13
14
|
_export_star(require("./Drawer"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/index.tsx"],"sourcesContent":["export * from \"./Accordion\";\nexport * from \"./Alert\";\nexport * from \"./Box\";\nexport * from \"./Breadcrumbs\";\nexport * from \"./Button\";\nexport * from \"./Checkbox\";\nexport * from \"./Container\";\nexport * from \"./Divider\";\nexport * from \"./Drawer\";\nexport * from \"./DropdownMenu\";\nexport * from \"./ErrorMessage\";\nexport * from \"./Fieldset\";\nexport * from \"./Flex\";\nexport * from \"./Grid\";\nexport * from \"./Icon\";\nexport * from \"./Image\";\nexport * from \"./Label\";\nexport * from \"./Link\";\nexport * from \"./LinkButton\";\nexport * from \"./List\";\nexport * from \"./LoadingIndicator\";\nexport * from \"./Logo\";\nexport * from \"./Modal\";\nexport * from \"./NumberField\";\nexport * from \"./Option\";\nexport * from \"./PasswordField\";\nexport * from \"./Popover\";\nexport * from \"./Progress\";\nexport * from \"./Radio\";\nexport * from \"./Segment\";\nexport * from \"./Select\";\nexport * from \"./Slider\";\nexport * from \"./Stack\";\nexport * from \"./SVG\";\nexport * from \"./Table\";\nexport * from \"./Text\";\nexport * from \"./TextArea\";\nexport * from \"./TextAreaInput\";\nexport * from \"./TextField\";\nexport * from \"./Title\";\nexport * from \"./Trust\";\nexport * from \"./VisuallyHidden\";\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/index.tsx"],"sourcesContent":["export * from \"./Accordion\";\nexport * from \"./Alert\";\nexport * from \"./Box\";\nexport * from \"./Breadcrumbs\";\nexport * from \"./Button\";\nexport * from \"./Checkbox\";\nexport * from \"./Combobox\";\nexport * from \"./Container\";\nexport * from \"./Divider\";\nexport * from \"./Drawer\";\nexport * from \"./DropdownMenu\";\nexport * from \"./ErrorMessage\";\nexport * from \"./Fieldset\";\nexport * from \"./Flex\";\nexport * from \"./Grid\";\nexport * from \"./Icon\";\nexport * from \"./Image\";\nexport * from \"./Label\";\nexport * from \"./Link\";\nexport * from \"./LinkButton\";\nexport * from \"./List\";\nexport * from \"./LoadingIndicator\";\nexport * from \"./Logo\";\nexport * from \"./Modal\";\nexport * from \"./NumberField\";\nexport * from \"./Option\";\nexport * from \"./PasswordField\";\nexport * from \"./Popover\";\nexport * from \"./Progress\";\nexport * from \"./Radio\";\nexport * from \"./Segment\";\nexport * from \"./Select\";\nexport * from \"./Slider\";\nexport * from \"./Stack\";\nexport * from \"./SVG\";\nexport * from \"./Table\";\nexport * from \"./Text\";\nexport * from \"./TextArea\";\nexport * from \"./TextAreaInput\";\nexport * from \"./TextField\";\nexport * from \"./Title\";\nexport * from \"./Trust\";\nexport * from \"./VisuallyHidden\";\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -41,6 +41,7 @@ function useTextField(props) {
|
|
|
41
41
|
"aria-invalid": props.isInvalid,
|
|
42
42
|
"aria-describedby": ariaDescribedBy,
|
|
43
43
|
"aria-errormessage": props["aria-errormessage"],
|
|
44
|
+
role: props.role,
|
|
44
45
|
type: inputElementType === "input" ? props.type : undefined,
|
|
45
46
|
pattern: inputElementType === "input" ? props.pattern : undefined,
|
|
46
47
|
autoComplete: props.autoComplete,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/useTextField/useTextField.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport { spaceDelimitedList } from \"../../utils/spaceDelimitedList\";\nimport { useLabel } from \"../useLabel/useLabel\";\nimport { UseTextFieldProps, UseTextFieldReturn } from \"./types\";\n\nexport function useTextField(props: UseTextFieldProps): UseTextFieldReturn {\n const {\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n inputElementType = \"input\",\n } = props;\n const { labelProps, fieldProps } = useLabel(props);\n\n const descriptionId = useId();\n const descriptionProps = { id: descriptionId };\n\n const errorMessageId = useId();\n const errorMessageProps = { id: errorMessageId };\n\n const ariaDescribedBy = spaceDelimitedList([\n props.description && descriptionId,\n props.errorMessage && errorMessageId,\n props[\"aria-describedby\"],\n ]);\n\n return {\n descriptionProps,\n errorMessageProps,\n labelProps,\n inputProps: {\n defaultValue: props.defaultValue,\n value: props.value,\n onChange: props.onChange,\n disabled: isDisabled,\n readOnly: isReadOnly,\n \"aria-required\": isRequired === true ? true : undefined,\n \"aria-invalid\": props.isInvalid,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": props[\"aria-errormessage\"],\n\n type: inputElementType === \"input\" ? props.type : undefined,\n pattern: inputElementType === \"input\" ? props.pattern : undefined,\n\n autoComplete: props.autoComplete,\n maxLength: props.maxLength,\n minLength: props.minLength,\n name: props.name,\n placeholder: props.placeholder,\n inputMode: props.inputMode,\n\n // Clipboard events\n onCopy: props.onCopy,\n onCut: props.onCut,\n onPaste: props.onPaste,\n\n // Composition events\n onCompositionEnd: props.onCompositionEnd,\n onCompositionStart: props.onCompositionStart,\n onCompositionUpdate: props.onCompositionUpdate,\n\n // Selection events\n onSelect: props.onSelect,\n\n // Input events\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n\n // Focus events\n onFocus: props.onFocus,\n onBlur: props.onBlur,\n\n ...fieldProps,\n },\n };\n}\n"],"names":["useTextField","props","isDisabled","isReadOnly","isRequired","inputElementType","labelProps","fieldProps","useLabel","descriptionId","useId","descriptionProps","id","errorMessageId","errorMessageProps","ariaDescribedBy","spaceDelimitedList","description","errorMessage","inputProps","defaultValue","value","onChange","disabled","readOnly","undefined","isInvalid","type","pattern","autoComplete","maxLength","minLength","name","placeholder","inputMode","onCopy","onCut","onPaste","onCompositionEnd","onCompositionStart","onCompositionUpdate","onSelect","onBeforeInput","onInput","onFocus","onBlur"],"mappings":";;;;+BAKgBA;;;eAAAA;;;uBALM;oCACa;0BACV;AAGlB,SAASA,aAAaC,KAAwB;IACnD,MAAM,EACJC,aAAa,KAAK,EAClBC,aAAa,KAAK,EAClBC,aAAa,KAAK,EAClBC,mBAAmB,OAAO,EAC3B,GAAGJ;IACJ,MAAM,EAAEK,UAAU,EAAEC,UAAU,EAAE,GAAGC,IAAAA,kBAAQ,EAACP;IAE5C,MAAMQ,gBAAgBC,IAAAA,YAAK;IAC3B,MAAMC,mBAAmB;QAAEC,IAAIH;IAAc;IAE7C,MAAMI,iBAAiBH,IAAAA,YAAK;IAC5B,MAAMI,oBAAoB;QAAEF,IAAIC;IAAe;IAE/C,MAAME,kBAAkBC,IAAAA,sCAAkB,EAAC;QACzCf,MAAMgB,WAAW,IAAIR;QACrBR,MAAMiB,YAAY,IAAIL;QACtBZ,KAAK,CAAC,mBAAmB;KAC1B;IAED,OAAO;QACLU;QACAG;QACAR;QACAa,YAAY;YACVC,cAAcnB,MAAMmB,YAAY;YAChCC,OAAOpB,MAAMoB,KAAK;YAClBC,UAAUrB,MAAMqB,QAAQ;YACxBC,UAAUrB;YACVsB,UAAUrB;YACV,iBAAiBC,eAAe,OAAO,OAAOqB;YAC9C,gBAAgBxB,MAAMyB,SAAS;YAC/B,oBAAoBX;YACpB,qBAAqBd,KAAK,CAAC,oBAAoB;
|
|
1
|
+
{"version":3,"sources":["../../../../src/hooks/useTextField/useTextField.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport { spaceDelimitedList } from \"../../utils/spaceDelimitedList\";\nimport { useLabel } from \"../useLabel/useLabel\";\nimport { UseTextFieldProps, UseTextFieldReturn } from \"./types\";\n\nexport function useTextField(props: UseTextFieldProps): UseTextFieldReturn {\n const {\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n inputElementType = \"input\",\n } = props;\n const { labelProps, fieldProps } = useLabel(props);\n\n const descriptionId = useId();\n const descriptionProps = { id: descriptionId };\n\n const errorMessageId = useId();\n const errorMessageProps = { id: errorMessageId };\n\n const ariaDescribedBy = spaceDelimitedList([\n props.description && descriptionId,\n props.errorMessage && errorMessageId,\n props[\"aria-describedby\"],\n ]);\n\n return {\n descriptionProps,\n errorMessageProps,\n labelProps,\n inputProps: {\n defaultValue: props.defaultValue,\n value: props.value,\n onChange: props.onChange,\n disabled: isDisabled,\n readOnly: isReadOnly,\n \"aria-required\": isRequired === true ? true : undefined,\n \"aria-invalid\": props.isInvalid,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": props[\"aria-errormessage\"],\n role: props.role,\n\n type: inputElementType === \"input\" ? props.type : undefined,\n pattern: inputElementType === \"input\" ? props.pattern : undefined,\n\n autoComplete: props.autoComplete,\n maxLength: props.maxLength,\n minLength: props.minLength,\n name: props.name,\n placeholder: props.placeholder,\n inputMode: props.inputMode,\n\n // Clipboard events\n onCopy: props.onCopy,\n onCut: props.onCut,\n onPaste: props.onPaste,\n\n // Composition events\n onCompositionEnd: props.onCompositionEnd,\n onCompositionStart: props.onCompositionStart,\n onCompositionUpdate: props.onCompositionUpdate,\n\n // Selection events\n onSelect: props.onSelect,\n\n // Input events\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n\n // Focus events\n onFocus: props.onFocus,\n onBlur: props.onBlur,\n\n ...fieldProps,\n },\n };\n}\n"],"names":["useTextField","props","isDisabled","isReadOnly","isRequired","inputElementType","labelProps","fieldProps","useLabel","descriptionId","useId","descriptionProps","id","errorMessageId","errorMessageProps","ariaDescribedBy","spaceDelimitedList","description","errorMessage","inputProps","defaultValue","value","onChange","disabled","readOnly","undefined","isInvalid","role","type","pattern","autoComplete","maxLength","minLength","name","placeholder","inputMode","onCopy","onCut","onPaste","onCompositionEnd","onCompositionStart","onCompositionUpdate","onSelect","onBeforeInput","onInput","onFocus","onBlur"],"mappings":";;;;+BAKgBA;;;eAAAA;;;uBALM;oCACa;0BACV;AAGlB,SAASA,aAAaC,KAAwB;IACnD,MAAM,EACJC,aAAa,KAAK,EAClBC,aAAa,KAAK,EAClBC,aAAa,KAAK,EAClBC,mBAAmB,OAAO,EAC3B,GAAGJ;IACJ,MAAM,EAAEK,UAAU,EAAEC,UAAU,EAAE,GAAGC,IAAAA,kBAAQ,EAACP;IAE5C,MAAMQ,gBAAgBC,IAAAA,YAAK;IAC3B,MAAMC,mBAAmB;QAAEC,IAAIH;IAAc;IAE7C,MAAMI,iBAAiBH,IAAAA,YAAK;IAC5B,MAAMI,oBAAoB;QAAEF,IAAIC;IAAe;IAE/C,MAAME,kBAAkBC,IAAAA,sCAAkB,EAAC;QACzCf,MAAMgB,WAAW,IAAIR;QACrBR,MAAMiB,YAAY,IAAIL;QACtBZ,KAAK,CAAC,mBAAmB;KAC1B;IAED,OAAO;QACLU;QACAG;QACAR;QACAa,YAAY;YACVC,cAAcnB,MAAMmB,YAAY;YAChCC,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