@wonderflow/react-components 10.16.0 → 10.17.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.
Files changed (38) hide show
  1. package/dist/components/menu/menu-item/menu-item.d.ts +4 -0
  2. package/dist/components/menu/menu-item/menu-item.d.ts.map +1 -1
  3. package/dist/components/menu/menu-item/menu-item.js +3 -3
  4. package/dist/components/menu/menu-item/menu-item.stories.d.ts.map +1 -1
  5. package/dist/components/menu/menu-item/menu-item.stories.js +1 -0
  6. package/dist/components/select/select.js +1 -1
  7. package/dist/components/select/select.module.css +1 -1
  8. package/dist/components/selection-controls/checkbox.d.ts +12 -0
  9. package/dist/components/selection-controls/checkbox.d.ts.map +1 -1
  10. package/dist/components/selection-controls/checkbox.js +8 -4
  11. package/dist/components/selection-controls/checkbox.stories.d.ts +11 -0
  12. package/dist/components/selection-controls/checkbox.stories.d.ts.map +1 -1
  13. package/dist/components/selection-controls/checkbox.stories.js +6 -0
  14. package/dist/components/selection-controls/radio.d.ts +12 -0
  15. package/dist/components/selection-controls/radio.d.ts.map +1 -1
  16. package/dist/components/selection-controls/radio.js +9 -3
  17. package/dist/components/selection-controls/radio.stories.d.ts +9 -0
  18. package/dist/components/selection-controls/radio.stories.d.ts.map +1 -1
  19. package/dist/components/selection-controls/radio.stories.js +6 -0
  20. package/dist/components/selection-controls/selection-controls.module.css +1 -1
  21. package/dist/components/selection-controls/toggle.d.ts +12 -0
  22. package/dist/components/selection-controls/toggle.d.ts.map +1 -1
  23. package/dist/components/selection-controls/toggle.js +9 -3
  24. package/dist/components/selection-controls/toggle.stories.d.ts +1 -0
  25. package/dist/components/selection-controls/toggle.stories.d.ts.map +1 -1
  26. package/dist/components/selection-controls/toggle.stories.js +1 -0
  27. package/dist/components/slider/slider.d.ts +12 -0
  28. package/dist/components/slider/slider.d.ts.map +1 -1
  29. package/dist/components/slider/slider.js +6 -3
  30. package/dist/components/slider/slider.module.css +1 -1
  31. package/dist/components/slider/slider.stories.d.ts +15 -0
  32. package/dist/components/slider/slider.stories.d.ts.map +1 -1
  33. package/dist/components/slider/slider.stories.js +7 -0
  34. package/dist/components/textfield/textfield.js +1 -1
  35. package/dist/components/textfield/textfield.module.css +1 -1
  36. package/dist/components/textfield/textfield.stories.d.ts.map +1 -1
  37. package/dist/components/textfield/textfield.stories.js +2 -1
  38. package/package.json +3 -3
