@salt-ds/lab 1.0.0-alpha.100 → 1.0.0-alpha.101

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @salt-ds/lab
2
2
 
3
+ ## 1.0.0-alpha.101
4
+
5
+ ### Patch Changes
6
+
7
+ - 8aaa8d0: Fixed read-only inputs so empty controlled values, empty default values, and empty selections consistently display the `emptyReadOnlyMarker` (`—` by default), while non-empty values such as numeric `0` continue to display the real value.
8
+ - Updated dependencies [8aaa8d0]
9
+ - Updated dependencies [fc112cb]
10
+ - Updated dependencies [8aaa8d0]
11
+ - Updated dependencies [7a828e4]
12
+ - Updated dependencies [87a8a85]
13
+ - Updated dependencies [8156149]
14
+ - @salt-ds/core@1.68.0
15
+ - @salt-ds/styles@0.4.0
16
+ - @salt-ds/icons@1.18.2
17
+
3
18
  ## 1.0.0-alpha.100
4
19
 
5
20
  ### Patch Changes
package/css/salt-lab.css CHANGED
@@ -3264,4 +3264,4 @@
3264
3264
  margin: calc(var(--salt-size-unit) / 2) 0;
3265
3265
  }
3266
3266
 
3267
- /* src/6f33401a-e8aa-4c64-8a91-c7a84caaf9c4.css */
3267
+ /* src/91d946a2-b6ab-42c3-8426-e7a367fde92e.css */
@@ -25,6 +25,9 @@ function mergeA11yProps(a11yProps, inputProps, misplacedAriaProps) {
25
25
  "aria-labelledby": ariaLabelledBy ? Array.from(new Set(ariaLabelledBy.split(" "))).join(" ") : null
26
26
  };
27
27
  }
