@wonderflow/react-components 11.0.5 → 11.0.7

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 (34) hide show
  1. package/dist/components/disclosure/disclosure.d.ts.map +1 -1
  2. package/dist/components/disclosure/disclosure.js +3 -2
  3. package/dist/components/disclosure/disclosure.stories.js +1 -1
  4. package/dist/components/modal/modal.stories.d.ts.map +1 -1
  5. package/dist/components/modal/modal.stories.js +1 -1
  6. package/dist/components/selection-controls/checkbox.d.ts.map +1 -1
  7. package/dist/components/selection-controls/checkbox.js +9 -1
  8. package/dist/components/selection-controls/checkbox.stories.d.ts +7 -0
  9. package/dist/components/selection-controls/checkbox.stories.d.ts.map +1 -1
  10. package/dist/components/selection-controls/checkbox.stories.js +8 -0
  11. package/dist/components/selection-controls/radio.d.ts.map +1 -1
  12. package/dist/components/selection-controls/radio.js +10 -2
  13. package/dist/components/selection-controls/radio.stories.d.ts +6 -0
  14. package/dist/components/selection-controls/radio.stories.d.ts.map +1 -1
  15. package/dist/components/selection-controls/radio.stories.js +8 -0
  16. package/dist/components/selection-controls/selection-controls.module.css +1 -1
  17. package/dist/components/selection-controls/toggle.d.ts.map +1 -1
  18. package/dist/components/selection-controls/toggle.js +10 -2
  19. package/dist/components/selection-controls/toggle.stories.d.ts +7 -0
  20. package/dist/components/selection-controls/toggle.stories.d.ts.map +1 -1
  21. package/dist/components/selection-controls/toggle.stories.js +8 -0
  22. package/dist/examples/shell.stories.d.ts.map +1 -1
  23. package/dist/examples/shell.stories.js +6 -6
  24. package/dist/hooks/useBreakpoints.d.ts.map +1 -1
  25. package/dist/hooks/useBreakpoints.js +7 -5
  26. package/dist/providers/responsive.d.ts.map +1 -1
  27. package/dist/providers/responsive.js +7 -5
  28. package/dist/utils/conversions.d.ts +2 -0
  29. package/dist/utils/conversions.d.ts.map +1 -0
  30. package/dist/utils/conversions.js +24 -0
  31. package/dist/utils/convertions.test.d.ts +2 -0
  32. package/dist/utils/convertions.test.d.ts.map +1 -0
  33. package/dist/utils/convertions.test.js +13 -0
  34. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"disclosure.d.ts","sourceRoot":"","sources":["../../../src/components/disclosure/disclosure.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAEL,qBAAqB,EACrB,SAAS,EACV,MAAM,OAAO,CAAC;AASf,oBAAY,eAAe,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,GAAG;IACxE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;IACxC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,eAAO,MAAM,UAAU;IAnCrB;;OAEG;;IAEH;;;OAGG;aACM,SAAS;IAClB;;;;OAIG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;;OAGG;;sDA4GH,CAAC"}