@@ -13,6 +13,10 @@ export declare type MenuItemProps = {
13
13
  * Set the position of the icon. Used only when icon is defined.
14
14
  */
15
15
  iconPosition?: 'left' | 'right';
16
+ /**
17
+ * Whether the menu item should have a supporting text
18
+ */
19
+ subtext?: string;
16
20
  /**
17
21
  * Set the size of the menu item.
18
22
  * Font size and icon style will be adjusted to match the size.
@@ -1 +1 @@
1
- {"version":3,"file":"menu-item.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/menu-item/menu-item.tsx"],"names":[],"mappings":"AAiBA,OAAO,EACO,SAAS,EACtB,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,WAAW,EAAiB,WAAW,EACxC,MAAM,cAAc,CAAC;AAItB,oBAAY,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf,CAAA;AAED,aAAK,mBAAmB,GAAG,WAAW,CAAC,mBAAmB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AAEpF,eAAO,MAAM,QAAQ,qBA8FI,CAAC"}
1
+ {"version":3,"file":"menu-item.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/menu-item/menu-item.tsx"],"names":[],"mappings":"AAiBA,OAAO,EACO,SAAS,EACtB,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,WAAW,EAAiB,WAAW,EAExC,MAAM,cAAc,CAAC;AAItB,oBAAY,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf,CAAA;AAED,aAAK,mBAAmB,GAAG,WAAW,CAAC,mBAAmB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AAEpF,eAAO,MAAM,QAAQ,qBAkGI,CAAC"}
@@ -17,9 +17,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
17
  import clsx from 'clsx';
18
18
  import { forwardRef, useCallback, useMemo, useRef, } from 'react';
19
19
  import { useFocusEffect, useRovingTabIndex } from 'react-roving-tabindex';
20
- import { Stack, Symbol, Tooltip, } from '../../..';
20
+ import { Stack, Symbol, Text, Tooltip, } from '../../..';
21
21
  import * as styles from './menu-item.module.css';
22
- export const MenuItem = forwardRef(({ className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description, padding = true, disabled = false, autoFocus, decoration, value, ...otherProps }, forwardedRef) => {
22
+ export const MenuItem = forwardRef(({ className, children, subtext, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description, padding = true, disabled = false, autoFocus, decoration, value, ...otherProps }, forwardedRef) => {
23
23
  const itemRef = useRef(forwardedRef);
24
24
  const [tabIndex, isFocused, handleKeyDown, handleClick] = useRovingTabIndex(itemRef, disabled);
25
25
  const isIconRight = iconPosition === 'right';
@@ -30,7 +30,7 @@ export const MenuItem = forwardRef(({ className, children, onClick, icon, dimens
30
30
  onClick(e, value);
31
31
  }
32
32
  }, [handleClick, onClick, value]);
33
- const InnerContent = useMemo(() => (_jsxs(Stack, { direction: isIconRight ? 'row-reverse' : 'row', as: "span", fill: false, className: styles.ItemContent, hAlign: isIconRight ? 'space-between' : 'start', vAlign: "center", columnGap: 8, hPadding: 16, vPadding: 8, "data-menu-item-icon-right": isIconRight, "data-menu-item-has-icon": Boolean(icon), "data-menu-item-padding": padding, style: { inlineSize: '100%' }, children: [icon && (_jsx(Symbol, { className: styles.Icon, source: icon, dimension: dimension === 'small' ? 12 : 16 })), _jsxs(Stack, { className: styles.DecorationContent, columnGap: 16, fill: false, direction: "row", hAlign: "space-between", children: [children, decoration] })] })), [children, dimension, icon, isIconRight, decoration, padding]);
33
+ const InnerContent = useMemo(() => (_jsxs(Stack, { direction: isIconRight ? 'row-reverse' : 'row', as: "span", fill: false, className: styles.ItemContent, hAlign: isIconRight ? 'space-between' : 'start', vAlign: "center", columnGap: 8, hPadding: 16, vPadding: 8, "data-menu-item-icon-right": isIconRight, "data-menu-item-has-icon": Boolean(icon), "data-menu-item-padding": padding, style: { inlineSize: '100%' }, children: [icon && (_jsx(Symbol, { className: styles.Icon, source: icon, dimension: dimension === 'small' ? 12 : 16 })), _jsxs(Stack, { className: styles.DecorationContent, columnGap: 16, fill: false, direction: "row", hAlign: "space-between", children: [_jsxs(Stack, { direction: "column", children: [children, subtext && _jsx(Text, { size: 14, style: { fontWeight: '400' }, children: subtext })] }), decoration] })] })), [children, subtext, dimension, icon, isIconRight, decoration, padding]);
34
34
  return (_jsx(Stack, { as: "li", role: "none", children: _jsx(Wrapper, { autoFocus: autoFocus, ref: itemRef, role: "menuitem", className: clsx(styles.MenuItem, className), onClick: disabled ? undefined : triggerClick, onKeyDown: disabled ? undefined : handleKeyDown, tabIndex: tabIndex, "aria-disabled": disabled, type: Wrapper === 'button' ? 'button' : undefined, "data-menu-item-dimension": dimension, ...otherProps, children: description
35
35
  ? (_jsx(Tooltip, { fill: true, open: isFocused, placement: "right-start", interactive: true, trigger: InnerContent, children: description }))
36
36
  : InnerContent }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"menu-item.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/menu-item/menu-item.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIjE,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE1B,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,IAAI,CAAC,IAAI,CAkB1C,CAAC;AAEF,eAAe,KAAK,CAAC;AAsBrB,eAAO,MAAM,WAAW,yHAAwB,CAAC;AA+BjD,eAAO,MAAM,cAAc;;GAAgC,CAAC;AAW5D,eAAO,MAAM,eAAe,yHAAkC,CAAC"}
1
+ {"version":3,"file":"menu-item.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/menu-item/menu-item.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIjE,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE1B,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,IAAI,CAAC,IAAI,CAmB1C,CAAC;AAEF,eAAe,KAAK,CAAC;AAsBrB,eAAO,MAAM,WAAW,yHAAwB,CAAC;AA+BjD,eAAO,MAAM,cAAc;;GAAgC,CAAC;AAW5D,eAAO,MAAM,eAAe,yHAAkC,CAAC"}
@@ -9,6 +9,7 @@ const story = {
9
9
  dimension: 'regular',
10
10
  padding: true,
11
11
  iconPosition: 'left',
12
+ subtext: '',
12
13
  },
13
14
  argTypes: {
14
15
  dimension: {
@@ -26,6 +26,6 @@ export const Select = forwardRef(({ children, className, disabled = false, icon
26
26
  regular: 16,
27
27
  big: 24,
28
28
  };
29
- return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(styles.Select, className), "data-select-is-multiple": kind === 'multiple', "data-select-has-label": Boolean(label), "data-select-dimension": dimension, "aria-disabled": disabled, hAlign: "start", vAlign: "start", inline: true, tabIndex: disabled ? 0 : undefined, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor: seedID('select'), children: label }), _jsxs("div", { className: styles.FieldContainer, children: [_jsx("select", { disabled: disabled, className: styles.Field, id: seedID('select'), multiple: kind === 'multiple', onChange: onChange, ref: forwardedRef, ...otherProps, children: children }), kind === 'single' && (_jsx(Symbol, { className: styles.Icon, source: icon, dimension: iconSizes[dimension] }))] })] }));
29
+ return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(styles.Select, className), "data-select-is-multiple": kind === 'multiple', "data-select-has-label": Boolean(label), "data-select-dimension": dimension, "aria-disabled": disabled, hAlign: "start", vAlign: "start", inline: true, tabIndex: disabled ? 0 : undefined, children: [label && _jsx(Text, { as: "label", "aria-disabled": disabled, className: styles.Label, size: dimension === 'small' ? 14 : 16, htmlFor: seedID('select'), children: label }), _jsxs("div", { className: styles.FieldContainer, children: [_jsx("select", { disabled: disabled, className: styles.Field, id: seedID('select'), multiple: kind === 'multiple', onChange: onChange, ref: forwardedRef, ...otherProps, children: children }), kind === 'single' && (_jsx(Symbol, { className: styles.Icon, source: icon, dimension: iconSizes[dimension] }))] })] }));
30
30
  });
31
31
  Select.displayName = 'Select';
@@ -1 +1 @@
1
- @layer components{.Select{appearance:none;padding:0;position:relative}.Select[data-select-dimension=small]{--field-height:1.50rem;--field-padding:0.33rem;--font-size:0.88rem}.Select[data-select-dimension=regular]{--field-height:2.50rem;--field-padding:1.00rem;--font-size:1.00rem}.Select[data-select-dimension=big]{--field-height:3.00rem;--field-padding:1.00rem;--font-size:1.13rem}.FieldContainer{color:var(--global-vibrancy-foreground);inline-size:100%;position:relative}.Select[aria-disabled=true] .FieldContainer{color:var(--global-disabled-foreground)}.Field{appearance:none;-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background:linear-gradient(to bottom,var(--global-vibrancy-background),var(--global-vibrancy-background));block-size:var(--field-height);border:0;border-radius:.25rem;box-sizing:border-box;color:inherit;display:block;font-family:inherit;font-size:var(--font-size);margin:0;min-inline-size:100%;overflow:hidden;padding:0 calc(var(--field-padding)*3.5) 0 var(--field-padding);text-overflow:ellipsis}.Field:disabled{background:linear-gradient(to bottom,var(--global-disabled-background),var(--global-disabled-background));color:var(--global-disabled-foreground);cursor:not-allowed}.Field option{color:#000}.Field optgroup{color:initial}.Field[multiple]{block-size:auto;overflow:auto;padding:.5rem 1rem}.Field[multiple] option{color:currentcolor;padding:calc(var(--field-padding)/2) var(--field-padding)}.Field[multiple] option:checked{background:#9ea5b3 linear-gradient(180deg,#9ea5b3 0,#9ea5b3);background-color:#9ea5b3;color:var(--global-background)}.Field[multiple] optgroup{color:currentcolor;font-family:inherit;font-size:inherit;line-height:inherit;margin:0 0 1rem}.Icon{border-radius:.25rem;pointer-events:none;position:absolute;right:calc(var(--field-padding) - var(--field-padding)/3);top:calc(var(--field-height)/2);transform:translateY(-50%)}}
1
+ @layer components{.Select{appearance:none;padding:0;position:relative}.Select[data-select-dimension=small]{--field-height:1.50rem;--field-padding:0.33rem;--font-size:0.88rem}.Select[data-select-dimension=regular]{--field-height:2.50rem;--field-padding:1.00rem;--font-size:1.00rem}.Select[data-select-dimension=big]{--field-height:3.00rem;--field-padding:1.00rem;--font-size:1.13rem}.FieldContainer{color:var(--global-vibrancy-foreground);inline-size:100%;position:relative}.Select[aria-disabled=true] .FieldContainer{color:var(--global-disabled-foreground)}.Field{appearance:none;-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background:linear-gradient(to bottom,var(--global-vibrancy-background),var(--global-vibrancy-background));block-size:var(--field-height);border:0;border-radius:.25rem;box-sizing:border-box;color:inherit;display:block;font-family:inherit;font-size:var(--font-size);margin:0;min-inline-size:100%;overflow:hidden;padding:0 calc(var(--field-padding)*3.5) 0 var(--field-padding);text-overflow:ellipsis}.Field:disabled{background:linear-gradient(to bottom,var(--global-disabled-background),var(--global-disabled-background));color:var(--global-disabled-foreground);cursor:not-allowed}.Field option{color:#000}.Field optgroup{color:initial}.Field[multiple]{block-size:auto;overflow:auto;padding:.5rem 1rem}.Field[multiple] option{color:currentcolor;padding:calc(var(--field-padding)/2) var(--field-padding)}.Field[multiple] option:checked{background:#9ea5b3 linear-gradient(180deg,#9ea5b3 0,#9ea5b3);background-color:#9ea5b3;color:var(--global-background)}.Field[multiple] optgroup{color:currentcolor;font-family:inherit;font-size:inherit;line-height:inherit;margin:0 0 1rem}.Icon{border-radius:.25rem;pointer-events:none;position:absolute;right:calc(var(--field-padding) - var(--field-padding)/3);top:calc(var(--field-height)/2);transform:translateY(-50%)}.Label[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}}
@@ -9,6 +9,12 @@ export declare type CheckboxProps = InputHTMLAttributes<HTMLInputElement> & {
9
9
  * Is used when a subset of the options are selected but not all of them.
10
10
  */
11
11
  indeterminate?: boolean;
12
+ /**
13
+ * Define the accessible label of the input. While this is not
14
+ * mandatory, an input should always have a label. If not using this property
15
+ * you can bind a custom label to the input by using an id.
16
+ */
17
+ label?: string;
12
18
  /**
13
19
  * Set the size of the toggle.
14
20
  */
@@ -29,6 +35,12 @@ export declare const Checkbox: import("react").ForwardRefExoticComponent<InputHT
29
35
  * Is used when a subset of the options are selected but not all of them.
30
36
  */
31
37
  indeterminate?: boolean | undefined;
38
+ /**
39
+ * Define the accessible label of the input. While this is not
40
+ * mandatory, an input should always have a label. If not using this property
41
+ * you can bind a custom label to the input by using an id.
42
+ */
43
+ label?: string | undefined;
32
44
  /**
33
45
  * Set the size of the toggle.
34
46
  */
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/checkbox.tsx"],"names":[],"mappings":"AAkBA,OAAO,EACL,WAAW,EAAc,mBAAmB,EAC7C,MAAM,OAAO,CAAC;AAIf,oBAAY,aAAa,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAClE;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC3D,CAAA;AAED,eAAO,MAAM,QAAQ;IApBnB;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;;OAGG;wBACgB,YAAY,gBAAgB,CAAC,KAAK,IAAI;oDA0CzD,CAAC"}
1
+ {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/checkbox.tsx"],"names":[],"mappings":"AAkBA,OAAO,EACL,WAAW,EAAc,mBAAmB,EAC7C,MAAM,OAAO,CAAC;AAOf,oBAAY,aAAa,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAClE;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC3D,CAAA;AAED,eAAO,MAAM,QAAQ;IA1BnB;;OAEG;;IAEH;;;OAGG;;IAEH;;;;OAIG;;IAEH;;OAEG;;IAEH;;;OAGG;wBACgB,YAAY,gBAAgB,CAAC,KAAK,IAAI;oDAmEzD,CAAC"}
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /*
3
3
  * Copyright 2022 Wonderflow <authored by Mattia Astorino>
4
4
  *
@@ -16,15 +16,19 @@ import { jsx as _jsx } from "react/jsx-runtime";
16
16
  */
17
17
  import clsx from 'clsx';
18
18
  import { domAnimation, LazyMotion, m } from 'framer-motion';
19
- import { forwardRef, useEffect, useRef, } from 'react';
19
+ import { forwardRef, useEffect, useMemo, useRef, } from 'react';
20
+ import { useUIDSeed } from 'react-uid';
21
+ import { Stack, Text } from '../..';
20
22
  import * as styles from './selection-controls.module.css';
21
- export const Checkbox = forwardRef(({ className, disabled, dimension = 'regular', onChange, indeterminate, hidden, ...otherProps }, forwardedRef) => {
23
+ export const Checkbox = forwardRef(({ className, disabled, dimension = 'regular', onChange, indeterminate, id, label, hidden, ...otherProps }, forwardedRef) => {
22
24
  const ref = useRef(forwardedRef);
25
+ const seedID = useUIDSeed();
26
+ const fieldID = useMemo(() => id ?? seedID('checkbox'), [id, seedID]);
23
27
  useEffect(() => {
24
28
  if (ref.current) {
25
29
  ref.current.indeterminate = indeterminate;
26
30
  }
27
31
  }, [indeterminate]);
28
- return (_jsx(LazyMotion, { features: domAnimation, strict: true, children: _jsx(m.span, { className: clsx(styles.InputWrapper, className), whileTap: { scale: 1.15 }, transition: { duration: 0.3, ease: 'backOut' }, "data-radio-control": hidden, children: _jsx("input", { type: "checkbox", disabled: disabled, "aria-disabled": disabled, "data-control-dimension": dimension, onChange: onChange, className: styles.CheckboxInput, ref: ref, hidden: hidden, ...otherProps }) }) }));
32
+ return (_jsx(LazyMotion, { features: domAnimation, strict: true, children: _jsx(m.span, { className: clsx(styles.InputWrapper, className), whileTap: { scale: 1.15 }, transition: { duration: 0.3, ease: 'backOut' }, "data-radio-control": hidden, children: _jsxs(Stack, { as: "span", direction: "row", columnGap: 8, vAlign: "center", fill: false, wrap: true, children: [_jsx("input", { type: "checkbox", disabled: disabled, "aria-disabled": disabled, "data-control-dimension": dimension, onChange: onChange, className: styles.CheckboxInput, ref: ref, hidden: hidden, id: fieldID, ...otherProps }), label && (_jsx(Text, { as: "label", "aria-disabled": disabled, className: styles.Label, size: dimension === 'small' ? 14 : 16, htmlFor: fieldID, children: label }))] }) }) }));
29
33
  });
30
34
  Checkbox.displayName = 'Checkbox';
@@ -6,24 +6,35 @@ export default story;
6
6
  export declare const Default: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
7
7
  disabled?: boolean | undefined;
8
8
  indeterminate?: boolean | undefined;
9
+ label?: string | undefined;
9
10
  dimension?: "small" | "regular" | undefined;
10
11
  onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
11
12
  } & React.RefAttributes<HTMLInputElement>>>;
12
13
  export declare const Checked: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
13
14
  disabled?: boolean | undefined;
14
15
  indeterminate?: boolean | undefined;
16
+ label?: string | undefined;
15
17
  dimension?: "small" | "regular" | undefined;
16
18
  onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
17
19
  } & React.RefAttributes<HTMLInputElement>>>;
18
20
  export declare const DisabledChecked: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
19
21
  disabled?: boolean | undefined;
20
22
  indeterminate?: boolean | undefined;
23
+ label?: string | undefined;
21
24
  dimension?: "small" | "regular" | undefined;
22
25
  onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
23
26
  } & React.RefAttributes<HTMLInputElement>>>;
24
27
  export declare const Indeterminate: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
25
28
  disabled?: boolean | undefined;
26
29
  indeterminate?: boolean | undefined;
30
+ label?: string | undefined;
31
+ dimension?: "small" | "regular" | undefined;
32
+ onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
33
+ } & React.RefAttributes<HTMLInputElement>>>;
34
+ export declare const withLabel: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
35
+ disabled?: boolean | undefined;
36
+ indeterminate?: boolean | undefined;
37
+ label?: string | undefined;
27
38
  dimension?: "small" | "regular" | undefined;
