@salt-ds/lab 1.0.0-alpha.19 → 1.0.0-alpha.20

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.
Files changed (50) hide show
  1. package/dist-cjs/combo-box-next/ComboBoxNext.js +6 -6
  2. package/dist-cjs/combo-box-next/ComboBoxNext.js.map +1 -1
  3. package/dist-cjs/combo-box-next/useComboBox.js +11 -11
  4. package/dist-cjs/combo-box-next/useComboBox.js.map +1 -1
  5. package/dist-cjs/combo-box-next/useComboboxPortal.js +1 -1
  6. package/dist-cjs/combo-box-next/useComboboxPortal.js.map +1 -1
  7. package/dist-cjs/combo-box-next/utils.js +5 -9
  8. package/dist-cjs/combo-box-next/utils.js.map +1 -1
  9. package/dist-cjs/dropdown-next/DropdownNext.js +20 -14
  10. package/dist-cjs/dropdown-next/DropdownNext.js.map +1 -1
  11. package/dist-cjs/dropdown-next/useDropdownNext.js +29 -16
  12. package/dist-cjs/dropdown-next/useDropdownNext.js.map +1 -1
  13. package/dist-cjs/index.js +0 -2
  14. package/dist-cjs/index.js.map +1 -1
  15. package/dist-cjs/pill-next/PillNext.css.js +1 -1
  16. package/dist-cjs/pill-next/PillNext.js +32 -20
  17. package/dist-cjs/pill-next/PillNext.js.map +1 -1
  18. package/dist-es/combo-box-next/ComboBoxNext.js +6 -6
  19. package/dist-es/combo-box-next/ComboBoxNext.js.map +1 -1
  20. package/dist-es/combo-box-next/useComboBox.js +11 -11
  21. package/dist-es/combo-box-next/useComboBox.js.map +1 -1
  22. package/dist-es/combo-box-next/useComboboxPortal.js +1 -1
  23. package/dist-es/combo-box-next/useComboboxPortal.js.map +1 -1
  24. package/dist-es/combo-box-next/utils.js +5 -9
  25. package/dist-es/combo-box-next/utils.js.map +1 -1
  26. package/dist-es/dropdown-next/DropdownNext.js +20 -14
  27. package/dist-es/dropdown-next/DropdownNext.js.map +1 -1
  28. package/dist-es/dropdown-next/useDropdownNext.js +29 -16
  29. package/dist-es/dropdown-next/useDropdownNext.js.map +1 -1
  30. package/dist-es/index.js +0 -1
  31. package/dist-es/index.js.map +1 -1
  32. package/dist-es/pill-next/PillNext.css.js +1 -1
  33. package/dist-es/pill-next/PillNext.js +33 -21
  34. package/dist-es/pill-next/PillNext.js.map +1 -1
  35. package/dist-types/combo-box-next/useComboBox.d.ts +3 -2
  36. package/dist-types/combo-box-next/utils.d.ts +1 -1
  37. package/dist-types/dropdown-next/useDropdownNext.d.ts +7 -3
  38. package/dist-types/index.d.ts +0 -1
  39. package/dist-types/pill-next/PillNext.d.ts +2 -2
  40. package/package.json +2 -2
  41. package/dist-cjs/switch/Switch.css.js +0 -6
  42. package/dist-cjs/switch/Switch.css.js.map +0 -1
  43. package/dist-cjs/switch/Switch.js +0 -117
  44. package/dist-cjs/switch/Switch.js.map +0 -1
  45. package/dist-es/switch/Switch.css.js +0 -4
  46. package/dist-es/switch/Switch.css.js.map +0 -1
  47. package/dist-es/switch/Switch.js +0 -113
  48. package/dist-es/switch/Switch.js.map +0 -1
  49. package/dist-types/switch/Switch.d.ts +0 -45
  50. package/dist-types/switch/index.d.ts +0 -1