1
+ {"version":3,"file":"disclosure.d.ts","sourceRoot":"","sources":["../../../src/components/disclosure/disclosure.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAEL,qBAAqB,EACrB,SAAS,EACV,MAAM,OAAO,CAAC;AASf,oBAAY,eAAe,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,GAAG;IACxE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;IACxC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,eAAO,MAAM,UAAU;IAnCrB;;OAEG;;IAEH;;;OAGG;aACM,SAAS;IAClB;;;;OAIG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;;OAGG;;sDA8GH,CAAC"}
@@ -32,8 +32,9 @@ export const Disclosure = forwardRef(({ children, open = false, padding = true,
32
32
  const handleOpen = useCallback(() => () => {
33
33
  if (ref.current && expandable)
34
34
  setIsOpen(open || ref.current.open);
35
- if (expandable && open === undefined)
35
+ if (expandable) {
36
36
  onToggle?.(open || ref.current.open);
37
+ }
37
38
  }, [expandable, onToggle, open]);
38
39
  const dynamicStyle = {
39
40
  '--max-height': contentMaxHeight,
@@ -53,7 +54,7 @@ export const Disclosure = forwardRef(({ children, open = false, padding = true,
53
54
  },
54
55
  };
55
56
  return (_jsxs("details", { style: { ...dynamicStyle, ...style }, className: clsx(styles.Disclosure, className), "data-testid": "Disclosure", "data-disclosure-icon-position": iconPosition, "data-disclosure-dimension": dimension, "data-disclosure-expandable": expandable, onToggle: handleOpen(), ref: ref, open: isOpen, "aria-controls": seedID('disclosure-content'), ...otherProps, children: [_jsxs(Text, { as: "summary", responsive: false, className: styles.Summary, id: seedID('disclosure'), size: sizes[dimension].summary, weight: "bold", "aria-expanded": isOpen, children: [summary, expandable && (_jsx(Symbol, { className: styles.ExpandIcon, source: "chevron-right", dimension: sizes[dimension].icon }))] }), _jsx(LazyMotion, { features: domMax, children: _jsx(m.div, { id: seedID('disclosure-content'), className: styles.Content, "data-disclosure-padding": padding, "data-disclosure-height": Boolean(contentMaxHeight), animate: isOpen ? {
56
- y: 5, opacity: 1, height: 'auto', overflow: 'unset',
57
+ y: 5, opacity: 1, height: 'auto', overflow: 'initial',
57
58
  } : {
58
59
  y: 0, opacity: 0, height: 0, overflow: 'hidden',
59
60
  }, transition: { ease: 'easeOut', duration: 0.2, delay: 0 }, initial: false, role: "region", "aria-labelledby": seedID('disclosure'), children: children }) })] }));
@@ -31,7 +31,7 @@ const story = {
31
31
  },
32
32
  };
33
33
  export default story;
34
- const Template = args => (_jsxs(Disclosure, { ...args, children: [_jsxs(Autocomplete, { style: { maxWidth: '300px', padding: '0.5rem 0' }, icon: "magnifying-glass", label: "Fruits", children: [_jsx(Autocomplete.Option, { value: "apple", children: "Apple" }), _jsx(Autocomplete.Option, { value: "banana", decoration: _jsx(Chip, { dimension: "small", color: "green", children: "110 Cal" }), children: "Banana" }), _jsx(Autocomplete.Option, { value: "cherry", children: "Cherry" })] }), _jsxs("p", { children: ["Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus corporis nobis ipsum natus laudantium dolorem sapiente, sint adipisci at asperiores quia ex voluptatum veniam! Quos rerum natus eos excepturi atque!", ' ', _jsx(Popover, { trigger: _jsx(IconButton, { icon: "circle-info", dimension: "small", kind: "flat" }), children: _jsx(Menu, { style: { maxWidth: '300px' }, children: _jsx(MenuItem, { value: "1", children: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus corporis nobis ipsum natus laudantium dolorem sapiente, sint adipisci at asperiores quia ex voluptatum veniam! Quos rerum natus eos excepturi atque!" }) }) })] })] }));
34
+ const Template = args => (_jsxs(Disclosure, { ...args, children: [_jsxs(Autocomplete, { style: { maxWidth: '300px', padding: '0.5rem 0' }, icon: "magnifying-glass", label: "Fruits", children: [_jsx(Autocomplete.Option, { value: "apple", children: "Apple" }), _jsx(Autocomplete.Option, { value: "banana", decoration: _jsx(Chip, { dimension: "small", color: "green", children: "110 Cal" }), children: "Banana" }), _jsx(Autocomplete.Option, { value: "cherry", children: "Cherry" })] }), _jsxs("div", { children: ["Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus corporis nobis ipsum natus laudantium dolorem sapiente, sint adipisci at asperiores quia ex voluptatum veniam! Quos rerum natus eos excepturi atque!", ' ', _jsx(Popover, { trigger: _jsx(IconButton, { icon: "circle-info", dimension: "small", kind: "flat" }), children: _jsx(Menu, { style: { maxWidth: '300px' }, children: _jsx(MenuItem, { value: "1", children: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus corporis nobis ipsum natus laudantium dolorem sapiente, sint adipisci at asperiores quia ex voluptatum veniam! Quos rerum natus eos excepturi atque!" }) }) })] })] }));
35
35
  export const Default = Template.bind({});
36
36
  const NestedTemplate = args => (_jsxs(Disclosure, { ...args, children: [_jsxs(Autocomplete, { style: { maxWidth: '300px', padding: '0.5rem 0' }, icon: "magnifying-glass", label: "Fruits", children: [_jsx(Autocomplete.Option, { value: "apple", children: "Apple" }), _jsx(Autocomplete.Option, { value: "banana", decoration: _jsx(Chip, { dimension: "small", color: "green", children: "110 Cal" }), children: "Banana" }), _jsx(Autocomplete.Option, { value: "cherry", children: "Cherry" })] }), "Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus corporis nobis ipsum natus laudantium dolorem sapiente, sint adipisci at asperiores quia ex voluptatum veniam! Quos rerum natus eos excepturi atque!", _jsx(Disclosure, { summary: "Nested", children: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus corporis nobis ipsum natus laudantium dolorem sapiente, sint adipisci at asperiores quia ex voluptatum veniam! Quos rerum natus eos excepturi atque!" })] }));
37
37
  export const Nested = NestedTemplate.bind({});
@@ -1 +1 @@
1
- {"version":3,"file":"modal.stories.d.ts","sourceRoot":"","sources":["../../../src/components/modal/modal.stories.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQjE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAQhC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,KAAK,CAmCtC,CAAC;AAEF,eAAe,KAAK,CAAC;AAkBrB,eAAO,MAAM,OAAO;;;;EAA2B,CAAC;AAEhD,eAAO,MAAM,OAAO;;;;EAA2B,CAAC;AAMhD,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AAOvD,eAAO,MAAM,YAAY;;;;EAA2B,CAAC;AAWrD,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AAevD,eAAO,MAAM,eAAe;;;;EAA2B,CAAC;AA8BxD,eAAO,MAAM,eAAe;;;;EAA2B,CAAC;AAgBxD,eAAO,MAAM,SAAS;;;;EAA2B,CAAC;AA+BlD,eAAO,MAAM,SAAS;;;;EAA2B,CAAC;AAoClD,eAAO,MAAM,QAAQ;;;;EAA2B,CAAC;AA4DjD,eAAO,MAAM,kBAAkB;;;;EAA2B,CAAC;AAS3D,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AAqBvD,eAAO,MAAM,YAAY;;;;EAA2B,CAAC;AA+CrD,eAAO,MAAM,MAAM;;;;EAA0B,CAAC"}
1
+ {"version":3,"file":"modal.stories.d.ts","sourceRoot":"","sources":["../../../src/components/modal/modal.stories.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQjE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAQhC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,KAAK,CAmCtC,CAAC;AAEF,eAAe,KAAK,CAAC;AAkBrB,eAAO,MAAM,OAAO;;;;EAA2B,CAAC;AAEhD,eAAO,MAAM,OAAO;;;;EAA2B,CAAC;AAMhD,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AAOvD,eAAO,MAAM,YAAY;;;;EAA2B,CAAC;AAWrD,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AAevD,eAAO,MAAM,eAAe;;;;EAA2B,CAAC;AA8BxD,eAAO,MAAM,eAAe;;;;EAA2B,CAAC;AAgBxD,eAAO,MAAM,SAAS;;;;EAA2B,CAAC;AAiClD,eAAO,MAAM,SAAS;;;;EAA2B,CAAC;AAoClD,eAAO,MAAM,QAAQ;;;;EAA2B,CAAC;AA4DjD,eAAO,MAAM,kBAAkB;;;;EAA2B,CAAC;AAS3D,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AAqBvD,eAAO,MAAM,YAAY;;;;EAA2B,CAAC;AA+CrD,eAAO,MAAM,MAAM;;;;EAA0B,CAAC"}
@@ -102,7 +102,7 @@ WithAList.args = {
102
102
  primaryAction: _jsx(Button, { children: "Primary" }),
103
103
  secondaryAction: _jsx(Button, { children: "Secondary" }),
104
104
  };
105
- const withImageContent = (_jsxs(Stack, { hAlign: "center", vAlign: "center", vPadding: 16, children: [_jsx("img", { src: "https://wonderimages.gumlet.io/placeholders/illustration.png?format=webp&q=100", alt: "modal illustartion", width: "400px", height: "auto" }), _jsx(Title, { level: "5", children: "Title goes here" }), _jsx(Text, { size: 14, children: "Subtitle goes here" })] }));
105
+ const withImageContent = (_jsxs(Stack, { hAlign: "center", vAlign: "center", rowGap: 24, children: [_jsx("img", { src: "https://wonderimages.gumlet.io/placeholders/illustration.png?format=webp&q=100", alt: "modal illustartion", width: "400px", height: "auto" }), _jsxs(Stack, { hAlign: "center", children: [_jsx(Title, { level: "5", children: "Title goes here" }), _jsx(Text, { size: 14, children: "Subtitle goes here" })] })] }));
106
106
  export const WithImage = DefaultTemplate.bind({});
107
107
  WithImage.args = {
108
108
  title: undefined,
@@ -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;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;oDAqEzD,CAAC"}
1
+ {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/checkbox.tsx"],"names":[],"mappings":"AAmBA,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;AAOD,eAAO,MAAM,QAAQ;IA/BnB;;OAEG;;IAEH;;;OAGG;;IAEH;;;;OAIG;;IAEH;;OAEG;;IAEH;;;OAGG;wBACgB,YAAY,gBAAgB,CAAC,KAAK,IAAI;oDAkFzD,CAAC"}
@@ -14,21 +14,29 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { useSize } from 'ahooks';
17
18
  import clsx from 'clsx';
18
19
  import { domAnimation, LazyMotion, m } from 'framer-motion';
19
20
  import { forwardRef, useEffect, useMemo, useRef, } from 'react';
20
21
  import { useUIDSeed } from 'react-uid';
21
22
  import { Stack, Text } from '../..';
22
23
  import * as styles from './selection-controls.module.css';
24
+ const inputSize = {
25
+ regular: 24,
26
+ small: 16,
27
+ };
23
28
  export const Checkbox = forwardRef(({ className, disabled, dimension = 'regular', onChange, indeterminate, id, label, hidden, ...otherProps }, forwardedRef) => {
24
29
  const ref = useRef(forwardedRef);
25
30
  const seedID = useUIDSeed();
26
31
  const fieldID = useMemo(() => id ?? seedID('checkbox'), [id, seedID]);
32
+ const refWrapper = useRef(null);
33
+ const wrapper = useSize(refWrapper);
34
+ const isAlignCenter = useMemo(() => wrapper?.height === inputSize[dimension], [wrapper, dimension]);
27
35
  useEffect(() => {
28
36
  if (ref.current) {
29
37
  ref.current.indeterminate = indeterminate;
30
38
  }
31
39
  }, [indeterminate]);
32
- return (_jsxs(Stack, { as: "span", direction: "row", columnGap: 8, vAlign: "center", fill: false, wrap: true, children: [_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, id: fieldID, ...otherProps }) }) }), label && (_jsx(Text, { as: "label", "aria-disabled": disabled, className: styles.Label, htmlFor: fieldID, size: dimension === 'small' ? 14 : 16, title: otherProps?.title, children: label }))] }));
40
+ return (_jsxs(Stack, { as: "span", direction: "row", columnGap: 8, vAlign: isAlignCenter ? 'center' : 'start', fill: false, ref: refWrapper, "data-outer-element": "Wrapper", children: [_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, "data-inner-element": "Checkbox", onChange: onChange, className: styles.CheckboxInput, ref: ref, hidden: hidden, id: fieldID, ...otherProps }) }) }), label && (_jsx(Text, { as: "label", "aria-disabled": disabled, "data-inner-element": "Label", className: styles.Label, lineHeight: dimension === 'small' ? 'small' : 'large', htmlFor: fieldID, size: dimension === 'small' ? 14 : 16, title: otherProps?.title, children: label }))] }));
33
41
  });
34
42
  Checkbox.displayName = 'Checkbox';
@@ -38,4 +38,11 @@ export declare const withLabel: ComponentStory<React.ForwardRefExoticComponent<R
38
38
  dimension?: "small" | "regular" | undefined;
39
39
  onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
40
40
  } & React.RefAttributes<HTMLInputElement>>>;
41
+ export declare const withConstraint: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
42
+ disabled?: boolean | undefined;
43
+ indeterminate?: boolean | undefined;
44
+ label?: string | undefined;
45
+ dimension?: "small" | "regular" | undefined;
46
+ onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
47
+ } & React.RefAttributes<HTMLInputElement>>>;
41
48
  //# sourceMappingURL=checkbox.stories.d.ts.map
@@ -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;AAK/C,eAAO,MAAM,SAAS;;;;;;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;AAI1B,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;AAa3C,eAAO,MAAM,cAAc;;;;;;2CAA8B,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Card } from '../..';
2
3
  import { Checkbox } from './checkbox';
3
4
  const story = {
4
5
  title: 'Inputs/Checkbox',
@@ -38,3 +39,10 @@ withLabel.args = {
38
39
  disabled: false,
39
40
  label: 'Label',
40
41
  };
42
+ const ConstraintTemplate = args => (_jsx(Card, { dimmed: 0, bordered: true, style: { width: '300px' }, children: _jsx(Checkbox, { ...args }) }));
43
+ export const withConstraint = ConstraintTemplate.bind({});
44
+ withConstraint.args = {
45
+ defaultChecked: true,
46
+ disabled: false,
47
+ label: 'myVeryLongUsernameUnspacedLabel@wonderflow.ai',
48
+ };
@@ -1 +1 @@
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;oDA4DzD,CAAC"}
1
+ {"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/radio.tsx"],"names":[],"mappings":"AAmBA,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;AAOD,eAAO,MAAM,KAAK;IA1BhB;;OAEG;;IAEH;;;;OAIG;;IAEH;;OAEG;;IAEH;;;OAGG;wBACgB,YAAY,gBAAgB,CAAC,KAAK,IAAI;oDAyEzD,CAAC"}
@@ -14,15 +14,23 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { useSize } from 'ahooks';
17
18
  import clsx from 'clsx';
18
19
  import { domAnimation, LazyMotion, m } from 'framer-motion';
19
- import { forwardRef, useMemo, } from 'react';
20
+ import { forwardRef, useMemo, useRef, } from 'react';
20
21
  import { useUIDSeed } from 'react-uid';
21
22
  import { Stack, Text } from '../..';
22
23
  import * as styles from './selection-controls.module.css';
24
+ const inputSize = {
25
+ regular: 24,
26
+ small: 16,
27
+ };
23
28
  export const Radio = forwardRef(({ className, disabled, id, label, dimension = 'regular', onChange, hidden, ...otherProps }, forwardedRef) => {
24
29
  const seedID = useUIDSeed();
25
30
  const fieldID = useMemo(() => id ?? seedID('radio'), [id, seedID]);
26
- return (_jsxs(Stack, { as: "span", direction: "row", columnGap: 8, vAlign: "center", fill: false, wrap: true, children: [_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, id: fieldID, ...otherProps }) }) }), label && (_jsx(Text, { as: "label", "aria-disabled": disabled, className: styles.Label, size: dimension === 'small' ? 14 : 16, htmlFor: fieldID, title: otherProps?.title, children: label }))] }));
31
+ const refWrapper = useRef(null);
32
+ const wrapper = useSize(refWrapper);
33
+ const isAlignCenter = useMemo(() => wrapper?.height === inputSize[dimension], [wrapper, dimension]);
34
+ return (_jsxs(Stack, { as: "span", direction: "row", columnGap: 8, vAlign: isAlignCenter ? 'center' : 'start', fill: false, ref: refWrapper, "data-outer-element": "Wrapper", children: [_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, "data-inner-element": "Radio", onChange: onChange, className: styles.RadioInput, ref: forwardedRef, hidden: hidden, id: fieldID, ...otherProps }) }) }), label && (_jsx(Text, { as: "label", "aria-disabled": disabled, "data-inner-element": "Label", className: styles.Label, size: dimension === 'small' ? 14 : 16, lineHeight: dimension === 'small' ? 'small' : 'large', htmlFor: fieldID, title: otherProps?.title, children: label }))] }));
27
35
  });
28
36
  Radio.displayName = 'Radio';
@@ -27,4 +27,10 @@ export declare const withLabel: ComponentStory<React.ForwardRefExoticComponent<R
27
27
  dimension?: "small" | "regular" | undefined;
28
28
  onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
29
29
  } & React.RefAttributes<HTMLInputElement>>>;
30
+ export declare const withConstraint: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
31
+ disabled?: boolean | undefined;
32
+ label?: string | undefined;
33
+ dimension?: "small" | "regular" | undefined;
34
+ onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
35
+ } & React.RefAttributes<HTMLInputElement>>>;
30
36
  //# sourceMappingURL=radio.stories.d.ts.map
@@ -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;AAMjD,eAAO,MAAM,SAAS;;;;;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;AAI1B,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;AAa3C,eAAO,MAAM,cAAc;;;;;2CAA8B,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Card } from '../..';
2
3
  import { Radio } from './radio';
3
4
  const story = {
4
5
  title: 'Inputs/Radio',
@@ -34,3 +35,10 @@ withLabel.args = {
34
35
  disabled: false,
35
36
  label: 'Label',
36
37
  };
38
+ const ConstraintTemplate = args => (_jsx(Card, { dimmed: 0, bordered: true, style: { width: '300px' }, children: _jsx(Radio, { ...args }) }));
39
+ export const withConstraint = ConstraintTemplate.bind({});
40
+ withConstraint.args = {
41
+ defaultChecked: true,
42
+ disabled: false,
43
+ label: 'myVeryLongUsernameUnspacedLabel@wonderflow.ai',
44
+ };
@@ -1 +1 @@
1
- @layer components{.InputWrapper{cursor:none;display:inline-block;line-height:0}.InputWrapper:hover{cursor:pointer}.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);cursor:none;inline-size:var(--w);max-block-size:var(--h);max-inline-size:var(--w);position:relative}.CheckboxInput:hover{cursor:pointer}.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);box-shadow:none;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%)}.RadioInput:disabled{box-shadow:none}.RadioInput:indeterminate{background-color:var(--global-vibrancy-background);box-shadow:0 0 0 1px var(--global-background),inset 0 0 0 1px var(--dimmed-2)}.RadioInput:indeterminate:disabled{box-shadow:none}.RadioInput:indeterminate:after{block-size:0}.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{cursor:none}.Label:hover{cursor:pointer}.Label[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}}
1
+ @layer components{.InputWrapper{cursor:none;display:inline-block;line-height:0}.InputWrapper:hover{cursor:pointer}.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);cursor:none;inline-size:var(--w);max-block-size:var(--h);max-inline-size:var(--w);position:relative}.CheckboxInput:hover{cursor:pointer}.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);box-shadow:none;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%)}.RadioInput:disabled{box-shadow:none}.RadioInput:indeterminate{background-color:var(--global-vibrancy-background);box-shadow:0 0 0 1px var(--global-background),inset 0 0 0 1px var(--dimmed-2)}.RadioInput:indeterminate:disabled{box-shadow:none}.RadioInput:indeterminate:after{block-size:0}.Toggle{--w:44px;--h:24px;--p:2px;composes:RadioInput;border-radius:200px;color:var(--dimmed-7);min-width:var(--w)}.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;min-width:var(--w)}.Label{cursor:none;word-break:break-word}.Label:hover{cursor:pointer}.Label[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}}
@@ -1 +1 @@
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;IAEH,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;IAtBjB;;OAEG;;IAEH;;;;OAIG;;IAEH;;OAEG;;IAGH;;;OAGG;wBACgB,YAAY,gBAAgB,CAAC,KAAK,IAAI;oDAiDzD,CAAC"}
1
+ {"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../../src/components/selection-controls/toggle.tsx"],"names":[],"mappings":"AAkBA,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;AAOD,eAAO,MAAM,MAAM;IA1BjB;;OAEG;;IAEH;;;;OAIG;;IAEH;;OAEG;;IAEH;;;OAGG;wBACgB,YAAY,gBAAgB,CAAC,KAAK,IAAI;oDA8DzD,CAAC"}
@@ -14,14 +14,22 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { useSize } from 'ahooks';
17
18
  import clsx from 'clsx';