28
39
  onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
29
40
  } & React.RefAttributes<HTMLInputElement>>>;
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.stories.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/checkbox.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,QAAQ,CAezC,CAAC;AAEF,eAAe,KAAK,CAAC;AAMrB,eAAO,MAAM,OAAO;;;;;2CAAoB,CAAC;AAEzC,eAAO,MAAM,OAAO;;;;;2CAAoB,CAAC;AAKzC,eAAO,MAAM,eAAe;;;;;2CAAoB,CAAC;AAMjD,eAAO,MAAM,aAAa;;;;;2CAAoB,CAAC"}
1
+ {"version":3,"file":"checkbox.stories.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/checkbox.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,QAAQ,CAezC,CAAC;AAEF,eAAe,KAAK,CAAC;AAMrB,eAAO,MAAM,OAAO;;;;;;2CAAoB,CAAC;AAEzC,eAAO,MAAM,OAAO;;;;;;2CAAoB,CAAC;AAKzC,eAAO,MAAM,eAAe;;;;;;2CAAoB,CAAC;AAMjD,eAAO,MAAM,aAAa;;;;;;2CAAoB,CAAC;AAK/C,eAAO,MAAM,SAAS;;;;;;2CAAoB,CAAC"}
@@ -32,3 +32,9 @@ export const Indeterminate = Template.bind({});
32
32
  Indeterminate.args = {
33
33
  indeterminate: true,
34
34
  };
35
+ export const withLabel = Template.bind({});
36
+ withLabel.args = {
37
+ defaultChecked: true,
38
+ disabled: false,
39
+ label: 'Label',
40
+ };
@@ -4,6 +4,12 @@ export declare type RadioProps = InputHTMLAttributes<HTMLInputElement> & {
4
4
  * Set disabled state. The component is not interactive and grayed out.
5
5
  */
6
6
  disabled?: boolean;
7
+ /**
8
+ * Define the accessible label of the input. While this is not
9
+ * mandatory, an input should always have a label. If not using this property
10
+ * you can bind a custom label to the input by using an id.
11
+ */
12
+ label?: string;
7
13
  /**
8
14
  * Set the size of the toggle.
9
15
  */
@@ -19,6 +25,12 @@ export declare const Radio: import("react").ForwardRefExoticComponent<InputHTMLA
19
25
  * Set disabled state. The component is not interactive and grayed out.
20
26
  */
21
27
  disabled?: boolean | undefined;
28
+ /**
29
+ * Define the accessible label of the input. While this is not
30
+ * mandatory, an input should always have a label. If not using this property
31
+ * you can bind a custom label to the input by using an id.
32
+ */
33
+ label?: string | undefined;
22
34
  /**
23
35
  * Set the size of the toggle.
24
36
  */
@@ -1 +1 @@
1
- {"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/radio.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,WAAW,EAAc,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAIrE,oBAAY,UAAU,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAC/D;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC3D,CAAA;AAED,eAAO,MAAM,KAAK;IAfhB;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;wBACgB,YAAY,gBAAgB,CAAC,KAAK,IAAI;oDA+BzD,CAAC"}
1
+ {"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/radio.tsx"],"names":[],"mappings":"AAkBA,OAAO,EACL,WAAW,EAAc,mBAAmB,EAC7C,MAAM,OAAO,CAAC;AAOf,oBAAY,UAAU,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAC/D;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC3D,CAAA;AAED,eAAO,MAAM,KAAK;IArBhB;;OAEG;;IAEH;;;;OAIG;;IAEH;;OAEG;;IAEH;;;OAGG;wBACgB,YAAY,gBAAgB,CAAC,KAAK,IAAI;oDA2DzD,CAAC"}
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /*
3
3
  * Copyright 2022 Wonderflow <authored by Mattia Astorino>
4
4
  *
@@ -16,7 +16,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
16
16
  */