@@ -1,113 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { clsx } from 'clsx';
3
- import { forwardRef } from 'react';
4
- import { makePrefixer, useControlled, useFormFieldProps, useDensity } from '@salt-ds/core';
5
- import { useWindow } from '@salt-ds/window';
6
- import { useComponentCssInjection } from '@salt-ds/styles';
7
- import css_248z from './Switch.css.js';
8
- import { SuccessSmallSolidIcon, SuccessSolidIcon } from '@salt-ds/icons';
9
-
10
- const withBaseName = makePrefixer("saltSwitch");
11
- function CheckedIcon(props) {
12
- const density = useDensity();
13
- return density === "high" ? /* @__PURE__ */ jsx(SuccessSmallSolidIcon, {
14
- ...props
15
- }) : /* @__PURE__ */ jsx(SuccessSolidIcon, {
16
- ...props
17
- });
18
- }
19
- const Switch = forwardRef(function Switch2(props, ref) {
20
- const {
21
- checked: checkedProp,
22
- className,
23
- color,
24
- defaultChecked,
25
- disabled: disabledProp,
26
- inputProps = {},
27
- label,
28
- name,
29
- onBlur,
30
- onChange,
31
- onFocus,
32
- value,
33
- ...rest
34
- } = props;
35
- const targetWindow = useWindow();
36
- useComponentCssInjection({
37
- testId: "salt-switch",
38
- css: css_248z,
39
- window: targetWindow
40
- });
41
- const {
42
- "aria-describedby": inputDescribedBy,
43
- "aria-labelledby": inputLabelledBy,
44
- className: inputClassName,
45
- onChange: inputOnChange,
46
- ...restInputProps
47
- } = inputProps;
48
- const [checked, setChecked] = useControlled({
49
- controlled: checkedProp,
50
- default: Boolean(defaultChecked),
51
- name: "Switch",
52
- state: "checked"
53
- });
54
- const { a11yProps: formFieldA11yProps, disabled: formFieldDisabled } = useFormFieldProps();
55
- const disabled = formFieldDisabled != null ? formFieldDisabled : disabledProp;
56
- const handleChange = (event) => {
57
- if (event.nativeEvent.defaultPrevented) {
58
- return;
59
- }
60
- const value2 = event.target.checked;
61
- setChecked(value2);
62
- onChange == null ? void 0 : onChange(event);
63
- inputOnChange == null ? void 0 : inputOnChange(event);
64
- };
65
- return /* @__PURE__ */ jsxs("label", {
66
- className: clsx(
67
- withBaseName(),
68
- {
69
- [withBaseName("disabled")]: disabled,
70
- [withBaseName("checked")]: checked
71
- },
72
- className
73
- ),
74
- ref,
75
- ...rest,
76
- children: [
77
- /* @__PURE__ */ jsx("input", {
78
- "aria-describedby": clsx(
79
- formFieldA11yProps == null ? void 0 : formFieldA11yProps["aria-describedby"],
80
- inputDescribedBy
81
- ),
82
- "aria-labelledby": clsx(
83
- formFieldA11yProps == null ? void 0 : formFieldA11yProps["aria-labelledby"],
84
- inputLabelledBy
85
- ),
86
- name,
87
- value,
88
- checked,
89
- className: clsx(withBaseName("input"), inputClassName),
90
- defaultChecked,
91
- disabled,
92
- onBlur,
93
- onChange: handleChange,
94
- onFocus,
95
- type: "checkbox",
96
- ...restInputProps
97
- }),
98
- /* @__PURE__ */ jsx("span", {
99
- className: withBaseName("track"),
100
- children: /* @__PURE__ */ jsx("span", {
101
- className: withBaseName("thumb"),
102
- children: checked && /* @__PURE__ */ jsx(CheckedIcon, {
103
- className: withBaseName("icon")
104
- })
105
- })
106
- }),
107
- label
108
- ]
109
- });
110
- });
111
-
112
- export { Switch };
113
- //# sourceMappingURL=Switch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Switch.js","sources":["../src/switch/Switch.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n ChangeEventHandler,\n ComponentPropsWithoutRef,\n FocusEventHandler,\n forwardRef,\n ReactNode,\n} from \"react\";\nimport {\n makePrefixer,\n useControlled,\n useDensity,\n useFormFieldProps,\n} from \"@salt-ds/core\";\n\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nimport switchCss from \"./Switch.css\";\nimport {\n IconProps,\n SuccessSmallSolidIcon,\n SuccessSolidIcon,\n} from \"@salt-ds/icons\";\n\nexport interface SwitchProps\n extends Omit<\n ComponentPropsWithoutRef<\"label\">,\n \"children\" | \"onFocus\" | \"onBlur\" | \"onChange\"\n > {\n /**\n * If `true`, the checkbox will be checked.\n */\n checked?: boolean;\n /**\n * Whether the checkbox component is checked by default\n * This will be disregarded if checked is already set.\n */\n defaultChecked?: boolean;\n /**\n * If `true`, the checkbox will be disabled.\n */\n disabled?: boolean;\n /**\n * Properties applied to the input element.\n */\n inputProps?: Partial<ComponentPropsWithoutRef<\"input\">>;\n /**\n * The label to be shown next to the checkbox.\n */\n label?: ReactNode;\n /**\n * The name applied to the input.\n */\n name?: string;\n /**\n * Callback when checkbox loses focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Callback when checked state is changed.\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Callback when checkbox gains focus.\n */\n onFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * The value of the checkbox.\n */\n value?: string;\n}\n\nconst withBaseName = makePrefixer(\"saltSwitch\");\n\nfunction CheckedIcon(props: IconProps) {\n const density = useDensity();\n return density === \"high\" ? (\n <SuccessSmallSolidIcon {...props} />\n ) : (\n <SuccessSolidIcon {...props} />\n );\n}\n\nexport const Switch = forwardRef<HTMLLabelElement, SwitchProps>(function Switch(\n props,\n ref\n) {\n const {\n checked: checkedProp,\n className,\n color,\n defaultChecked,\n disabled: disabledProp,\n inputProps = {},\n label,\n name,\n onBlur,\n onChange,\n onFocus,\n value,\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-switch\",\n css: switchCss,\n window: targetWindow,\n });\n\n const {\n \"aria-describedby\": inputDescribedBy,\n \"aria-labelledby\": inputLabelledBy,\n className: inputClassName,\n onChange: inputOnChange,\n ...restInputProps\n } = inputProps;\n\n const [checked, setChecked] = useControlled({\n controlled: checkedProp,\n default: Boolean(defaultChecked),\n name: \"Switch\",\n state: \"checked\",\n });\n\n const { a11yProps: formFieldA11yProps, disabled: formFieldDisabled } =\n useFormFieldProps();\n\n const disabled = formFieldDisabled ?? disabledProp;\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n // Workaround for https://github.com/facebook/react/issues/9023\n if (event.nativeEvent.defaultPrevented) {\n return;\n }\n\n const value = event.target.checked;\n setChecked(value);\n onChange?.(event);\n inputOnChange?.(event);\n };\n\n return (\n <label\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"disabled\")]: disabled,\n [withBaseName(\"checked\")]: checked,\n },\n className\n )}\n ref={ref}\n {...rest}\n >\n <input\n aria-describedby={clsx(\n formFieldA11yProps?.[\"aria-describedby\"],\n inputDescribedBy\n )}\n aria-labelledby={clsx(\n formFieldA11yProps?.[\"aria-labelledby\"],\n inputLabelledBy\n )}\n name={name}\n value={value}\n checked={checked}\n className={clsx(withBaseName(\"input\"), inputClassName)}\n defaultChecked={defaultChecked}\n disabled={disabled}\n onBlur={onBlur}\n onChange={handleChange}\n onFocus={onFocus}\n type=\"checkbox\"\n {...restInputProps}\n />\n <span className={withBaseName(\"track\")}>\n <span className={withBaseName(\"thumb\")}>\n {checked && <CheckedIcon className={withBaseName(\"icon\")} />}\n </span>\n </span>\n {label}\n </label>\n );\n});\n"],"names":["Switch","switchCss","value"],"mappings":";;;;;;;;;AAyEA,MAAM,YAAA,GAAe,aAAa,YAAY,CAAA,CAAA;AAE9C,SAAS,YAAY,KAAkB,EAAA;AACrC,EAAA,MAAM,UAAU,UAAW,EAAA,CAAA;AAC3B,EAAO,OAAA,OAAA,KAAY,yBAChB,GAAA,CAAA,qBAAA,EAAA;AAAA,IAAuB,GAAG,KAAA;AAAA,GAAO,oBAEjC,GAAA,CAAA,gBAAA,EAAA;AAAA,IAAkB,GAAG,KAAA;AAAA,GAAO,CAAA,CAAA;AAEjC,CAAA;AAEO,MAAM,MAAS,GAAA,UAAA,CAA0C,SAASA,OAAAA,CACvE,OACA,GACA,EAAA;AACA,EAAM,MAAA;AAAA,IACJ,OAAS,EAAA,WAAA;AAAA,IACT,SAAA;AAAA,IACA,KAAA;AAAA,IACA,cAAA;AAAA,IACA,QAAU,EAAA,YAAA;AAAA,IACV,aAAa,EAAC;AAAA,IACd,KAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,IACG,GAAA,IAAA;AAAA,GACD,GAAA,KAAA,CAAA;AAEJ,EAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,EAAyB,wBAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,aAAA;AAAA,IACR,GAAK,EAAAC,QAAA;AAAA,IACL,MAAQ,EAAA,YAAA;AAAA,GACT,CAAA,CAAA;AAED,EAAM,MAAA;AAAA,IACJ,kBAAoB,EAAA,gBAAA;AAAA,IACpB,iBAAmB,EAAA,eAAA;AAAA,IACnB,SAAW,EAAA,cAAA;AAAA,IACX,QAAU,EAAA,aAAA;AAAA,IACP,GAAA,cAAA;AAAA,GACD,GAAA,UAAA,CAAA;AAEJ,EA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AA,GAAA,KAAA,CAAA,GAAA,kBAAA,CAAA,kBAAA,CAAA;AAAA,UACrB,gBAAA;AAAA,SACF;AAAA,QACA,iBAAiB,EAAA,IAAA;AAAA,UACf,kBAAqB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,kBAAA,CAAA,iBAAA,CAAA;AAAA,UACrB,eAAA;AAAA,SACF;AAAA,QACA,IAAA;AAAA,QACA,KAAA;AAAA,QACA,OAAA;AAAA,QACA,SAAW,EAAA,IAAA,CAAK,YAAa,CAAA,OAAO,GAAG,cAAc,CAAA;AAAA,QACrD,cAAA;AAAA,QACA,QAAA;AAAA,QACA,MAAA;AAAA,QACA,QAAU,EAAA,YAAA;AAAA,QACV,OAAA;AAAA,QACA,IAAK,EAAA,UAAA;AAAA,QACJ,GAAG,cAAA;AAAA,OACN,CAAA;AAAA,sBACC,GAAA,CAAA,MAAA,EAAA;AAAA,QAAK,SAAA,EAAW,aAAa,OAAO,CAAA;AAAA,QACnC,QAAC,kBAAA,GAAA,CAAA,MAAA,EAAA;AAAA,UAAK,SAAA,EAAW,aAAa,OAAO,CAAA;AAAA,UAClC,qCAAY,GAAA,CAAA,WAAA,EAAA;AAAA,YAAY,SAAA,EAAW,aAAa,MAAM,CAAA;AAAA,WAAG,CAAA;AAAA,SAC5D,CAAA;AAAA,OACF,CAAA;AAAA,MACC,KAAA;AAAA,KAAA;AAAA,GACH,CAAA,CAAA;AAEJ,CAAC;;;;"}
@@ -1,45 +0,0 @@
1
- import { ChangeEventHandler, ComponentPropsWithoutRef, FocusEventHandler, ReactNode } from "react";
2
- export interface SwitchProps extends Omit<ComponentPropsWithoutRef<"label">, "children" | "onFocus" | "onBlur" | "onChange"> {
3
- /**
4
- * If `true`, the checkbox will be checked.
5
- */
6
- checked?: boolean;
7
- /**
8
- * Whether the checkbox component is checked by default
9
- * This will be disregarded if checked is already set.
10
- */
11
- defaultChecked?: boolean;
12
- /**
13
- * If `true`, the checkbox will be disabled.
14
- */
15
- disabled?: boolean;
16
- /**
17
- * Properties applied to the input element.
18
- */
19
- inputProps?: Partial<ComponentPropsWithoutRef<"input">>;
20
- /**
21
- * The label to be shown next to the checkbox.
22
- */
23
- label?: ReactNode;
24
- /**
25
- * The name applied to the input.
26
- */
27
- name?: string;
28
- /**
29
- * Callback when checkbox loses focus.
30
- */
31
- onBlur?: FocusEventHandler<HTMLInputElement>;
32
- /**
33
- * Callback when checked state is changed.
34
- */
35
- onChange?: ChangeEventHandler<HTMLInputElement>;
36
- /**
37
- * Callback when checkbox gains focus.
38
- */
39
- onFocus?: FocusEventHandler<HTMLInputElement>;
40
- /**
41
- * The value of the checkbox.
42
- */
43
- value?: string;
44
- }
45
- export declare const Switch: import("react").ForwardRefExoticComponent<SwitchProps & import("react").RefAttributes<HTMLLabelElement>>;
@@ -1 +0,0 @@
1
- export * from "./Switch";