18
- import { forwardRef, useMemo, } from 'react';
19
+ import { forwardRef, useMemo, useRef, } from 'react';
19
20
  import { useUIDSeed } from 'react-uid';
20
21
  import { Stack, Text } from '../..';
21
22
  import * as styles from './selection-controls.module.css';
23
+ const inputSize = {
24
+ regular: 24,
25
+ small: 17,
26
+ };
22
27
  export const Toggle = forwardRef(({ className, disabled, id, label, dimension = 'regular', onChange, ...otherProps }, forwardedRef) => {
23
28
  const seedID = useUIDSeed();
24
29
  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, title: otherProps?.title, children: label }))] }));
30
+ const refWrapper = useRef(null);
31
+ const wrapper = useSize(refWrapper);
32
+ const isAlignCenter = useMemo(() => wrapper?.height === inputSize[dimension], [wrapper, dimension]);
33
+ return (_jsxs(Stack, { as: "span", direction: "row", columnGap: 8, vAlign: isAlignCenter ? 'center' : 'start', fill: false, ref: refWrapper, "data-outer-element": "Wrapper", children: [_jsx("input", { type: "checkbox", disabled: disabled, "aria-disabled": disabled, "data-control-dimension": dimension, "data-inner-element": "Toggle", onChange: onChange, className: clsx(styles.Toggle, className), ref: forwardedRef, id: fieldID, ...otherProps }), label && (_jsx(Text, { as: "label", "aria-disabled": disabled, "data-inner-element": "Label", className: styles.Label, size: dimension === 'small' ? 14 : 16, lineHeight: dimension === 'small' ? 'small' : 'large', htmlFor: fieldID, title: otherProps?.title, children: label }))] }));
26
34
  });