17
17
  import clsx from 'clsx';
18
18
  import { domAnimation, LazyMotion, m } from 'framer-motion';
19
- import { forwardRef } from 'react';
19
+ import { forwardRef, useMemo, } from 'react';
20
+ import { useUIDSeed } from 'react-uid';
21
+ import { Stack, Text } from '../..';
20
22
  import * as styles from './selection-controls.module.css';
21
- export const Radio = forwardRef(({ className, disabled, dimension = 'regular', onChange, hidden, ...otherProps }, forwardedRef) => (_jsx(LazyMotion, { features: domAnimation, strict: true, children: _jsx(m.span, { className: clsx(styles.InputWrapper, className), whileTap: { scale: 1.15 }, transition: { duration: 0.3, ease: 'backOut' }, "data-radio-control": hidden, children: _jsx("input", { type: "radio", disabled: disabled, "aria-disabled": disabled, "data-control-dimension": dimension, onChange: onChange, className: styles.RadioInput, ref: forwardedRef, hidden: hidden, ...otherProps }) }) })));
23
+ export const Radio = forwardRef(({ className, disabled, id, label, dimension = 'regular', onChange, hidden, ...otherProps }, forwardedRef) => {
24
+ const seedID = useUIDSeed();
25
+ const fieldID = useMemo(() => id ?? seedID('radio'), [id, seedID]);
26
+ return (_jsx(LazyMotion, { features: domAnimation, strict: true, children: _jsx(m.span, { className: clsx(styles.InputWrapper, className), whileTap: { scale: 1.15 }, transition: { duration: 0.3, ease: 'backOut' }, "data-radio-control": hidden, children: _jsxs(Stack, { as: "span", direction: "row", columnGap: 8, vAlign: "center", fill: false, wrap: true, children: [_jsx("input", { type: "radio", disabled: disabled, "aria-disabled": disabled, "data-control-dimension": dimension, onChange: onChange, className: styles.RadioInput, ref: forwardedRef, hidden: hidden, id: fieldID, ...otherProps }), label && (_jsx(Text, { as: "label", "aria-disabled": disabled, className: styles.Label, size: dimension === 'small' ? 14 : 16, htmlFor: fieldID, children: label }))] }) }) }));
27
+ });
22
28
  Radio.displayName = 'Radio';
@@ -5,16 +5,25 @@ declare const story: ComponentMeta<typeof Radio>;
5
5
  export default story;
6
6
  export declare const Default: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
7
7
  disabled?: boolean | undefined;
8
+ label?: string | undefined;
8
9
  dimension?: "small" | "regular" | undefined;
9
10
  onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
10
11
  } & React.RefAttributes<HTMLInputElement>>>;
11
12
  export declare const Checked: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
12
13
  disabled?: boolean | undefined;
14
+ label?: string | undefined;
13
15
  dimension?: "small" | "regular" | undefined;
14
16
  onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
15
17
  } & React.RefAttributes<HTMLInputElement>>>;
16
18
  export declare const DisabledChecked: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
17
19
  disabled?: boolean | undefined;
20
+ label?: string | undefined;
21
+ dimension?: "small" | "regular" | undefined;
22
+ onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
23
+ } & React.RefAttributes<HTMLInputElement>>>;
24
+ export declare const withLabel: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
25
+ disabled?: boolean | undefined;
26
+ label?: string | undefined;
18
27
  dimension?: "small" | "regular" | undefined;
19
28
  onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
20
29
  } & React.RefAttributes<HTMLInputElement>>>;
@@ -1 +1 @@
1
- {"version":3,"file":"radio.stories.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/radio.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,KAAK,CAetC,CAAC;AAEF,eAAe,KAAK,CAAC;AAMrB,eAAO,MAAM,OAAO;;;;2CAAoB,CAAC;AAEzC,eAAO,MAAM,OAAO;;;;2CAAoB,CAAC;AAKzC,eAAO,MAAM,eAAe;;;;2CAAoB,CAAC"}
1
+ {"version":3,"file":"radio.stories.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/radio.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,KAAK,CAetC,CAAC;AAEF,eAAe,KAAK,CAAC;AAMrB,eAAO,MAAM,OAAO;;;;;2CAAoB,CAAC;AAEzC,eAAO,MAAM,OAAO;;;;;2CAAoB,CAAC;AAKzC,eAAO,MAAM,eAAe;;;;;2CAAoB,CAAC;AAMjD,eAAO,MAAM,SAAS;;;;;2CAAoB,CAAC"}
@@ -28,3 +28,9 @@ DisabledChecked.args = {
28
28
  defaultChecked: true,
29
29
  disabled: true,
30
30
  };
31
+ export const withLabel = Template.bind({});
32
+ withLabel.args = {
33
+ defaultChecked: true,
34
+ disabled: false,
35
+ label: 'Label',
36
+ };
@@ -1 +1 @@
1
- @layer components{.InputWrapper{display:inline-block;line-height:0}.InputWrapper[data-radio-control=true]{position:absolute}.CheckboxInput{--w:24px;--h:24px;appearance:none;-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);block-size:var(--h);border-radius:.25rem;box-shadow:0 0 0 1px var(--global-background),inset 0 0 0 1px var(--dimmed-2);color:var(--global-background);inline-size:var(--w);max-block-size:var(--h);max-inline-size:var(--w);position:relative}.CheckboxInput:after{block-size:27%;border-bottom:2px solid;border-left:2px solid;content:"";display:none;inline-size:50%;left:50%;position:absolute;top:50%;transform:translate(-50%,-80%) rotate(-45deg)}.CheckboxInput:active{background-color:var(--global-vibrancy-background-hard)}.CheckboxInput:checked,.CheckboxInput:indeterminate{background:var(--dimmed-7);box-shadow:0 0 0 1px var(--global-background),inset 0 0 0 1px transparent}.CheckboxInput:checked:after,.CheckboxInput:indeterminate:after{display:block}.CheckboxInput:disabled{background-color:var(--global-disabled-background);color:var(--global-disabled-foreground);cursor:not-allowed}.CheckboxInput[data-control-dimension=small]{--w:16px;--h:16px}.CheckboxInput:indeterminate:after{block-size:2px;border-left:0;transform:translate(-50%,-50%)}.RadioInput{composes:CheckboxInput;border-radius:100%}.RadioInput:after{background-color:currentcolor;block-size:50%;border:0;border-radius:100%;inline-size:50%;transform:translate(-50%,-50%)}.Toggle{--w:44px;--h:24px;--p:2px;composes:RadioInput;border-radius:200px;color:var(--dimmed-7)}.Toggle:checked{color:var(--global-background)}.Toggle:disabled{color:var(--global-disabled-foreground)}.Toggle:after{block-size:calc(var(--h) - var(--p)*2);bottom:var(--p);display:block;inline-size:calc(var(--h) - var(--p)*2);left:var(--p);top:var(--p);transform:none;transition:transform .1s cubic-bezier(.3,.07,.34,1),background-color .1s cubic-bezier(.3,.07,.34,1)}.Toggle:checked:after{display:block;transform:translateX(100%)}.Toggle[data-control-dimension=small]{--w:28px;--h:16px}}
1
+ @layer components{.InputWrapper{display:inline-block;line-height:0}.InputWrapper[data-radio-control=true]{position:absolute}.CheckboxInput{--w:24px;--h:24px;appearance:none;-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);block-size:var(--h);border-radius:.25rem;box-shadow:0 0 0 1px var(--global-background),inset 0 0 0 1px var(--dimmed-2);color:var(--global-background);inline-size:var(--w);max-block-size:var(--h);max-inline-size:var(--w);position:relative}.CheckboxInput:after{block-size:27%;border-bottom:2px solid;border-left:2px solid;content:"";display:none;inline-size:50%;left:50%;position:absolute;top:50%;transform:translate(-50%,-80%) rotate(-45deg)}.CheckboxInput:active{background-color:var(--global-vibrancy-background-hard)}.CheckboxInput:checked,.CheckboxInput:indeterminate{background:var(--dimmed-7);box-shadow:0 0 0 1px var(--global-background),inset 0 0 0 1px transparent}.CheckboxInput:checked:after,.CheckboxInput:indeterminate:after{display:block}.CheckboxInput:disabled{background-color:var(--global-disabled-background);color:var(--global-disabled-foreground);cursor:not-allowed}.CheckboxInput[data-control-dimension=small]{--w:16px;--h:16px}.CheckboxInput:indeterminate:after{block-size:2px;border-left:0;transform:translate(-50%,-50%)}.RadioInput{composes:CheckboxInput;border-radius:100%}.RadioInput:after{background-color:currentcolor;block-size:50%;border:0;border-radius:100%;inline-size:50%;transform:translate(-50%,-50%)}.Toggle{--w:44px;--h:24px;--p:2px;composes:RadioInput;border-radius:200px;color:var(--dimmed-7)}.Toggle:checked{color:var(--global-background)}.Toggle:disabled{color:var(--global-disabled-foreground)}.Toggle:after{block-size:calc(var(--h) - var(--p)*2);bottom:var(--p);display:block;inline-size:calc(var(--h) - var(--p)*2);left:var(--p);top:var(--p);transform:none;transition:transform .1s cubic-bezier(.3,.07,.34,1),background-color .1s cubic-bezier(.3,.07,.34,1)}.Toggle:checked:after{display:block;transform:translateX(100%)}.Toggle[data-control-dimension=small]{--w:28px;--h:16px}.Label[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}}
@@ -4,6 +4,12 @@ export declare type ToggleProps = InputHTMLAttributes<HTMLInputElement> & {
4
4
  * Set disabled state. The component is not interactive and grayed out.
5
5
  */
6
6
  disabled?: boolean;
7
+ /**
8
+ * Define the accessible label of the input. While this is not
9
+ * mandatory, an input should always have a label. If not using this property
10
+ * you can bind a custom label to the input by using an id.
11
+ */
12
+ label?: string;
7
13
  /**
8
14
  * Set the size of the toggle.
9
15
  */
@@ -19,6 +25,12 @@ export declare const Toggle: import("react").ForwardRefExoticComponent<InputHTML
19
25
  * Set disabled state. The component is not interactive and grayed out.
20
26
  */
21
27
  disabled?: boolean | undefined;
28
+ /**
29
+ * Define the accessible label of the input. While this is not
30
+ * mandatory, an input should always have a label. If not using this property
31
+ * you can bind a custom label to the input by using an id.
32
+ */
33
+ label?: string | undefined;
22
34
  /**
23
35
  * Set the size of the toggle.
24
36
  */
@@ -1 +1 @@
1
- {"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/toggle.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,WAAW,EAAc,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAIrE,oBAAY,WAAW,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAChE;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC3D,CAAA;AAED,eAAO,MAAM,MAAM;IAfjB;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;wBACgB,YAAY,gBAAgB,CAAC,KAAK,IAAI;oDAoBzD,CAAC"}
1
+ {"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/toggle.tsx"],"names":[],"mappings":"AAiBA,OAAO,EACL,WAAW,EAAc,mBAAmB,EAC7C,MAAM,OAAO,CAAC;AAOf,oBAAY,WAAW,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAChE;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC3D,CAAA;AAED,eAAO,MAAM,MAAM;IArBjB;;OAEG;;IAEH;;;;OAIG;;IAEH;;OAEG;;IAEH;;;OAGG;wBACgB,YAAY,gBAAgB,CAAC,KAAK,IAAI;oDAiDzD,CAAC"}
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /*
3
3
  * Copyright 2022 Wonderflow <authored by Mattia Astorino>
4
4
  *
@@ -15,7 +15,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
15
15
  * limitations under the License.
16
16
  */