28
+ function isEmptyReadOnlyValue(value) {
29
+ return value == null || value === "";
30
+ }
28
31
  const InputLegacy = react.forwardRef(
29
32
  function Input({
30
33
  "aria-activedescendant": ariaActiveDescendant,
@@ -95,10 +98,12 @@ const InputLegacy = react.forwardRef(
95
98
  inputPropsProp,
96
99
  misplacedAriaProps
97
100
  );
98
- const isEmptyReadOnly = isReadOnly && !defaultValueProp && !valueProp;
99
- const defaultValue = isEmptyReadOnly ? emptyReadOnlyMarker : defaultValueProp;
101
+ const isValueEmptyReadOnly = isReadOnly && isEmptyReadOnlyValue(valueProp);
102
+ const isDefaultValueEmptyReadOnly = isReadOnly && isEmptyReadOnlyValue(defaultValueProp);
103
+ const controlledValue = valueProp === void 0 ? void 0 : isValueEmptyReadOnly ? emptyReadOnlyMarker : valueProp;
104
+ const defaultValue = isDefaultValueEmptyReadOnly ? emptyReadOnlyMarker : defaultValueProp;
100
105
  const [value, setValue] = core.useControlled({
101
- controlled: valueProp,
106
+ controlled: controlledValue,
102
107
  default: defaultValue,
103
108
  name: "Input",
104
109
  state: "value"
@@ -1 +1 @@
1
- {"version":3,"file":"InputLegacy.js","sources":["../src/input-legacy/InputLegacy.tsx"],"sourcesContent":["import { makePrefixer, useControlled, useForkRef } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport {\n type AriaAttributes,\n type ChangeEvent,\n type ElementType,\n type FocusEvent,\n type FocusEventHandler,\n forwardRef,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type KeyboardEventHandler,\n type MouseEvent,\n type MouseEventHandler,\n type ReactNode,\n useRef,\n useState,\n} from \"react\";\nimport { useFormFieldLegacyProps } from \"../form-field-context-legacy\";\nimport inputLegacyCss from \"./InputLegacy.css\";\nimport { useCursorOnFocus } from \"./useCursorOnFocus\";\n\nconst withBaseName = makePrefixer(\"saltInputLegacy\");\n\n// TODO: Double confirm whether this should be extending DivElement given root is `<div>`.\n// And forwarded ref is not assigned to the root like other components.\nexport interface InputLegacyProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n /**\n * Determines the position of the text cursor on focus of the input.\n *\n * start = place cursor at the beginning<br>\n * end = place cursor at the end<br>\n * \\# = index to place the cursor<br>\n */\n cursorPositionOnFocus?: \"start\" | \"end\" | number;\n /**\n * The value of the `input` element, required for an uncontrolled component.\n */\n defaultValue?: HTMLInputElement[\"defaultValue\"];\n /**\n * If `true`, the component is disabled.\n */\n disabled?: HTMLInputElement[\"disabled\"];\n /**\n * The marker to use in an empty read only Input.\n * Use `''` to disable this feature. Defaults to '—'.\n */\n emptyReadOnlyMarker?: string;\n /**\n * Determines what gets highlighted on focus of the input.\n *\n * If `true` all text will be highlighted.\n * If an array text between those indices will be highlighted\n * e.g. [0,1] will highlight the first character.\n */\n highlightOnFocus?: boolean | number[];\n /**\n * The HTML element to render the Input, e.g. 'input', a custom React component.\n */\n inputComponent?: ElementType;\n /**\n * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.\n */\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Callback for change event.\n */\n onChange?: (event: ChangeEvent<HTMLInputElement>, value: string) => void;\n onFocus?: FocusEventHandler<HTMLInputElement>;\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n onKeyUp?: KeyboardEventHandler<HTMLInputElement>;\n onMouseUp?: MouseEventHandler<HTMLInputElement>;\n onMouseMove?: MouseEventHandler<HTMLInputElement>;\n onMouseDown?: MouseEventHandler<HTMLInputElement>;\n /**\n * If `true`, the component is read only.\n */\n readOnly?: boolean;\n /**\n *\n * Determines the alignment of the input text.\n */\n textAlign?: \"left\" | \"right\" | \"center\";\n type?: HTMLInputElement[\"type\"];\n /**\n * The value of the `input` element, required for a controlled component.\n */\n value?: HTMLInputElement[\"value\"];\n renderSuffix?: (state: {\n disabled?: boolean;\n error?: boolean;\n focused?: boolean;\n margin?: \"dense\" | \"none\" | \"normal\";\n required?: boolean;\n startAdornment?: ReactNode;\n }) => ReactNode;\n endAdornment?: ReactNode;\n startAdornment?: ReactNode;\n}\n\nfunction mergeA11yProps(\n a11yProps: Partial<ReturnType<typeof useFormFieldLegacyProps>[\"a11yProps\"]>,\n inputProps: InputLegacyProps[\"inputProps\"],\n misplacedAriaProps: AriaAttributes,\n) {\n const ariaLabelledBy = clsx(\n a11yProps?.[\"aria-labelledby\"],\n inputProps?.[\"aria-labelledby\"],\n );\n\n return {\n ...misplacedAriaProps,\n ...a11yProps,\n ...inputProps,\n // The weird filtering is due to TokenizedInputBase\n \"aria-labelledby\": ariaLabelledBy\n ? Array.from(new Set(ariaLabelledBy.split(\" \"))).join(\" \")\n : null,\n };\n}\n\nexport const InputLegacy = forwardRef<HTMLInputElement, InputLegacyProps>(\n function Input(\n {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n className: classNameProp,\n cursorPositionOnFocus,\n disabled,\n emptyReadOnlyMarker = \"—\",\n endAdornment,\n highlightOnFocus,\n id,\n inputComponent: InputComponent = \"input\",\n inputProps: inputPropsProp,\n role,\n style,\n value: valueProp,\n // If we leave both value and defaultValue undefined, we will get a React warning on first edit\n // (uncontrolled to controlled warning) from the React input\n defaultValue: defaultValueProp = valueProp === undefined ? \"\" : undefined,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n onKeyUp,\n onMouseUp,\n onMouseMove,\n onMouseDown,\n readOnly: readOnlyProp,\n renderSuffix,\n startAdornment,\n textAlign = \"left\",\n type = \"text\",\n ...other\n },\n ref,\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-input-legacy\",\n css: inputLegacyCss,\n window: targetWindow,\n });\n\n const {\n a11yProps: {\n readOnly: a11yReadOnly,\n disabled: a11yDisabled,\n ...restA11y\n } = {},\n setFocused: setFormFieldFocused,\n inFormField,\n } = useFormFieldLegacyProps();\n\n const [focused, setFocused] = useState(false);\n const inputRef = useRef(null);\n const handleRef = useForkRef(inputRef, ref);\n const cursorOnFocusHelpers = useCursorOnFocus(inputRef, {\n cursorPositionOnFocus,\n highlightOnFocus,\n });\n\n const isDisabled = disabled || a11yDisabled;\n const isReadOnly = readOnlyProp || a11yReadOnly;\n const misplacedAriaProps = {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n role,\n };\n const inputProps = mergeA11yProps(\n restA11y,\n inputPropsProp,\n misplacedAriaProps,\n );\n const isEmptyReadOnly = isReadOnly && !defaultValueProp && !valueProp;\n const defaultValue = isEmptyReadOnly\n ? emptyReadOnlyMarker\n : defaultValueProp;\n\n const [value, setValue] = useControlled({\n controlled: valueProp,\n default: defaultValue,\n name: \"Input\",\n state: \"value\",\n });\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const value = event.target.value;\n setValue(value);\n onChange?.(event, value);\n };\n\n const handleFocus = (event: FocusEvent<HTMLInputElement>) => {\n onFocus?.(event);\n setFormFieldFocused?.(true);\n setFocused(true);\n };\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n onBlur?.(event);\n setFormFieldFocused?.(false);\n setFocused(false);\n };\n\n const handleMouseMove = (event: MouseEvent<HTMLInputElement>) => {\n cursorOnFocusHelpers.handleMouseMove(event);\n\n onMouseMove?.(event);\n };\n\n const handleMouseUp = (event: MouseEvent<HTMLInputElement>) => {\n cursorOnFocusHelpers.handleMouseUp();\n\n onMouseUp?.(event);\n };\n\n const handleMouseDown = (event: MouseEvent<HTMLInputElement>) => {\n cursorOnFocusHelpers.handleMouseDown();\n\n onMouseDown?.(event);\n };\n\n return (\n <div\n className={clsx(\n withBaseName(),\n {\n [withBaseName(`${textAlign}TextAlign`)]: textAlign,\n [withBaseName(\"formField\")]: inFormField,\n [withBaseName(\"focused\")]: focused && !inFormField,\n [withBaseName(\"disabled\")]: isDisabled,\n [withBaseName(\"inputAdornedStart\")]: startAdornment,\n [withBaseName(\"inputAdornedEnd\")]: endAdornment,\n },\n classNameProp,\n )}\n style={style}\n {...other}\n >\n {startAdornment && (\n <div className={withBaseName(\"prefixContainer\")}>\n {startAdornment}\n </div>\n )}\n <InputComponent\n type={type}\n id={id}\n {...inputProps}\n className={clsx(withBaseName(\"input\"), inputProps?.className)}\n disabled={isDisabled}\n ref={handleRef}\n value={value}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onFocus={handleFocus}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseMove={handleMouseMove}\n readOnly={isReadOnly}\n />\n {endAdornment && (\n <div className={withBaseName(\"suffixContainer\")}>{endAdornment}</div>\n )}\n {/* TODO: Confirm implementation of suffix */}\n {renderSuffix?.({ disabled, focused })}\n </div>\n );\n },\n);\n"],"names":["makePrefixer","clsx","forwardRef","useWindow","useComponentCssInjection","inputLegacyCss","useFormFieldLegacyProps","useState","useRef","useForkRef","useCursorOnFocus","useControlled","value","jsxs","jsx"],"mappings":";;;;;;;;;;;;;AAwBA,MAAM,YAAA,GAAeA,kBAAa,iBAAiB,CAAA;AAgFnD,SAAS,cAAA,CACP,SAAA,EACA,UAAA,EACA,kBAAA,EACA;AACA,EAAA,MAAM,cAAA,GAAiBC,SAAA;AAAA,IACrB,SAAA,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAY,iBAAA,CAAA;AAAA,IACZ,UAAA,IAAA,IAAA,GAAA,MAAA,GAAA,UAAA,CAAa,iBAAA;AAAA,GACf;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,kBAAA;AAAA,IACH,GAAG,SAAA;AAAA,IACH,GAAG,UAAA;AAAA;AAAA,IAEH,iBAAA,EAAmB,cAAA,GACf,KAAA,CAAM,IAAA,CAAK,IAAI,GAAA,CAAI,cAAA,CAAe,KAAA,CAAM,GAAG,CAAC,CAAC,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA,GACvD;AAAA,GACN;AACF;AAEO,MAAM,WAAA,GAAcC,gBAAA;AAAA,EACzB,SAAS,KAAA,CACP;AAAA,IACE,uBAAA,EAAyB,oBAAA;AAAA,IACzB,eAAA,EAAiB,YAAA;AAAA,IACjB,WAAA,EAAa,QAAA;AAAA,IACb,SAAA,EAAW,aAAA;AAAA,IAC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A;AAAA,YACrC,CAAC,YAAA,CAAa,iBAAiB,CAAC,GAAG;AAAA,WACrC;AAAA,UACA;AAAA,SACF;AAAA,QACA,KAAA;AAAA,QACC,GAAG,KAAA;AAAA,QAEH,QAAA,EAAA;AAAA,UAAA,cAAA,mCACE,KAAA,EAAA,EAAI,SAAA,EAAW,YAAA,CAAa,iBAAiB,GAC3C,QAAA,EAAA,cAAA,EACH,CAAA;AAAA,0BAEFa,cAAA;AAAA,YAAC,cAAA;AAAA,YAAA;AAAA,cACC,IAAA;AAAA,cACA,EAAA;AAAA,cACC,GAAG,UAAA;AAAA,cACJ,WAAWb,SAAA,CAAK,YAAA,CAAa,OAAO,CAAA,EAAG,yCAAY,SAAS,CAAA;AAAA,cAC5D,QAAA,EAAU,UAAA;AAAA,cACV,GAAA,EAAK,SAAA;AAAA,cACL,KAAA;AAAA,cACA,MAAA,EAAQ,UAAA;AAAA,cACR,QAAA,EAAU,YAAA;AAAA,cACV,SAAA;AAAA,cACA,OAAA;AAAA,cACA,OAAA,EAAS,WAAA;AAAA,cACT,WAAA,EAAa,eAAA;AAAA,cACb,SAAA,EAAW,aAAA;AAAA,cACX,WAAA,EAAa,eAAA;AAAA,cACb,QAAA,EAAU;AAAA;AAAA,WACZ;AAAA,UACC,gCACCa,cAAA,CAAC,KAAA,EAAA,EAAI,WAAW,YAAA,CAAa,iBAAiB,GAAI,QAAA,EAAA,YAAA,EAAa,CAAA;AAAA,UAGhE,YAAA,IAAA,IAAA,GAAA,MAAA,GAAA,YAAA,CAAe,EAAE,QAAA,EAAU,OAAA,EAAQ;AAAA;AAAA;AAAA,KACtC;AAAA,EAEJ;AACF;;;;"}
1
+ {"version":3,"file":"InputLegacy.js","sources":["../src/input-legacy/InputLegacy.tsx"],"sourcesContent":["import { makePrefixer, useControlled, useForkRef } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport {\n type AriaAttributes,\n type ChangeEvent,\n type ElementType,\n type FocusEvent,\n type FocusEventHandler,\n forwardRef,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type KeyboardEventHandler,\n type MouseEvent,\n type MouseEventHandler,\n type ReactNode,\n useRef,\n useState,\n} from \"react\";\nimport { useFormFieldLegacyProps } from \"../form-field-context-legacy\";\nimport inputLegacyCss from \"./InputLegacy.css\";\nimport { useCursorOnFocus } from \"./useCursorOnFocus\";\n\nconst withBaseName = makePrefixer(\"saltInputLegacy\");\n\n// TODO: Double confirm whether this should be extending DivElement given root is `<div>`.\n// And forwarded ref is not assigned to the root like other components.\nexport interface InputLegacyProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n /**\n * Determines the position of the text cursor on focus of the input.\n *\n * start = place cursor at the beginning<br>\n * end = place cursor at the end<br>\n * \\# = index to place the cursor<br>\n */\n cursorPositionOnFocus?: \"start\" | \"end\" | number;\n /**\n * The value of the `input` element, required for an uncontrolled component.\n */\n defaultValue?: HTMLInputElement[\"defaultValue\"];\n /**\n * If `true`, the component is disabled.\n */\n disabled?: HTMLInputElement[\"disabled\"];\n /**\n * The marker to use in an empty read only Input.\n * Use `''` to disable this feature. Defaults to '—'.\n */\n emptyReadOnlyMarker?: string;\n /**\n * Determines what gets highlighted on focus of the input.\n *\n * If `true` all text will be highlighted.\n * If an array text between those indices will be highlighted\n * e.g. [0,1] will highlight the first character.\n */\n highlightOnFocus?: boolean | number[];\n /**\n * The HTML element to render the Input, e.g. 'input', a custom React component.\n */\n inputComponent?: ElementType;\n /**\n * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.\n */\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Callback for change event.\n */\n onChange?: (event: ChangeEvent<HTMLInputElement>, value: string) => void;\n onFocus?: FocusEventHandler<HTMLInputElement>;\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n onKeyUp?: KeyboardEventHandler<HTMLInputElement>;\n onMouseUp?: MouseEventHandler<HTMLInputElement>;\n onMouseMove?: MouseEventHandler<HTMLInputElement>;\n onMouseDown?: MouseEventHandler<HTMLInputElement>;\n /**\n * If `true`, the component is read only.\n */\n readOnly?: boolean;\n /**\n *\n * Determines the alignment of the input text.\n */\n textAlign?: \"left\" | \"right\" | \"center\";\n type?: HTMLInputElement[\"type\"];\n /**\n * The value of the `input` element, required for a controlled component.\n */\n value?: HTMLInputElement[\"value\"];\n renderSuffix?: (state: {\n disabled?: boolean;\n error?: boolean;\n focused?: boolean;\n margin?: \"dense\" | \"none\" | \"normal\";\n required?: boolean;\n startAdornment?: ReactNode;\n }) => ReactNode;\n endAdornment?: ReactNode;\n startAdornment?: ReactNode;\n}\n\nfunction mergeA11yProps(\n a11yProps: Partial<ReturnType<typeof useFormFieldLegacyProps>[\"a11yProps\"]>,\n inputProps: InputLegacyProps[\"inputProps\"],\n misplacedAriaProps: AriaAttributes,\n) {\n const ariaLabelledBy = clsx(\n a11yProps?.[\"aria-labelledby\"],\n inputProps?.[\"aria-labelledby\"],\n );\n\n return {\n ...misplacedAriaProps,\n ...a11yProps,\n ...inputProps,\n // The weird filtering is due to TokenizedInputBase\n \"aria-labelledby\": ariaLabelledBy\n ? Array.from(new Set(ariaLabelledBy.split(\" \"))).join(\" \")\n : null,\n };\n}\n\nfunction isEmptyReadOnlyValue(\n value: InputLegacyProps[\"value\"] | InputLegacyProps[\"defaultValue\"],\n) {\n return value == null || value === \"\";\n}\n\nexport const InputLegacy = forwardRef<HTMLInputElement, InputLegacyProps>(\n function Input(\n {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n className: classNameProp,\n cursorPositionOnFocus,\n disabled,\n emptyReadOnlyMarker = \"—\",\n endAdornment,\n highlightOnFocus,\n id,\n inputComponent: InputComponent = \"input\",\n inputProps: inputPropsProp,\n role,\n style,\n value: valueProp,\n // If we leave both value and defaultValue undefined, we will get a React warning on first edit\n // (uncontrolled to controlled warning) from the React input\n defaultValue: defaultValueProp = valueProp === undefined ? \"\" : undefined,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n onKeyUp,\n onMouseUp,\n onMouseMove,\n onMouseDown,\n readOnly: readOnlyProp,\n renderSuffix,\n startAdornment,\n textAlign = \"left\",\n type = \"text\",\n ...other\n },\n ref,\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-input-legacy\",\n css: inputLegacyCss,\n window: targetWindow,\n });\n\n const {\n a11yProps: {\n readOnly: a11yReadOnly,\n disabled: a11yDisabled,\n ...restA11y\n } = {},\n setFocused: setFormFieldFocused,\n inFormField,\n } = useFormFieldLegacyProps();\n\n const [focused, setFocused] = useState(false);\n const inputRef = useRef(null);\n const handleRef = useForkRef(inputRef, ref);\n const cursorOnFocusHelpers = useCursorOnFocus(inputRef, {\n cursorPositionOnFocus,\n highlightOnFocus,\n });\n\n const isDisabled = disabled || a11yDisabled;\n const isReadOnly = readOnlyProp || a11yReadOnly;\n const misplacedAriaProps = {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n role,\n };\n const inputProps = mergeA11yProps(\n restA11y,\n inputPropsProp,\n misplacedAriaProps,\n );\n const isValueEmptyReadOnly = isReadOnly && isEmptyReadOnlyValue(valueProp);\n const isDefaultValueEmptyReadOnly =\n isReadOnly && isEmptyReadOnlyValue(defaultValueProp);\n const controlledValue =\n valueProp === undefined\n ? undefined\n : isValueEmptyReadOnly\n ? emptyReadOnlyMarker\n : valueProp;\n const defaultValue = isDefaultValueEmptyReadOnly\n ? emptyReadOnlyMarker\n : defaultValueProp;\n\n const [value, setValue] = useControlled({\n controlled: controlledValue,\n default: defaultValue,\n name: \"Input\",\n state: \"value\",\n });\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const value = event.target.value;\n setValue(value);\n onChange?.(event, value);\n };\n\n const handleFocus = (event: FocusEvent<HTMLInputElement>) => {\n onFocus?.(event);\n setFormFieldFocused?.(true);\n setFocused(true);\n };\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n onBlur?.(event);\n setFormFieldFocused?.(false);\n setFocused(false);\n };\n\n const handleMouseMove = (event: MouseEvent<HTMLInputElement>) => {\n cursorOnFocusHelpers.handleMouseMove(event);\n\n onMouseMove?.(event);\n };\n\n const handleMouseUp = (event: MouseEvent<HTMLInputElement>) => {\n cursorOnFocusHelpers.handleMouseUp();\n\n onMouseUp?.(event);\n };\n\n const handleMouseDown = (event: MouseEvent<HTMLInputElement>) => {\n cursorOnFocusHelpers.handleMouseDown();\n\n onMouseDown?.(event);\n };\n\n return (\n <div\n className={clsx(\n withBaseName(),\n {\n [withBaseName(`${textAlign}TextAlign`)]: textAlign,\n [withBaseName(\"formField\")]: inFormField,\n [withBaseName(\"focused\")]: focused && !inFormField,\n [withBaseName(\"disabled\")]: isDisabled,\n [withBaseName(\"inputAdornedStart\")]: startAdornment,\n [withBaseName(\"inputAdornedEnd\")]: endAdornment,\n },\n classNameProp,\n )}\n style={style}\n {...other}\n >\n {startAdornment && (\n <div className={withBaseName(\"prefixContainer\")}>\n {startAdornment}\n </div>\n )}\n <InputComponent\n type={type}\n id={id}\n {...inputProps}\n className={clsx(withBaseName(\"input\"), inputProps?.className)}\n disabled={isDisabled}\n ref={handleRef}\n value={value}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onFocus={handleFocus}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseMove={handleMouseMove}\n readOnly={isReadOnly}\n />\n {endAdornment && (\n <div className={withBaseName(\"suffixContainer\")}>{endAdornment}</div>\n )}\n {/* TODO: Confirm implementation of suffix */}\n {renderSuffix?.({ disabled, focused })}\n </div>\n );\n },\n);\n"],"names":["makePrefixer","clsx","forwardRef","useWindow","useComponentCssInjection","inputLegacyCss","useFormFieldLegacyProps","useState","useRef","useForkRef","useCursorOnFocus","useControlled","value","jsxs","jsx"],"mappings":";;;;;;;;;;;;;AAwBA,MAAM,YAAA,GAAeA,kBAAa,iBAAiB,CAAA;AAgFnD,SAAS,cAAA,CACP,SAAA,EACA,UAAA,EACA,kBAAA,EACA;AACA,EAAA,MAAM,cAAA,GAAiBC,SAAA;AAAA,IACrB,SAAA,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAY,iBAAA,CAAA;AAAA,IACZ,UAAA,IAAA,IAAA,GAAA,MAAA,GAAA,UAAA,CAAa,iBAAA;AAAA,GACf;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,kBAAA;AAAA,IACH,GAAG,SAAA;AAAA,IACH,GAAG,UAAA;AAAA;AAAA,IAEH,iBAAA,EAAmB,cAAA,GACf,KAAA,CAAM,IAAA,CAAK,IAAI,GAAA,CAAI,cAAA,CAAe,KAAA,CAAM,GAAG,CAAC,CAAC,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA,GACvD;AAAA,GACN;AACF;AAEA,SAAS,qBACP,KAAA,EACA;AACA,EAAA,OAAO,KAAA,IAAS,QAAQ,KAAA,KAAU,EAAA;AACpC;AAEO,MAAM,WAAA,GAAcC,gBAAA;AAAA,EACzB,SAAS,KAAA,CACP;AAAA,IACE,uBAAA,EAAyB,oBAAA;AAAA,IACzB,eAAA,EAAiB,YAAA;AAAA,IACjB,WAAA,EAAa,QAAA;AAAA,IACb,SAAA,EAAW,aAAA;AAAA,IACX,qBAAA;AAAA,IACA,QAAA;AAAA,IACA,mBAAA,GAAsB,QAAA;AAAA,IACtB,YAAA;AAAA,IACA,gBAAA;AAAA,IACA,EAAA;AAAA,IACA,gBAAgB,cAAA,GAAiB,OAAA;AAAA,IACjC,UAAA,EAAY,cAAA;AAAA,IACZ,IAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA,EAAO,SAAA;AAAA;AAAA;AAAA,IAGP,YAAA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,KAAA;AAAA,QAEH,QAAA,EAAA;AAAA,UAAA,cAAA,mCACE,KAAA,EAAA,EAAI,SAAA,EAAW,YAAA,CAAa,iBAAiB,GAC3C,QAAA,EAAA,cAAA,EACH,CAAA;AAAA,0BAEFa,cAAA;AAAA,YAAC,cAAA;AAAA,YAAA;AAAA,cACC,IAAA;AAAA,cACA,EAAA;AAAA,cACC,GAAG,UAAA;AAAA,cACJ,WAAWb,SAAA,CAAK,YAAA,CAAa,OAAO,CAAA,EAAG,yCAAY,SAAS,CAAA;AAAA,cAC5D,QAAA,EAAU,UAAA;AAAA,cACV,GAAA,EAAK,SAAA;AAAA,cACL,KAAA;AAAA,cACA,MAAA,EAAQ,UAAA;AAAA,cACR,QAAA,EAAU,YAAA;AAAA,cACV,SAAA;AAAA,cACA,OAAA;AAAA,cACA,OAAA,EAAS,WAAA;AAAA,cACT,WAAA,EAAa,eAAA;AAAA,cACb,SAAA,EAAW,aAAA;AAAA,cACX,WAAA,EAAa,eAAA;AAAA,cACb,QAAA,EAAU;AAAA;AAAA,WACZ;AAAA,UACC,gCACCa,cAAA,CAAC,KAAA,EAAA,EAAI,WAAW,YAAA,CAAa,iBAAiB,GAAI,QAAA,EAAA,YAAA,EAAa,CAAA;AAAA,UAGhE,YAAA,IAAA,IAAA,GAAA,MAAA,GAAA,YAAA,CAAe,EAAE,QAAA,EAAU,OAAA,EAAQ;AAAA;AAAA;AAAA,KACtC;AAAA,EAEJ;AACF;;;;"}
@@ -23,6 +23,9 @@ function mergeA11yProps(a11yProps, inputProps, misplacedAriaProps) {
23
23
  "aria-labelledby": ariaLabelledBy ? Array.from(new Set(ariaLabelledBy.split(" "))).join(" ") : null
24
24
  };
25
25
  }
26
+ function isEmptyReadOnlyValue(value) {
27
+ return value == null || value === "";
28
+ }
26
29
  const InputLegacy = forwardRef(
27
30
  function Input({
28
31
  "aria-activedescendant": ariaActiveDescendant,
@@ -93,10 +96,12 @@ const InputLegacy = forwardRef(
93
96
  inputPropsProp,
94
97
  misplacedAriaProps
95
98
  );
96
- const isEmptyReadOnly = isReadOnly && !defaultValueProp && !valueProp;
97
- const defaultValue = isEmptyReadOnly ? emptyReadOnlyMarker : defaultValueProp;
99
+ const isValueEmptyReadOnly = isReadOnly && isEmptyReadOnlyValue(valueProp);
100
+ const isDefaultValueEmptyReadOnly = isReadOnly && isEmptyReadOnlyValue(defaultValueProp);
101
+ const controlledValue = valueProp === void 0 ? void 0 : isValueEmptyReadOnly ? emptyReadOnlyMarker : valueProp;
102
+ const defaultValue = isDefaultValueEmptyReadOnly ? emptyReadOnlyMarker : defaultValueProp;
98
103
  const [value, setValue] = useControlled({
99
- controlled: valueProp,
104
+ controlled: controlledValue,
100
105
  default: defaultValue,
101
106
  name: "Input",
102
107
  state: "value"
@@ -1 +1 @@
1
- {"version":3,"file":"InputLegacy.js","sources":["../src/input-legacy/InputLegacy.tsx"],"sourcesContent":["import { makePrefixer, useControlled, useForkRef } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport {\n type AriaAttributes,\n type ChangeEvent,\n type ElementType,\n type FocusEvent,\n type FocusEventHandler,\n forwardRef,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type KeyboardEventHandler,\n type MouseEvent,\n type MouseEventHandler,\n type ReactNode,\n useRef,\n useState,\n} from \"react\";\nimport { useFormFieldLegacyProps } from \"../form-field-context-legacy\";\nimport inputLegacyCss from \"./InputLegacy.css\";\nimport { useCursorOnFocus } from \"./useCursorOnFocus\";\n\nconst withBaseName = makePrefixer(\"saltInputLegacy\");\n\n// TODO: Double confirm whether this should be extending DivElement given root is `<div>`.\n// And forwarded ref is not assigned to the root like other components.\nexport interface InputLegacyProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n /**\n * Determines the position of the text cursor on focus of the input.\n *\n * start = place cursor at the beginning<br>\n * end = place cursor at the end<br>\n * \\# = index to place the cursor<br>\n */\n cursorPositionOnFocus?: \"start\" | \"end\" | number;\n /**\n * The value of the `input` element, required for an uncontrolled component.\n */\n defaultValue?: HTMLInputElement[\"defaultValue\"];\n /**\n * If `true`, the component is disabled.\n */\n disabled?: HTMLInputElement[\"disabled\"];\n /**\n * The marker to use in an empty read only Input.\n * Use `''` to disable this feature. Defaults to '—'.\n */\n emptyReadOnlyMarker?: string;\n /**\n * Determines what gets highlighted on focus of the input.\n *\n * If `true` all text will be highlighted.\n * If an array text between those indices will be highlighted\n * e.g. [0,1] will highlight the first character.\n */\n highlightOnFocus?: boolean | number[];\n /**\n * The HTML element to render the Input, e.g. 'input', a custom React component.\n */\n inputComponent?: ElementType;\n /**\n * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.\n */\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Callback for change event.\n */\n onChange?: (event: ChangeEvent<HTMLInputElement>, value: string) => void;\n onFocus?: FocusEventHandler<HTMLInputElement>;\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n onKeyUp?: KeyboardEventHandler<HTMLInputElement>;\n onMouseUp?: MouseEventHandler<HTMLInputElement>;\n onMouseMove?: MouseEventHandler<HTMLInputElement>;\n onMouseDown?: MouseEventHandler<HTMLInputElement>;\n /**\n * If `true`, the component is read only.\n */\n readOnly?: boolean;\n /**\n *\n * Determines the alignment of the input text.\n */\n textAlign?: \"left\" | \"right\" | \"center\";\n type?: HTMLInputElement[\"type\"];\n /**\n * The value of the `input` element, required for a controlled component.\n */\n value?: HTMLInputElement[\"value\"];\n renderSuffix?: (state: {\n disabled?: boolean;\n error?: boolean;\n focused?: boolean;\n margin?: \"dense\" | \"none\" | \"normal\";\n required?: boolean;\n startAdornment?: ReactNode;\n }) => ReactNode;\n endAdornment?: ReactNode;\n startAdornment?: ReactNode;\n}\n\nfunction mergeA11yProps(\n a11yProps: Partial<ReturnType<typeof useFormFieldLegacyProps>[\"a11yProps\"]>,\n inputProps: InputLegacyProps[\"inputProps\"],\n misplacedAriaProps: AriaAttributes,\n) {\n const ariaLabelledBy = clsx(\n a11yProps?.[\"aria-labelledby\"],\n inputProps?.[\"aria-labelledby\"],\n );\n\n return {\n ...misplacedAriaProps,\n ...a11yProps,\n ...inputProps,\n // The weird filtering is due to TokenizedInputBase\n \"aria-labelledby\": ariaLabelledBy\n ? Array.from(new Set(ariaLabelledBy.split(\" \"))).join(\" \")\n : null,\n };\n}\n\nexport const InputLegacy = forwardRef<HTMLInputElement, InputLegacyProps>(\n function Input(\n {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n className: classNameProp,\n cursorPositionOnFocus,\n disabled,\n emptyReadOnlyMarker = \"—\",\n endAdornment,\n highlightOnFocus,\n id,\n inputComponent: InputComponent = \"input\",\n inputProps: inputPropsProp,\n role,\n style,\n value: valueProp,\n // If we leave both value and defaultValue undefined, we will get a React warning on first edit\n // (uncontrolled to controlled warning) from the React input\n defaultValue: defaultValueProp = valueProp === undefined ? \"\" : undefined,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n onKeyUp,\n onMouseUp,\n onMouseMove,\n onMouseDown,\n readOnly: readOnlyProp,\n renderSuffix,\n startAdornment,\n textAlign = \"left\",\n type = \"text\",\n ...other\n },\n ref,\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-input-legacy\",\n css: inputLegacyCss,\n window: targetWindow,\n });\n\n const {\n a11yProps: {\n readOnly: a11yReadOnly,\n disabled: a11yDisabled,\n ...restA11y\n } = {},\n setFocused: setFormFieldFocused,\n inFormField,\n } = useFormFieldLegacyProps();\n\n const [focused, setFocused] = useState(false);\n const inputRef = useRef(null);\n const handleRef = useForkRef(inputRef, ref);\n const cursorOnFocusHelpers = useCursorOnFocus(inputRef, {\n cursorPositionOnFocus,\n highlightOnFocus,\n });\n\n const isDisabled = disabled || a11yDisabled;\n const isReadOnly = readOnlyProp || a11yReadOnly;\n const misplacedAriaProps = {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n role,\n };\n const inputProps = mergeA11yProps(\n restA11y,\n inputPropsProp,\n misplacedAriaProps,\n );\n const isEmptyReadOnly = isReadOnly && !defaultValueProp && !valueProp;\n const defaultValue = isEmptyReadOnly\n ? emptyReadOnlyMarker\n : defaultValueProp;\n\n const [value, setValue] = useControlled({\n controlled: valueProp,\n default: defaultValue,\n name: \"Input\",\n state: \"value\",\n });\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const value = event.target.value;\n setValue(value);\n onChange?.(event, value);\n };\n\n const handleFocus = (event: FocusEvent<HTMLInputElement>) => {\n onFocus?.(event);\n setFormFieldFocused?.(true);\n setFocused(true);\n };\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n onBlur?.(event);\n setFormFieldFocused?.(false);\n setFocused(false);\n };\n\n const handleMouseMove = (event: MouseEvent<HTMLInputElement>) => {\n cursorOnFocusHelpers.handleMouseMove(event);\n\n onMouseMove?.(event);\n };\n\n const handleMouseUp = (event: MouseEvent<HTMLInputElement>) => {\n cursorOnFocusHelpers.handleMouseUp();\n\n onMouseUp?.(event);\n };\n\n const handleMouseDown = (event: MouseEvent<HTMLInputElement>) => {\n cursorOnFocusHelpers.handleMouseDown();\n\n onMouseDown?.(event);\n };\n\n return (\n <div\n className={clsx(\n withBaseName(),\n {\n [withBaseName(`${textAlign}TextAlign`)]: textAlign,\n [withBaseName(\"formField\")]: inFormField,\n [withBaseName(\"focused\")]: focused && !inFormField,\n [withBaseName(\"disabled\")]: isDisabled,\n [withBaseName(\"inputAdornedStart\")]: startAdornment,\n [withBaseName(\"inputAdornedEnd\")]: endAdornment,\n },\n classNameProp,\n )}\n style={style}\n {...other}\n >\n {startAdornment && (\n <div className={withBaseName(\"prefixContainer\")}>\n {startAdornment}\n </div>\n )}\n <InputComponent\n type={type}\n id={id}\n {...inputProps}\n className={clsx(withBaseName(\"input\"), inputProps?.className)}\n disabled={isDisabled}\n ref={handleRef}\n value={value}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onFocus={handleFocus}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseMove={handleMouseMove}\n readOnly={isReadOnly}\n />\n {endAdornment && (\n <div className={withBaseName(\"suffixContainer\")}>{endAdornment}</div>\n )}\n {/* TODO: Confirm implementation of suffix */}\n {renderSuffix?.({ disabled, focused })}\n </div>\n );\n },\n);\n"],"names":["inputLegacyCss","value"],"mappings":";;;;;;;;;;;AAwBA,MAAM,YAAA,GAAe,aAAa,iBAAiB,CAAA;AAgFnD,SAAS,cAAA,CACP,SAAA,EACA,UAAA,EACA,kBAAA,EACA;AACA,EAAA,MAAM,cAAA,GAAiB,IAAA;AAAA,IACrB,SAAA,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAY,iBAAA,CAAA;AAAA,IACZ,UAAA,IAAA,IAAA,GAAA,MAAA,GAAA,UAAA,CAAa,iBAAA;AAAA,GACf;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,kBAAA;AAAA,IACH,GAAG,SAAA;AAAA,IACH,GAAG,UAAA;AAAA;AAAA,IAEH,iBAAA,EAAmB,cAAA,GACf,KAAA,CAAM,IAAA,CAAK,IAAI,GAAA,CAAI,cAAA,CAAe,KAAA,CAAM,GAAG,CAAC,CAAC,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA,GACvD;AAAA,GACN;AACF;AAEO,MAAM,WAAA,GAAc,UAAA;AAAA,EACzB,SAAS,KAAA,CACP;AAAA,IACE,uBAAA,EAAyB,oBAAA;AAAA,IACzB,eAAA,EAAiB,YAAA;AAAA,IACjB,WAAA,EAAa,QAAA;AAAA,IACb,SAAA,EAAW,aAAA;AAAA,IACX,qBAAA;AAAA,IACA,QAAA;A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AC,GAAG;AAAA,WACrC;AAAA,UACA;AAAA,SACF;AAAA,QACA,KAAA;AAAA,QACC,GAAG,KAAA;AAAA,QAEH,QAAA,EAAA;AAAA,UAAA,cAAA,wBACE,KAAA,EAAA,EAAI,SAAA,EAAW,YAAA,CAAa,iBAAiB,GAC3C,QAAA,EAAA,cAAA,EACH,CAAA;AAAA,0BAEF,GAAA;AAAA,YAAC,cAAA;AAAA,YAAA;AAAA,cACC,IAAA;AAAA,cACA,EAAA;AAAA,cACC,GAAG,UAAA;AAAA,cACJ,WAAW,IAAA,CAAK,YAAA,CAAa,OAAO,CAAA,EAAG,yCAAY,SAAS,CAAA;AAAA,cAC5D,QAAA,EAAU,UAAA;AAAA,cACV,GAAA,EAAK,SAAA;AAAA,cACL,KAAA;AAAA,cACA,MAAA,EAAQ,UAAA;AAAA,cACR,QAAA,EAAU,YAAA;AAAA,cACV,SAAA;AAAA,cACA,OAAA;AAAA,cACA,OAAA,EAAS,WAAA;AAAA,cACT,WAAA,EAAa,eAAA;AAAA,cACb,SAAA,EAAW,aAAA;AAAA,cACX,WAAA,EAAa,eAAA;AAAA,cACb,QAAA,EAAU;AAAA;AAAA,WACZ;AAAA,UACC,gCACC,GAAA,CAAC,KAAA,EAAA,EAAI,WAAW,YAAA,CAAa,iBAAiB,GAAI,QAAA,EAAA,YAAA,EAAa,CAAA;AAAA,UAGhE,YAAA,IAAA,IAAA,GAAA,MAAA,GAAA,YAAA,CAAe,EAAE,QAAA,EAAU,OAAA,EAAQ;AAAA;AAAA;AAAA,KACtC;AAAA,EAEJ;AACF;;;;"}
1
+ {"version":3,"file":"InputLegacy.js","sources":["../src/input-legacy/InputLegacy.tsx"],"sourcesContent":["import { makePrefixer, useControlled, useForkRef } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport {\n type AriaAttributes,\n type ChangeEvent,\n type ElementType,\n type FocusEvent,\n type FocusEventHandler,\n forwardRef,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type KeyboardEventHandler,\n type MouseEvent,\n type MouseEventHandler,\n type ReactNode,\n useRef,\n useState,\n} from \"react\";\nimport { useFormFieldLegacyProps } from \"../form-field-context-legacy\";\nimport inputLegacyCss from \"./InputLegacy.css\";\nimport { useCursorOnFocus } from \"./useCursorOnFocus\";\n\nconst withBaseName = makePrefixer(\"saltInputLegacy\");\n\n// TODO: Double confirm whether this should be extending DivElement given root is `<div>`.\n// And forwarded ref is not assigned to the root like other components.\nexport interface InputLegacyProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n /**\n * Determines the position of the text cursor on focus of the input.\n *\n * start = place cursor at the beginning<br>\n * end = place cursor at the end<br>\n * \\# = index to place the cursor<br>\n */\n cursorPositionOnFocus?: \"start\" | \"end\" | number;\n /**\n * The value of the `input` element, required for an uncontrolled component.\n */\n defaultValue?: HTMLInputElement[\"defaultValue\"];\n /**\n * If `true`, the component is disabled.\n */\n disabled?: HTMLInputElement[\"disabled\"];\n /**\n * The marker to use in an empty read only Input.\n * Use `''` to disable this feature. Defaults to '—'.\n */\n emptyReadOnlyMarker?: string;\n /**\n * Determines what gets highlighted on focus of the input.\n *\n * If `true` all text will be highlighted.\n * If an array text between those indices will be highlighted\n * e.g. [0,1] will highlight the first character.\n */\n highlightOnFocus?: boolean | number[];\n /**\n * The HTML element to render the Input, e.g. 'input', a custom React component.\n */\n inputComponent?: ElementType;\n /**\n * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.\n */\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Callback for change event.\n */\n onChange?: (event: ChangeEvent<HTMLInputElement>, value: string) => void;\n onFocus?: FocusEventHandler<HTMLInputElement>;\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n onKeyUp?: KeyboardEventHandler<HTMLInputElement>;\n onMouseUp?: MouseEventHandler<HTMLInputElement>;\n onMouseMove?: MouseEventHandler<HTMLInputElement>;\n onMouseDown?: MouseEventHandler<HTMLInputElement>;\n /**\n * If `true`, the component is read only.\n */\n readOnly?: boolean;\n /**\n *\n * Determines the alignment of the input text.\n */\n textAlign?: \"left\" | \"right\" | \"center\";\n type?: HTMLInputElement[\"type\"];\n /**\n * The value of the `input` element, required for a controlled component.\n */\n value?: HTMLInputElement[\"value\"];\n renderSuffix?: (state: {\n disabled?: boolean;\n error?: boolean;\n focused?: boolean;\n margin?: \"dense\" | \"none\" | \"normal\";\n required?: boolean;\n startAdornment?: ReactNode;\n }) => ReactNode;\n endAdornment?: ReactNode;\n startAdornment?: ReactNode;\n}\n\nfunction mergeA11yProps(\n a11yProps: Partial<ReturnType<typeof useFormFieldLegacyProps>[\"a11yProps\"]>,\n inputProps: InputLegacyProps[\"inputProps\"],\n misplacedAriaProps: AriaAttributes,\n) {\n const ariaLabelledBy = clsx(\n a11yProps?.[\"aria-labelledby\"],\n inputProps?.[\"aria-labelledby\"],\n );\n\n return {\n ...misplacedAriaProps,\n ...a11yProps,\n ...inputProps,\n // The weird filtering is due to TokenizedInputBase\n \"aria-labelledby\": ariaLabelledBy\n ? Array.from(new Set(ariaLabelledBy.split(\" \"))).join(\" \")\n : null,\n };\n}\n\nfunction isEmptyReadOnlyValue(\n value: InputLegacyProps[\"value\"] | InputLegacyProps[\"defaultValue\"],\n) {\n return value == null || value === \"\";\n}\n\nexport const InputLegacy = forwardRef<HTMLInputElement, InputLegacyProps>(\n function Input(\n {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n className: classNameProp,\n cursorPositionOnFocus,\n disabled,\n emptyReadOnlyMarker = \"—\",\n endAdornment,\n highlightOnFocus,\n id,\n inputComponent: InputComponent = \"input\",\n inputProps: inputPropsProp,\n role,\n style,\n value: valueProp,\n // If we leave both value and defaultValue undefined, we will get a React warning on first edit\n // (uncontrolled to controlled warning) from the React input\n defaultValue: defaultValueProp = valueProp === undefined ? \"\" : undefined,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n onKeyUp,\n onMouseUp,\n onMouseMove,\n onMouseDown,\n readOnly: readOnlyProp,\n renderSuffix,\n startAdornment,\n textAlign = \"left\",\n type = \"text\",\n ...other\n },\n ref,\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-input-legacy\",\n css: inputLegacyCss,\n window: targetWindow,\n });\n\n const {\n a11yProps: {\n readOnly: a11yReadOnly,\n disabled: a11yDisabled,\n ...restA11y\n } = {},\n setFocused: setFormFieldFocused,\n inFormField,\n } = useFormFieldLegacyProps();\n\n const [focused, setFocused] = useState(false);\n const inputRef = useRef(null);\n const handleRef = useForkRef(inputRef, ref);\n const cursorOnFocusHelpers = useCursorOnFocus(inputRef, {\n cursorPositionOnFocus,\n highlightOnFocus,\n });\n\n const isDisabled = disabled || a11yDisabled;\n const isReadOnly = readOnlyProp || a11yReadOnly;\n const misplacedAriaProps = {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n role,\n };\n const inputProps = mergeA11yProps(\n restA11y,\n inputPropsProp,\n misplacedAriaProps,\n );\n const isValueEmptyReadOnly = isReadOnly && isEmptyReadOnlyValue(valueProp);\n const isDefaultValueEmptyReadOnly =\n isReadOnly && isEmptyReadOnlyValue(defaultValueProp);\n const controlledValue =\n valueProp === undefined\n ? undefined\n : isValueEmptyReadOnly\n ? emptyReadOnlyMarker\n : valueProp;\n const defaultValue = isDefaultValueEmptyReadOnly\n ? emptyReadOnlyMarker\n : defaultValueProp;\n\n const [value, setValue] = useControlled({\n controlled: controlledValue,\n default: defaultValue,\n name: \"Input\",\n state: \"value\",\n });\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const value = event.target.value;\n setValue(value);\n onChange?.(event, value);\n };\n\n const handleFocus = (event: FocusEvent<HTMLInputElement>) => {\n onFocus?.(event);\n setFormFieldFocused?.(true);\n setFocused(true);\n };\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n onBlur?.(event);\n setFormFieldFocused?.(false);\n setFocused(false);\n };\n\n const handleMouseMove = (event: MouseEvent<HTMLInputElement>) => {\n cursorOnFocusHelpers.handleMouseMove(event);\n\n onMouseMove?.(event);\n };\n\n const handleMouseUp = (event: MouseEvent<HTMLInputElement>) => {\n cursorOnFocusHelpers.handleMouseUp();\n\n onMouseUp?.(event);\n };\n\n const handleMouseDown = (event: MouseEvent<HTMLInputElement>) => {\n cursorOnFocusHelpers.handleMouseDown();\n\n onMouseDown?.(event);\n };\n\n return (\n <div\n className={clsx(\n withBaseName(),\n {\n [withBaseName(`${textAlign}TextAlign`)]: textAlign,\n [withBaseName(\"formField\")]: inFormField,\n [withBaseName(\"focused\")]: focused && !inFormField,\n [withBaseName(\"disabled\")]: isDisabled,\n [withBaseName(\"inputAdornedStart\")]: startAdornment,\n [withBaseName(\"inputAdornedEnd\")]: endAdornment,\n },\n classNameProp,\n )}\n style={style}\n {...other}\n >\n {startAdornment && (\n <div className={withBaseName(\"prefixContainer\")}>\n {startAdornment}\n </div>\n )}\n <InputComponent\n type={type}\n id={id}\n {...inputProps}\n className={clsx(withBaseName(\"input\"), inputProps?.className)}\n disabled={isDisabled}\n ref={handleRef}\n value={value}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onFocus={handleFocus}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseMove={handleMouseMove}\n readOnly={isReadOnly}\n />\n {endAdornment && (\n <div className={withBaseName(\"suffixContainer\")}>{endAdornment}</div>\n )}\n {/* TODO: Confirm implementation of suffix */}\n {renderSuffix?.({ disabled, focused })}\n </div>\n );\n },\n);\n"],"names":["inputLegacyCss","value"],"mappings":";;;;;;;;;;;AAwBA,MAAM,YAAA,GAAe,aAAa,iBAAiB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AC,cAAA;AAAA,YAAA;AAAA,cACC,IAAA;AAAA,cACA,EAAA;AAAA,cACC,GAAG,UAAA;AAAA,cACJ,WAAW,IAAA,CAAK,YAAA,CAAa,OAAO,CAAA,EAAG,yCAAY,SAAS,CAAA;AAAA,cAC5D,QAAA,EAAU,UAAA;AAAA,cACV,GAAA,EAAK,SAAA;AAAA,cACL,KAAA;AAAA,cACA,MAAA,EAAQ,UAAA;AAAA,cACR,QAAA,EAAU,YAAA;AAAA,cACV,SAAA;AAAA,cACA,OAAA;AAAA,cACA,OAAA,EAAS,WAAA;AAAA,cACT,WAAA,EAAa,eAAA;AAAA,cACb,SAAA,EAAW,aAAA;AAAA,cACX,WAAA,EAAa,eAAA;AAAA,cACb,QAAA,EAAU;AAAA;AAAA,WACZ;AAAA,UACC,gCACC,GAAA,CAAC,KAAA,EAAA,EAAI,WAAW,YAAA,CAAa,iBAAiB,GAAI,QAAA,EAAA,YAAA,EAAa,CAAA;AAAA,UAGhE,YAAA,IAAA,IAAA,GAAA,MAAA,GAAA,YAAA,CAAe,EAAE,QAAA,EAAU,OAAA,EAAQ;AAAA;AAAA;AAAA,KACtC;AAAA,EAEJ;AACF;;;;"}
@@ -50,6 +50,7 @@ export declare const useComboBox: <Item>(props: UseComboBoxProps<Item>) => {
50
50
  virtualized?: boolean | undefined;
51
51
  width?: number | string | undefined;
52
52
  children?: import("react").ReactNode;
53
+ nonce?: string | undefined | undefined;
53
54
  slot?: string | undefined | undefined;
54
55
  style?: import("react").CSSProperties | undefined;
55
56
  title?: string | undefined | undefined;
@@ -282,7 +283,6 @@ export declare const useComboBox: <Item>(props: UseComboBoxProps<Item>) => {
282
283
  draggable?: (boolean | "true" | "false") | undefined;
283
284
  enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
284
285
  hidden?: boolean | undefined | undefined;
285
- nonce?: string | undefined | undefined;
286
286
  spellCheck?: (boolean | "true" | "false") | undefined;
287
287
  translate?: "yes" | "no" | undefined | undefined;
288
288
  radioGroup?: string | undefined | undefined;
@@ -320,6 +320,7 @@ export declare const useMultiSelectComboBox: <Item>(props: Omit<UseMultiSelectCo
320
320
  };
321
321
  onKeyDown: (event: KeyboardEvent<HTMLInputElement | HTMLButtonElement | HTMLDivElement>) => void;
322
322
  children?: import("react").ReactNode;
323
+ nonce?: string | undefined | undefined;
323
324
  slot?: string | undefined | undefined;
324
325
  style?: import("react").CSSProperties | undefined;
325
326
  title?: string | undefined | undefined;
@@ -554,7 +555,6 @@ export declare const useMultiSelectComboBox: <Item>(props: Omit<UseMultiSelectCo
554
555
  draggable?: (boolean | "true" | "false") | undefined;
555
556
  enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
556
557
  hidden?: boolean | undefined | undefined;
557
- nonce?: string | undefined | undefined;
558
558
  spellCheck?: (boolean | "true" | "false") | undefined;
559
559
  translate?: "yes" | "no" | undefined | undefined;
560
560
  radioGroup?: string | undefined | undefined;
@@ -636,6 +636,7 @@ export declare const useMultiSelectComboBox: <Item>(props: Omit<UseMultiSelectCo
636
636
  virtualized?: boolean | undefined;
637
637
  width?: number | string | undefined;
638
638
  children?: import("react").ReactNode;
639
+ nonce?: string | undefined | undefined;
639
640
  slot?: string | undefined | undefined;
640
641
  style?: import("react").CSSProperties | undefined;
641
642
  title?: string | undefined | undefined;
@@ -868,7 +869,6 @@ export declare const useMultiSelectComboBox: <Item>(props: Omit<UseMultiSelectCo
868
869
  draggable?: (boolean | "true" | "false") | undefined;
869
870
  enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
870
871
  hidden?: boolean | undefined | undefined;
871
- nonce?: string | undefined | undefined;
872
872
  spellCheck?: (boolean | "true" | "false") | undefined;
873
873
  translate?: "yes" | "no" | undefined | undefined;
874
874
  radioGroup?: string | undefined | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salt-ds/lab",
3
- "version": "1.0.0-alpha.100",
3
+ "version": "1.0.0-alpha.101",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,9 +21,9 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@floating-ui/react": "^0.27.19",
24
- "@salt-ds/core": "^1.67.1",
25
- "@salt-ds/icons": "^1.18.1",
26
- "@salt-ds/styles": "0.3.0",
24
+ "@salt-ds/core": "^1.68.0",
25
+ "@salt-ds/icons": "^1.18.2",
26
+ "@salt-ds/styles": "0.4.0",
27
27
  "@salt-ds/window": "0.1.1",
28
28
  "@types/react-window": "^1.8.2",
29
29
  "clipboard-copy": "^4.0.1",