27
35
  Toggle.displayName = 'Toggle';
@@ -1,4 +1,5 @@
1
1
  import { ComponentMeta, ComponentStory } from '@storybook/react';
2
+ import React from 'react';
2
3
  import { Toggle } from './toggle';
3
4
  declare const story: ComponentMeta<typeof Toggle>;
4
5
  export default story;
@@ -6,4 +7,10 @@ export declare const Default: ComponentStory<typeof Toggle>;
6
7
  export declare const Checked: ComponentStory<typeof Toggle>;
7
8
  export declare const DisabledChecked: ComponentStory<typeof Toggle>;
8
9
  export declare const withLabel: ComponentStory<typeof Toggle>;
10
+ export declare const withConstraint: ComponentStory<React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
11
+ disabled?: boolean | undefined;
12
+ label?: string | undefined;
13
+ dimension?: "small" | "regular" | undefined;
14
+ onChange?: ((event: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
15
+ } & React.RefAttributes<HTMLInputElement>>>;
9
16
  //# 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;AACnH,eAAO,MAAM,SAAS,EAAE,cAAc,CAAC,OAAO,MAAM,CAA6D,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;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,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;AAQlH,eAAO,MAAM,cAAc;;;;;2CAA8B,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Card } from '../..';
2
3
  import { Toggle } from './toggle';
3
4
  const story = {
4
5
  title: 'Inputs/Toggle',
@@ -21,3 +22,10 @@ export const Default = args => _jsx(Toggle, { ...args });
21
22
  export const Checked = args => _jsx(Toggle, { defaultChecked: true, ...args });
22
23
  export const DisabledChecked = args => _jsx(Toggle, { defaultChecked: true, disabled: true, ...args });
23
24
  export const withLabel = args => _jsx(Toggle, { defaultChecked: true, label: "Label", ...args });
25
+ const ConstraintTemplate = args => (_jsx(Card, { dimmed: 0, bordered: true, style: { width: '300px' }, children: _jsx(Toggle, { ...args }) }));
26
+ export const withConstraint = ConstraintTemplate.bind({});
27
+ withConstraint.args = {
28
+ defaultChecked: true,
29
+ disabled: false,
30
+ label: 'myVeryLongUsernameUnspacedLabel@wonderflow.ai',
31
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"shell.stories.d.ts","sourceRoot":"","sources":["../../src/examples/shell.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQjE,OAAO,EAGL,SAAS,EAOV,MAAM,cAAc,CAAC;AAItB,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,SAAS,CAG1C,CAAC;AAEF,eAAe,KAAK,CAAC;AAuJrB,eAAO,MAAM,KAAK,kHAAoB,CAAC"}
1
+ {"version":3,"file":"shell.stories.d.ts","sourceRoot":"","sources":["../../src/examples/shell.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQjE,OAAO,EAGL,SAAS,EAOV,MAAM,cAAc,CAAC;AAItB,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,SAAS,CAG1C,CAAC;AAEF,eAAe,KAAK,CAAC;AAwJrB,eAAO,MAAM,KAAK,kHAAoB,CAAC"}
@@ -18,11 +18,11 @@ const Template = () => {
18
18
  const { matches, size } = useBreakpoints();
19
19
  const linkIcons = useMemo(() => ['accessibility', 'astronomy', 'crown', 'megaphone', 'thumbs-up'], []);
20
20
  const { value: containerValue, matches: containerMatches, size: containerSize, } = useBreakpointsConfig({
21
- sm: { gutter: 16, col: 3, dimension: 'fixed' },
22
- md: { gutter: 24, col: 3, dimension: 'fixed' },
23
- lg: { gutter: 24, col: 4, dimension: 'fixed' },
24
- xl: { gutter: 24, col: 6, dimension: 'fixed' },
25
- fallback: { gutter: 16, col: 2, dimension: 'fixed' },
21
+ sm: { gutter: 16, col: 2, dimension: 'extra-large' },
22
+ md: { gutter: 24, col: 3, dimension: 'extra-large' },
23
+ lg: { gutter: 24, col: 4, dimension: 'extra-large' },
24
+ xl: { gutter: 32, col: 6, dimension: 'extra-large' },
25
+ fallback: { gutter: 16, col: 1, dimension: 'extra-large' },
26
26
  }, ref);
27
27
  useEffect(() => {
28
28
  if (isBrowser) {
@@ -35,6 +35,6 @@ const Template = () => {
35
35
  }, [isBrowser]);
36
36
  return (_jsx(Container, { dimension: "full", padding: false, className: style.MainContainer, children: _jsxs(Stack, { direction: "row", children: [_jsxs(Stack, { id: "LeftMenu", rowGap: 16, className: style.LeftMenu, "data-is-open": isLeftOpen, children: [_jsx("div", { className: style.LeftMenuInner, "data-is-open": isLeftOpen }), isLeftOpen
37
37
  ? (_jsx("div", { children: linkIcons.map((e, i) => (_jsx(Menu.Item, { disabled: true, value: `${e}`, icon: linkIcons[i], children: e }, seed(`linkMenu${i}`)))) }))
38
- : (_jsx(Stack, { inline: true, hAlign: "center", rowGap: 8, children: linkIcons.map((e, i) => (_jsx(IconButton, { disabled: true, icon: linkIcons[i], kind: "flat" }, `${e} ${seed(`icons${i}`)}`))) }))] }), _jsxs(Stack, { children: [_jsxs(Stack, { id: "MainMenu", direction: "row", vAlign: "center", hAlign: "space-between", columnGap: 16, className: style.MainMenu, children: [_jsx(Stack, { inline: true, children: _jsx(Button, { kind: "secondary", dimension: "regular", fullWidth: false, onClick: () => setIsLeftOpen(!isLeftOpen), children: "Menu" }) }), _jsx(Stack, { inline: true, children: _jsx(Button, { kind: "secondary", dimension: "regular", fullWidth: false, onClick: () => setIsRightOpen(!isRightOpen), children: "Filters" }) })] }), _jsx(Container, { ref: ref, dimension: containerValue.dimension, className: clsx(style.Container, 'ContainerEx'), children: _jsxs(Stack, { rowGap: 32, vPadding: 32, children: [_jsxs(Snackbar, { children: [_jsx(Title, { level: "2", children: "Product Card Container" }), _jsx(Text, { as: "span", children: `Window Width: ${size}px - Breakpoints Match: ${matches.toUpperCase()}` }), _jsx("br", {}), _jsx(Text, { as: "span", children: `Container Width: ${containerSize}px - Grid Columns: ${containerValue.col} - Grid Gutter: ${containerValue.gutter}px` }), _jsx("br", {}), _jsx(Text, { as: "span", children: `useBreakpointsConfig.value: ${JSON.stringify(containerValue)} - useBreakpointsConfig.matches: ${containerMatches.toUpperCase()}` })] }), _jsx(Grid, { columns: containerValue.col, rowGap: containerValue.gutter, columnGap: containerValue.gutter, filling: false, children: Array(12).fill('Card').map((e, i) => (_jsx(Grid.Item, { children: _jsx(Card, { bordered: true, style: { height: '500px' }, children: _jsx(Stack, { hAlign: "center", children: _jsx(Text, { size: 14, children: `${e} ${i + 1}` }) }) }) }, seed(`cards${i}`)))) })] }) })] }), _jsxs(Stack, { id: "RightMenu", className: style.RightMenu, "data-is-open": isRightOpen, children: [_jsx("div", { className: style.RightMenuInner }), _jsx("div", { className: style.Filter, children: Array(10).fill('Filter').map((e, i) => (_jsxs(Disclosure, { summary: `${e} ${String.fromCharCode(i + 65)}`, children: [_jsx(Menu.Item, { value: "1", subtext: "Hint Text", children: "Menu Item 1" }), _jsx(Menu.Item, { value: "2", subtext: "Hint Text", children: "Menu Item 2" }), _jsx(Menu.Item, { value: "3", subtext: "Hint Text", children: "Menu Item 3" }), _jsx(Menu.Item, { value: "4", subtext: "Hint Text", children: "Menu Item 4" })] }, seed(`filters${i}`)))) })] })] }) }));
38
+ : (_jsx(Stack, { inline: true, hAlign: "center", rowGap: 8, children: linkIcons.map((e, i) => (_jsx(IconButton, { disabled: true, icon: linkIcons[i], kind: "flat" }, `${e} ${seed(`icons${i}`)}`))) }))] }), _jsxs(Stack, { children: [_jsxs(Stack, { id: "MainMenu", direction: "row", vAlign: "center", hAlign: "space-between", columnGap: 16, className: style.MainMenu, children: [_jsx(Stack, { inline: true, children: _jsx(Button, { kind: "secondary", dimension: "regular", fullWidth: false, onClick: () => setIsLeftOpen(!isLeftOpen), children: "Menu" }) }), _jsx(Stack, { inline: true, children: _jsx(Button, { kind: "secondary", dimension: "regular", fullWidth: false, onClick: () => setIsRightOpen(!isRightOpen), children: "Filters" }) })] }), _jsx(Container, { ref: ref, dimension: containerValue.dimension, className: clsx(style.Container, 'ContainerEx'), children: _jsxs(Stack, { rowGap: 32, vPadding: 32, children: [_jsxs(Snackbar, { children: [_jsx(Title, { level: "2", children: "Product Card Container" }), _jsx(Text, { as: "span", children: `Window Width: ${size}px - Breakpoints Match: ${matches.toUpperCase()}` }), _jsx("br", {}), _jsx(Text, { as: "span", children: `Container Width: ${containerSize}px - Grid Columns: ${containerValue.col} - Grid Gutter: ${containerValue.gutter}px` }), _jsx("br", {}), _jsx(Text, { as: "span", children: `useBreakpointsConfig.value: ${JSON.stringify(containerValue)} - useBreakpointsConfig.matches: ${containerMatches.toUpperCase()}` })] }), _jsx(Grid, { colMinWidth: "1rem", columns: containerValue.col, rowGap: containerValue.gutter, columnGap: containerValue.gutter, filling: false, children: Array(12).fill('Card').map((e, i) => (_jsx(Grid.Item, { children: _jsx(Card, { bordered: true, style: { height: '500px' }, children: _jsx(Stack, { hAlign: "center", children: _jsx(Text, { size: 14, children: `${e} ${i + 1}` }) }) }) }, seed(`cards${i}`)))) })] }) })] }), _jsxs(Stack, { id: "RightMenu", className: style.RightMenu, "data-is-open": isRightOpen, children: [_jsx("div", { className: style.RightMenuInner }), _jsx("div", { className: style.Filter, children: Array(10).fill('Filter').map((e, i) => (_jsxs(Disclosure, { summary: `${e} ${String.fromCharCode(i + 65)}`, children: [_jsx(Menu.Item, { value: "1", subtext: "Hint Text", children: "Menu Item 1" }), _jsx(Menu.Item, { value: "2", subtext: "Hint Text", children: "Menu Item 2" }), _jsx(Menu.Item, { value: "3", subtext: "Hint Text", children: "Menu Item 3" }), _jsx(Menu.Item, { value: "4", subtext: "Hint Text", children: "Menu Item 4" })] }, seed(`filters${i}`)))) })] })] }) }));
39
39
  };