17
17
  import clsx from 'clsx';
18
- import { forwardRef } from 'react';
18
+ import { forwardRef, useMemo, } from 'react';
19
+ import { useUIDSeed } from 'react-uid';
20
+ import { Stack, Text } from '../..';
19
21
  import * as styles from './selection-controls.module.css';
20
- export const Toggle = forwardRef(({ className, disabled, dimension = 'regular', onChange, ...otherProps }, forwardedRef) => (_jsx("input", { type: "checkbox", disabled: disabled, "aria-disabled": disabled, "data-control-dimension": dimension, onChange: onChange, className: clsx(styles.Toggle, className), ref: forwardedRef, ...otherProps })));
22
+ export const Toggle = forwardRef(({ className, disabled, id, label, dimension = 'regular', onChange, ...otherProps }, forwardedRef) => {
23
+ const seedID = useUIDSeed();
24
+ const fieldID = useMemo(() => id ?? seedID('toggle'), [id, seedID]);
25
+ return (_jsxs(Stack, { as: "span", direction: "row", columnGap: 8, vAlign: "center", fill: false, wrap: true, children: [_jsx("input", { type: "checkbox", disabled: disabled, "aria-disabled": disabled, "data-control-dimension": dimension, onChange: onChange, className: clsx(styles.Toggle, className), ref: forwardedRef, id: fieldID, ...otherProps }), label && (_jsx(Text, { as: "label", "aria-disabled": disabled, className: styles.Label, size: dimension === 'small' ? 14 : 16, htmlFor: fieldID, children: label }))] }));
26
+ });
21
27
  Toggle.displayName = 'Toggle';
@@ -5,4 +5,5 @@ export default story;
5
5
  export declare const Default: ComponentStory<typeof Toggle>;
6
6
  export declare const Checked: ComponentStory<typeof Toggle>;
7
7
  export declare const DisabledChecked: ComponentStory<typeof Toggle>;
8
+ export declare const withLabel: ComponentStory<typeof Toggle>;
8
9
  //# sourceMappingURL=toggle.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toggle.stories.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/toggle.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,MAAM,CAevC,CAAC;AAEF,eAAe,KAAK,CAAC;AAErB,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,OAAO,MAAM,CAAgC,CAAC;AACnF,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,OAAO,MAAM,CAA+C,CAAC;AAClG,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,OAAO,MAAM,CAAwD,CAAC"}
1
+ {"version":3,"file":"toggle.stories.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/toggle.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,MAAM,CAevC,CAAC;AAEF,eAAe,KAAK,CAAC;AAErB,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,OAAO,MAAM,CAAgC,CAAC;AACnF,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,OAAO,MAAM,CAA+C,CAAC;AAClG,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,OAAO,MAAM,CAAwD,CAAC;AACnH,eAAO,MAAM,SAAS,EAAE,cAAc,CAAC,OAAO,MAAM,CAA6D,CAAC"}
@@ -20,3 +20,4 @@ export default story;
20
20
  export const Default = args => _jsx(Toggle, { ...args });
21
21
  export const Checked = args => _jsx(Toggle, { defaultChecked: true, ...args });
22
22
  export const DisabledChecked = args => _jsx(Toggle, { defaultChecked: true, disabled: true, ...args });
23
+ export const withLabel = args => _jsx(Toggle, { defaultChecked: true, label: "Label", ...args });
@@ -41,6 +41,12 @@ export declare type SliderProps = InputHTMLAttributes<HTMLInputElement> & {
41
41
  * Set the size of the slider.
42
42
  */
43
43
  dimension?: 'small' | 'regular';
44
+ /**
45
+ * Define the accessible label of the input. While this is not
46
+ * mandatory, an input should always have a label. If not using this property
47
+ * you can bind a custom label to the input by using an id.
48
+ */
49
+ label?: string;
44
50
  };
45
51
  export declare const Slider: import("react").ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & {
46
52
  /**
@@ -83,5 +89,11 @@ export declare const Slider: import("react").ForwardRefExoticComponent<InputHTML
83
89
  * Set the size of the slider.
84
90
  */
85
91
  dimension?: "small" | "regular" | undefined;
92
+ /**
93
+ * Define the accessible label of the input. While this is not
94
+ * mandatory, an input should always have a label. If not using this property
95
+ * you can bind a custom label to the input by using an id.
96
+ */
97
+ label?: string | undefined;
86
98
  } & import("react").RefAttributes<HTMLInputElement>>;
87
99
  //# sourceMappingURL=slider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../src/components/slider/slider.tsx"],"names":[],"mappings":"AAiBA,OAAO,EACO,mBAAmB,EAChC,MAAM,OAAO,CAAC;AAEf,OAAO,EACU,WAAW,EAC3B,MAAM,cAAc,CAAC;AAItB,oBAAY,WAAW,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAChE;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAChC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACjC,CAAA;AAED,eAAO,MAAM,MAAM;IA1CjB;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;;OAGG;uBACe,MAAM,KAAK,IAAI;IACjC;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;OAEG;;oDA0DH,CAAC"}
1
+ {"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../src/components/slider/slider.tsx"],"names":[],"mappings":"AAiBA,OAAO,EACO,mBAAmB,EAChC,MAAM,OAAO,CAAC;AAGf,OAAO,EACU,WAAW,EAC3B,MAAM,cAAc,CAAC;AAItB,oBAAY,WAAW,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAChE;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAChC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,eAAO,MAAM,MAAM;IAhDjB;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;;OAGG;uBACe,MAAM,KAAK,IAAI;IACjC;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;;;OAIG;;oDAqFH,CAAC"}
@@ -15,16 +15,19 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
15
  * limitations under the License.