40
40
  export const Shell = Template.bind({});
@@ -1 +1 @@
1
- {"version":3,"file":"useBreakpoints.d.ts","sourceRoot":"","sources":["../../src/hooks/useBreakpoints.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,gBAAgB,EACjB,MAAM,OAAO,CAAC;AAIf,oBAAY,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAE/D,oBAAY,WAAW,CAAC,CAAC,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAA;AAExD,oBAAY,mBAAmB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;AAErD,oBAAY,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;AAkBpD,eAAO,MAAM,cAAc,YAChB,iBAAiB,WAAW,GAAG,IAAI,CAAC,aACnC,mBAAmB;;;;CA6D9B,CAAC"}
1
+ {"version":3,"file":"useBreakpoints.d.ts","sourceRoot":"","sources":["../../src/hooks/useBreakpoints.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,gBAAgB,EACjB,MAAM,OAAO,CAAC;AAKf,oBAAY,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAE/D,oBAAY,WAAW,CAAC,CAAC,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAA;AAExD,oBAAY,mBAAmB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;AAErD,oBAAY,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;AAkBpD,eAAO,MAAM,cAAc,YAChB,iBAAiB,WAAW,GAAG,IAAI,CAAC,aACnC,mBAAmB;;;;CA6D9B,CAAC"}
@@ -13,15 +13,17 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import tkns from '@wonderflow/tokens/platforms/web/tokens.json';
16
17
  import { useSize } from 'ahooks';
17
18
  import { useEffect, useState, } from 'react';
19
+ import { cssRelativeUnitsToPixel } from '../utils/conversions';
18
20
  import { useSSR } from './useSSR';
19
21
  const DefaultBreakpointsSettings = {
20
- xs: 480,
21
- sm: 768,
22
- md: 960,
23
- lg: 1280,
24
- xl: 1600,
22
+ xs: cssRelativeUnitsToPixel(tkns.breakpoint['extra-small']),
23
+ sm: cssRelativeUnitsToPixel(tkns.breakpoint.small),
24
+ md: cssRelativeUnitsToPixel(tkns.breakpoint.medium),
25
+ lg: cssRelativeUnitsToPixel(tkns.breakpoint.large),
26
+ xl: cssRelativeUnitsToPixel(tkns.breakpoint['extra-large']),
25
27
  };
26
28
  const DefaultBreakpointsValues = {
27
29
  xs: false,
@@ -1 +1 @@
1
- {"version":3,"file":"responsive.d.ts","sourceRoot":"","sources":["../../src/providers/responsive.tsx"],"names":[],"mappings":";AAqBA,aAAK,sBAAsB,GAAG;IAC5B;;MAEE;IACF,WAAW,EAAE;QACX,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF;;MAEE;IACF,OAAO,EAAE,MAAM,CAAC,MAAM,sBAAsB,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;CACvE,CAAA;AAED,aAAK,uBAAuB,GAAG;IAC7B,WAAW,CAAC,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;CACrD,CAAA;AAUD,eAAO,MAAM,iBAAiB,iDAS5B,CAAC;AAIH,eAAO,MAAM,kBAAkB,EAAE,UAAU,CAAC,uBAAuB,CAuBlE,CAAC;AAEF,eAAO,MAAM,oBAAoB,8BAShC,CAAC"}
1
+ {"version":3,"file":"responsive.d.ts","sourceRoot":"","sources":["../../src/providers/responsive.tsx"],"names":[],"mappings":";AAuBA,aAAK,sBAAsB,GAAG;IAC5B;;MAEE;IACF,WAAW,EAAE;QACX,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF;;MAEE;IACF,OAAO,EAAE,MAAM,CAAC,MAAM,sBAAsB,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;CACvE,CAAA;AAED,aAAK,uBAAuB,GAAG;IAC7B,WAAW,CAAC,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;CACrD,CAAA;AAUD,eAAO,MAAM,iBAAiB,iDAS5B,CAAC;AAIH,eAAO,MAAM,kBAAkB,EAAE,UAAU,CAAC,uBAAuB,CAuBlE,CAAC;AAEF,eAAO,MAAM,oBAAoB,8BAShC,CAAC"}
@@ -14,14 +14,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import tkns from '@wonderflow/tokens/platforms/web/tokens.json';
17
18
  import { configResponsive, useResponsive as responsiveAhook } from 'ahooks';
18
19
  import { createContext, useContext, useEffect, useState, } from 'react';
20
+ import { cssRelativeUnitsToPixel } from '../utils/conversions';
19
21
  const DEFAULT_BREAKPOINTS = {
20
- extraSmall: 480,
21
- small: 768,
22
- medium: 960,
23
- large: 1280,
24
- extraLarge: 1600,
22
+ extraSmall: cssRelativeUnitsToPixel(tkns.breakpoint['extra-small']),
23
+ small: cssRelativeUnitsToPixel(tkns.breakpoint.small),
24
+ medium: cssRelativeUnitsToPixel(tkns.breakpoint.medium),
25
+ large: cssRelativeUnitsToPixel(tkns.breakpoint.large),
26
+ extraLarge: cssRelativeUnitsToPixel(tkns.breakpoint['extra-large']),
25
27
  };
26
28
  export const ResponsiveContext = createContext({
27
29
  breakpoints: DEFAULT_BREAKPOINTS,
@@ -0,0 +1,2 @@
1
+ export declare const cssRelativeUnitsToPixel: (size: string) => number;
2
+ //# sourceMappingURL=conversions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversions.d.ts","sourceRoot":"","sources":["../../src/utils/conversions.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,uBAAuB,SAAU,MAAM,KAAG,MAStD,CAAC"}
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright 2023 Wonderflow Design Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export const cssRelativeUnitsToPixel = (size) => {
17
+ if ((/[0-9]+(em|rem)/g).test(size)) {
18
+ const re = /\d+/g;
19
+ const m = size.match(re);
20
+ const v = m ?? +m[0];
21
+ return v * 16;
22
+ }
23
+ return -1;
24
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=convertions.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertions.test.d.ts","sourceRoot":"","sources":["../../src/utils/convertions.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { cssRelativeUnitsToPixel } from './conversions';
2
+ describe('cssRelativeUnitsToPixel()', () => {
3
+ const rightCases = ['20rem', '20em'];
4
+ const wrongCases = ['abc', '20Rem', '20eM', '20ReM', '20EM', '20px', '20%'];
5
+ rightCases.map(c => it(`should return 320 with input "${c}"`, () => {
6
+ const res = cssRelativeUnitsToPixel(c);
7
+ expect(res).toBe(320);
8
+ }));
9
+ wrongCases.map(c => it(`should return -1 with input "${c}"`, () => {
10
+ const res = cssRelativeUnitsToPixel(c);
11
+ expect(res).toBe(-1);
12
+ }));
13
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
- "version": "11.0.5",
3
+ "version": "11.0.7",
4
4
  "description": "UI components from Wonderflow's Wanda design system",
5
5
  "author": "Wonderflow",
6
6
  "license": "Apache-2.0",
@@ -82,8 +82,8 @@
82
82
  "@types/react-dom": "17.0.14",
83
83
  "@types/react-table": "7.7.12",
84
84
  "@types/react-test-renderer": "18.0.0",
85
- "@wonderflow/config": "11.0.5",
86
- "@wonderflow/tokens": "11.0.5",
85
+ "@wonderflow/config": "11.0.7",
86
+ "@wonderflow/tokens": "11.0.7",
87
87
  "babel-loader": "8.2.5",
88
88
  "cpy-cli": "3.1.1",
89
89
  "postcss": "8.4.17",