16
16
  */
17
17
  import clsx from 'clsx';
18
- import { forwardRef, useCallback, useState, } from 'react';
18
+ import { forwardRef, useCallback, useMemo, useState, } from 'react';
19
+ import { useUIDSeed } from 'react-uid';
19
20
  import { Stack, Symbol, Text, Textfield, } from '../..';
20
21
  import * as styles from './slider.module.css';
21
- export const Slider = forwardRef(({ min = 0, max = 100, step, onInput, className, defaultValue = 0, dimension = 'regular', showValues, iconMin, iconMax, ...otherProps }, forwardedRef) => {
22
+ export const Slider = forwardRef(({ min = 0, max = 100, step, onInput, className, defaultValue = 0, dimension = 'regular', showValues, iconMin, iconMax, disabled, label, id, ...otherProps }, forwardedRef) => {
22
23
  const [value, setValue] = useState(defaultValue);
23
24
  const isSmall = dimension === 'small';
24
25
  const handleInput = useCallback(({ currentTarget }) => {
25
26
  onInput?.(currentTarget.valueAsNumber);
26
27
  setValue(currentTarget.valueAsNumber);
27
28
  }, [onInput]);
28
- return (_jsxs(Stack, { direction: "row", vAlign: "center", columnGap: 8, className: clsx(styles.Slider, className), "data-slider-dimension": dimension, children: [showValues && _jsx(Text, { as: "span", size: isSmall ? 14 : 16, weight: "bold", textAlign: "end", className: styles.Value, children: min }), (iconMin && !showValues) && _jsx(Symbol, { source: iconMin, dimension: isSmall ? 16 : 24 }), _jsx("input", { ref: forwardedRef, className: styles.Input, type: "range", min: min, max: max, defaultValue: value, "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": value, step: step, onInput: handleInput, ...otherProps }), showValues && _jsx(Text, { as: "span", size: isSmall ? 14 : 16, weight: "bold", className: styles.Value, children: max }), showValues && _jsx(Textfield, { readOnly: true, dimension: "small", size: String(max).length, value: value, className: styles.CurrentValue }), (iconMax && !showValues) && _jsx(Symbol, { source: iconMax, dimension: isSmall ? 16 : 24 })] }));
29
+ const seedID = useUIDSeed();
30
+ const fieldID = useMemo(() => id ?? seedID('slider'), [id, seedID]);
31
+ return (_jsxs(Stack, { direction: "column", rowGap: 8, children: [label && _jsx(Text, { as: "label", size: isSmall ? 14 : 16, className: styles.Label, "aria-disabled": disabled, htmlFor: fieldID, children: label }), _jsxs(Stack, { direction: "row", vAlign: "center", columnGap: 8, className: clsx(styles.Slider, className), "data-slider-dimension": dimension, children: [showValues && _jsx(Text, { as: "span", size: isSmall ? 14 : 16, weight: "bold", textAlign: "end", className: styles.Value, "aria-disabled": disabled, children: min }), (iconMin && !showValues) && (_jsx(Symbol, { source: iconMin, dimension: isSmall ? 16 : 24, className: styles.Icon, "aria-disabled": disabled })), _jsx("input", { ref: forwardedRef, className: styles.Input, type: "range", min: min, max: max, defaultValue: value, "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": value, "aria-disabled": disabled, step: step, onInput: handleInput, disabled: disabled, id: fieldID, ...otherProps }), showValues && _jsx(Text, { as: "span", size: isSmall ? 14 : 16, weight: "bold", className: styles.Value, "aria-disabled": disabled, children: max }), showValues && _jsx(Textfield, { readOnly: true, dimension: "small", size: String(max).length, value: value, disabled: disabled }), (iconMax && !showValues) && (_jsx(Symbol, { source: iconMax, dimension: isSmall ? 16 : 24, className: styles.Icon, "aria-disabled": disabled }))] })] }));
29
32
  });
30
33
  Slider.displayName = 'Slider';
@@ -1 +1 @@
1
- @layer components{.Slider svg{flex-shrink:0}.Input{--track-color:var(--global-vibrancy-background);--progress-color:var(--dimmed-3);--thumb-size:24px;--progress-direction:calc(-9999px - var(--thumb-size)/2);appearance:none;background:transparent;border-radius:100px;height:var(--thumb-size);overflow:hidden;width:100%}[dir=rtl] .Input{--progress-direction:calc(9999px + var(--thumb-size)/2)}.Slider[data-slider-dimension=small] .Input{--thumb-size:16px}.Input::-webkit-slider-runnable-track{background:var(--track-color);cursor:pointer;height:var(--thumb-size);-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;width:100%}.Input::-moz-range-track{background:var(--track-color);cursor:pointer;height:var(--thumb-size);-moz-transition:background-color .2s ease-out;transition:background-color .2s ease-out;width:100%}.Input::-moz-focus-outer{border:0}.Input::-webkit-slider-thumb{appearance:none;background-color:var(--dimmed-7);border:0;border-radius:100%;box-shadow:var(--progress-direction) 0 0 9999px var(--progress-color);height:var(--thumb-size);outline-offset:-2px;-webkit-transition:box-shadow .1s ease-out,background-color .1s ease-out;transition:box-shadow .1s ease-out,background-color .1s ease-out;width:var(--thumb-size)}.Input::-webkit-slider-thumb:active,.Input::-webkit-slider-thumb:focus{background-color:var(--dimmed-6)}.Input::-moz-range-thumb{appearance:none;background-color:var(--dimmed-7);border:0;border-radius:100%;box-shadow:var(--progress-direction) 0 0 9999px var(--progress-color);height:var(--thumb-size);outline-offset:-2px;-moz-transition:box-shadow .1s ease-out,background-color .1s ease-out;transition:box-shadow .1s ease-out,background-color .1s ease-out;width:var(--thumb-size)}.Input::-moz-range-thumb:active,.Input::-moz-range-thumb:focus{background-color:var(--dimmed-6)}.Input:active::-webkit-slider-thumb{background-color:var(--dimmed-7);box-shadow:var(--progress-direction) 0 0 9999px var(--progress-color);cursor:grabbing}.Input:active::-moz-range-thumb{background-color:var(--dimmed-7);box-shadow:var(--progress-direction) 0 0 9999px var(--progress-color);cursor:grabbing}.Input:disabled::-webkit-slider-runnable-track{background:var(--global-disabled-background);cursor:not-allowed}.Input:disabled::-moz-range-track{background:var(--global-disabled-background);cursor:not-allowed}.Input:disabled::-webkit-slider-thumb{background:none var(--global-disabled-foreground);box-shadow:var(--progress-direction) 0 0 9999px transparent;cursor:not-allowed}.Input:disabled::-moz-range-thumb{background:none var(--global-disabled-foreground);box-shadow:var(--progress-direction) 0 0 9999px transparent;cursor:not-allowed}.CurrentValue,.Value{flex-shrink:0}}
1
+ @layer components{.Slider svg{flex-shrink:0}.Input{--track-color:var(--global-vibrancy-background);--progress-color:var(--dimmed-3);--thumb-size:24px;--progress-direction:calc(-9999px - var(--thumb-size)/2);appearance:none;background:transparent;border-radius:100px;height:var(--thumb-size);overflow:hidden;width:100%}[dir=rtl] .Input{--progress-direction:calc(9999px + var(--thumb-size)/2)}.Slider[data-slider-dimension=small] .Input{--thumb-size:16px}.Input::-webkit-slider-runnable-track{background:var(--track-color);cursor:pointer;height:var(--thumb-size);-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;width:100%}.Input::-moz-range-track{background:var(--track-color);cursor:pointer;height:var(--thumb-size);-moz-transition:background-color .2s ease-out;transition:background-color .2s ease-out;width:100%}.Input::-moz-focus-outer{border:0}.Input::-webkit-slider-thumb{appearance:none;background-color:var(--dimmed-7);border:0;border-radius:100%;box-shadow:var(--progress-direction) 0 0 9999px var(--progress-color);height:var(--thumb-size);outline-offset:-2px;-webkit-transition:box-shadow .1s ease-out,background-color .1s ease-out;transition:box-shadow .1s ease-out,background-color .1s ease-out;width:var(--thumb-size)}.Input::-webkit-slider-thumb:active,.Input::-webkit-slider-thumb:focus{background-color:var(--dimmed-6)}.Input::-moz-range-thumb{appearance:none;background-color:var(--dimmed-7);border:0;border-radius:100%;box-shadow:var(--progress-direction) 0 0 9999px var(--progress-color);height:var(--thumb-size);outline-offset:-2px;-moz-transition:box-shadow .1s ease-out,background-color .1s ease-out;transition:box-shadow .1s ease-out,background-color .1s ease-out;width:var(--thumb-size)}.Input::-moz-range-thumb:active,.Input::-moz-range-thumb:focus{background-color:var(--dimmed-6)}.Input:active::-webkit-slider-thumb{background-color:var(--dimmed-7);box-shadow:var(--progress-direction) 0 0 9999px var(--progress-color);cursor:grabbing}.Input:active::-moz-range-thumb{background-color:var(--dimmed-7);box-shadow:var(--progress-direction) 0 0 9999px var(--progress-color);cursor:grabbing}.Input:disabled::-webkit-slider-runnable-track{background:var(--global-disabled-background);cursor:not-allowed}.Input:disabled::-moz-range-track{background:var(--global-disabled-background);cursor:not-allowed}.Input:disabled::-webkit-slider-thumb{background:none var(--global-disabled-foreground);box-shadow:var(--progress-direction) 0 0 9999px transparent;cursor:not-allowed}.Input:disabled::-moz-range-thumb{background:none var(--global-disabled-foreground);box-shadow:var(--progress-direction) 0 0 9999px transparent;cursor:not-allowed}.Value{flex-shrink:0}.Value[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}.CurrentValue{flex-shrink:0}.Icon[aria-disabled=true],.Label[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}}
@@ -13,6 +13,7 @@ export declare const Default: ComponentStory<React.ForwardRefExoticComponent<Rea
13
13
  iconMin?: import("packages/symbols/dist").SymbolNames | React.ReactElement<HTMLOrSVGElement, string | React.JSXElementConstructor<any>> | undefined;
14
14
  iconMax?: import("packages/symbols/dist").SymbolNames | React.ReactElement<HTMLOrSVGElement, string | React.JSXElementConstructor<any>> | undefined;
15
15
  dimension?: "small" | "regular" | undefined;
16
+ label?: string | undefined;
16
17
  } & React.RefAttributes<HTMLInputElement>>>;
17
18
  export declare const WithValues: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
18
19
  min?: number | undefined;
@@ -24,6 +25,7 @@ export declare const WithValues: ComponentStory<React.ForwardRefExoticComponent<
24
25
  iconMin?: import("packages/symbols/dist").SymbolNames | React.ReactElement<HTMLOrSVGElement, string | React.JSXElementConstructor<any>> | undefined;
25
26
  iconMax?: import("packages/symbols/dist").SymbolNames | React.ReactElement<HTMLOrSVGElement, string | React.JSXElementConstructor<any>> | undefined;
26
27
  dimension?: "small" | "regular" | undefined;
28
+ label?: string | undefined;
27
29
  } & React.RefAttributes<HTMLInputElement>>>;
28
30
  export declare const WithIcons: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
29
31
  min?: number | undefined;
@@ -35,5 +37,18 @@ export declare const WithIcons: ComponentStory<React.ForwardRefExoticComponent<R
35
37
  iconMin?: import("packages/symbols/dist").SymbolNames | React.ReactElement<HTMLOrSVGElement, string | React.JSXElementConstructor<any>> | undefined;
36
38
  iconMax?: import("packages/symbols/dist").SymbolNames | React.ReactElement<HTMLOrSVGElement, string | React.JSXElementConstructor<any>> | undefined;
37
39
  dimension?: "small" | "regular" | undefined;
40
+ label?: string | undefined;
41
+ } & React.RefAttributes<HTMLInputElement>>>;
42
+ export declare const WithLabel: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
43
+ min?: number | undefined;
44
+ max?: number | undefined;
45
+ step?: number | undefined;
46
+ onInput?: ((value: number) => void) | undefined;
47
+ defaultValue?: number | undefined;
48
+ showValues?: boolean | undefined;
49
+ iconMin?: import("packages/symbols/dist").SymbolNames | React.ReactElement<HTMLOrSVGElement, string | React.JSXElementConstructor<any>> | undefined;
50
+ iconMax?: import("packages/symbols/dist").SymbolNames | React.ReactElement<HTMLOrSVGElement, string | React.JSXElementConstructor<any>> | undefined;
51
+ dimension?: "small" | "regular" | undefined;
52
+ label?: string | undefined;
38
53
  } & React.RefAttributes<HTMLInputElement>>>;
39
54
  //# sourceMappingURL=slider.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"slider.stories.d.ts","sourceRoot":"","sources":["../../../src/components/slider/slider.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,MAAM,CAkBvC,CAAC;AAEF,eAAe,KAAK,CAAC;AAIrB,eAAO,MAAM,OAAO;;;;;;;;;;2CAAoB,CAAC;AACzC,eAAO,MAAM,UAAU;;;;;;;;;;2CAAoB,CAAC;AAI5C,eAAO,MAAM,SAAS;;;;;;;;;;2CAAoB,CAAC"}
1
+ {"version":3,"file":"slider.stories.d.ts","sourceRoot":"","sources":["../../../src/components/slider/slider.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,MAAM,CAkBvC,CAAC;AAEF,eAAe,KAAK,CAAC;AAIrB,eAAO,MAAM,OAAO;;;;;;;;;;;2CAAoB,CAAC;AACzC,eAAO,MAAM,UAAU;;;;;;;;;;;2CAAoB,CAAC;AAI5C,eAAO,MAAM,SAAS;;;;;;;;;;;2CAAoB,CAAC;AAK3C,eAAO,MAAM,SAAS;;;;;;;;;;;2CAAoB,CAAC"}
@@ -31,3 +31,10 @@ WithIcons.args = {
31
31
  iconMin: 'moon',
32
32
  iconMax: 'sun-bright',
33
33
  };
34
+ export const WithLabel = Template.bind({});
35
+ WithLabel.args = {
36
+ iconMin: 'moon',
37
+ iconMax: 'sun-bright',
38
+ label: 'Label',
39
+ disabled: false,
40
+ };
@@ -29,7 +29,7 @@ export const Textfield = forwardRef(({ children, className, disabled = false, ic
29
29
  disabled,
30
30
  onChange,
31
31
  };
32
- return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(styles.Textfield, className), "data-textfield-has-icon": isPassword || Boolean(icon), "data-textfield-icon-position": iconPosition, "data-textfield-dimension": dimension, "data-textfield-invalid": invalid, "data-textfield-fullwidth": fullWidth, "aria-disabled": disabled, hAlign: "stretch", vAlign: "start", tabIndex: disabled ? 0 : undefined, style: style, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor: fieldID, children: label }), _jsxs("div", { className: styles.FieldContainer, children: [textarea
32
+ return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(styles.Textfield, className), "data-textfield-has-icon": isPassword || Boolean(icon), "data-textfield-icon-position": iconPosition, "data-textfield-dimension": dimension, "data-textfield-invalid": invalid, "data-textfield-fullwidth": fullWidth, "aria-disabled": disabled, hAlign: "stretch", vAlign: "start", tabIndex: disabled ? 0 : undefined, style: style, children: [label && _jsx(Text, { as: "label", "aria-disabled": disabled, className: styles.Label, size: dimension === 'small' ? 14 : 16, htmlFor: fieldID, children: label }), _jsxs("div", { className: styles.FieldContainer, children: [textarea
33
33
  ? (_jsx(BaseField, { ref: forwardedRef, as: "textarea", id: fieldID, ...commonProps, ...otherProps }))
34
34
  : (_jsx(BaseField, { className: styles.InputField, id: fieldID, ref: forwardedRef, type: isPasswordVisible ? 'text' : type, spellCheck: isPassword ? false : undefined, ...commonProps, ...otherProps })), isPassword && (_jsx(IconButton, { className: styles.IconButton, dimension: actionSizes[dimension], onClick: handlePasswordVisibility, kind: "flat", "aria-label": "Reveal password", icon: isPasswordVisible ? 'eye-slash' : 'eye' })), !textarea && icon && !isPassword && (_jsx(Symbol, { className: styles.Icon, source: icon, dimension: iconSizes[dimension] }))] })] }));
35
35
  });
@@ -1 +1 @@
1
- @layer components{.Textfield{appearance:none;padding:0;position:relative}.Textfield[data-textfield-dimension=small]{--field-height:1.50rem;--field-padding:0.33rem;--font-size:0.88rem}.Textfield[data-textfield-dimension=regular]{--field-height:2.50rem;--field-padding:1.00rem;--font-size:1.00rem}.Textfield[data-textfield-dimension=big]{--field-height:3.00rem;--field-padding:1.00rem;--font-size:1.13rem}.Textfield[data-textfield-fullwidth=true]{inline-size:100%}.FieldContainer{position:relative}.InputField{--factor:4}[data-textfield-has-icon=true][data-textfield-icon-position=right] .InputField{padding:0 calc(var(--field-padding)*var(--factor)) 0 var(--field-padding)}[data-textfield-has-icon=true][data-textfield-icon-position=left] .InputField{padding:0 var(--field-padding) 0 calc(var(--field-padding)*var(--factor))}[data-textfield-dimension*=big] .InputField,[data-textfield-dimension*=regular] .InputField{--factor:3}.Icon{border-radius:.25rem;pointer-events:none;position:absolute;top:50%;transform:translateY(-50%)}[data-textfield-icon-position=left] .Icon{left:var(--field-padding);right:auto}[data-textfield-icon-position=right] .Icon{left:auto;right:var(--field-padding)}.Textfield[data-textfield-invalid=true] .Icon{fill:var(--highlight-red-foreground)}.InputField:invalid+.Icon{fill:var(--highlight-red-foreground)}}@layer overrides{.IconButton{--x:25%;outline-offset:-.25em;position:absolute;top:50%;transform:translateY(-50%) translateX(var(--x))}.IconButton[data-button-kind=flat]:is(:hover,:active,:focus,[data-button-disabled=true]){-webkit-backdrop-filter:none;backdrop-filter:none;background-color:transparent}[data-textfield-icon-position=left] .IconButton{--x:-19%;left:var(--field-padding);right:auto}[data-textfield-icon-position=right] .IconButton{left:auto;right:var(--field-padding)}.Textfield[data-textfield-invalid=true] .IconButton{color:var(--highlight-red-foreground)}}
1
+ @layer components{.Textfield{appearance:none;padding:0;position:relative}.Textfield[data-textfield-dimension=small]{--field-height:1.50rem;--field-padding:0.33rem;--font-size:0.88rem}.Textfield[data-textfield-dimension=regular]{--field-height:2.50rem;--field-padding:1.00rem;--font-size:1.00rem}.Textfield[data-textfield-dimension=big]{--field-height:3.00rem;--field-padding:1.00rem;--font-size:1.13rem}.Textfield[data-textfield-fullwidth=true]{inline-size:100%}.FieldContainer{position:relative}.InputField{--factor:4}[data-textfield-has-icon=true][data-textfield-icon-position=right] .InputField{padding:0 calc(var(--field-padding)*var(--factor)) 0 var(--field-padding)}[data-textfield-has-icon=true][data-textfield-icon-position=left] .InputField{padding:0 var(--field-padding) 0 calc(var(--field-padding)*var(--factor))}[data-textfield-dimension*=big] .InputField,[data-textfield-dimension*=regular] .InputField{--factor:3}.Icon{border-radius:.25rem;pointer-events:none;position:absolute;top:50%;transform:translateY(-50%)}[data-textfield-icon-position=left] .Icon{left:var(--field-padding);right:auto}[data-textfield-icon-position=right] .Icon{left:auto;right:var(--field-padding)}.Textfield[data-textfield-invalid=true] .Icon{fill:var(--highlight-red-foreground)}.InputField:invalid+.Icon{fill:var(--highlight-red-foreground)}.Label[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}}@layer overrides{.IconButton{--x:25%;outline-offset:-.25em;position:absolute;top:50%;transform:translateY(-50%) translateX(var(--x))}.IconButton[data-button-kind=flat]:is(:hover,:active,:focus,[data-button-disabled=true]){-webkit-backdrop-filter:none;backdrop-filter:none;background-color:transparent}[data-textfield-icon-position=left] .IconButton{--x:-19%;left:var(--field-padding);right:auto}[data-textfield-icon-position=right] .IconButton{left:auto;right:var(--field-padding)}.Textfield[data-textfield-invalid=true] .IconButton{color:var(--highlight-red-foreground)}}
@@ -1 +1 @@
1
- {"version":3,"file":"textfield.stories.d.ts","sourceRoot":"","sources":["../../../src/components/textfield/textfield.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,SAAS,CAoC1C,CAAC;AAEF,eAAe,KAAK,CAAC;AA4BrB,eAAO,MAAM,MAAM,+LAA0B,CAAC;AAY9C,eAAO,MAAM,KAAK,+LAA4B,CAAC;AAgB/C,eAAO,MAAM,QAAQ,+LAA4B,CAAC;AAalD,eAAO,MAAM,QAAQ,+LAA0B,CAAC"}
1
+ {"version":3,"file":"textfield.stories.d.ts","sourceRoot":"","sources":["../../../src/components/textfield/textfield.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,SAAS,CAoC1C,CAAC;AAEF,eAAe,KAAK,CAAC;AA4BrB,eAAO,MAAM,MAAM,+LAA0B,CAAC;AAa9C,eAAO,MAAM,KAAK,+LAA4B,CAAC;AAgB/C,eAAO,MAAM,QAAQ,+LAA4B,CAAC;AAalD,eAAO,MAAM,QAAQ,+LAA0B,CAAC"}
@@ -39,11 +39,12 @@ const story = {
39
39
  },
40
40
  };
41
41
  export default story;
42
- const SingleTemplate = args => (_jsxs(Stack, { rowGap: 24, children: [_jsx(Textfield, { ...args, size: 4, label: "Empty", placeholder: "Placeholder" }), _jsx(Textfield, { ...args, size: 4, label: "Empty", placeholder: "Placeholder" }), _jsx(Textfield, { ...args, size: 4, label: "Empty", placeholder: "Placeholder" }), _jsx(Textfield, { ...args, type: "password", label: "Password", defaultValue: "123123kl\u00F2asj", placeholder: "Placeholder" })] }));
42
+ const SingleTemplate = args => (_jsxs(Stack, { rowGap: 24, children: [_jsx(Textfield, { ...args, size: 4, placeholder: "Placeholder" }), _jsx(Textfield, { ...args, size: 4, placeholder: "Placeholder" }), _jsx(Textfield, { ...args, size: 4, placeholder: "Placeholder" }), _jsx(Textfield, { ...args, type: "password", label: "Password", defaultValue: "123123kl\u00F2asj", placeholder: "Placeholder" })] }));
43
43
  const MultipleTemplate = args => (_jsxs(Stack, { rowGap: 24, children: [_jsx(Textfield, { ...args, label: "Filled", defaultValue: "Sample value" }), _jsx(Textfield, { ...args, label: "Filled read only", defaultValue: "Sample value", readOnly: true }), _jsx(Textfield, { ...args, label: "Empty disbled", placeholder: "Placeholder", disabled: true }), _jsx(Textfield, { ...args, label: "Filled disabled", defaultValue: "Sample value", disabled: true }), _jsx(Textfield, { ...args, type: "password", label: "Type password", defaultValue: "912435jh345" }), _jsx(Textfield, { ...args, type: "number", label: "Type number", defaultValue: 100 }), _jsx(Textfield, { ...args, type: "search", label: "Type search" }), _jsx(Textfield, { ...args, type: "date", label: "Type date" }), _jsx(Textfield, { ...args, type: "time", label: "Type time" }), _jsx(Textfield, { ...args, type: "month", label: "Type month" }), _jsx(Textfield, { ...args, type: "week", label: "Type week" }), _jsx(Textfield, { ...args, type: "datetime-local", label: "Type datetime-local" })] }));
44
44
  export const Single = SingleTemplate.bind({});
45
45
  Single.args = {
46
46
  disabled: false,
47
+ label: 'Empty',
47
48
  };
48
49
  Single.argTypes = {
49
50
  textarea: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
- "version": "10.16.0",
3
+ "version": "10.17.0",
4
4
  "description": "UI components from Wonderflow's Wanda design system",
5
5
  "author": "Wonderflow",
6
6
  "license": "Apache-2.0",
@@ -73,8 +73,8 @@
73
73
  "@types/react": "17.0.43",
74
74
  "@types/react-dom": "17.0.14",
75
75
  "@types/react-table": "7.7.12",
76
- "@wonderflow/config": "10.16.0",
77
- "@wonderflow/tokens": "10.16.0",
76
+ "@wonderflow/config": "10.17.0",
77
+ "@wonderflow/tokens": "10.17.0",
78
78
  "babel-loader": "8.2.5",
79
79
  "cpy-cli": "3.1.1",
80
80
  "postcss": "8.4.17",