reshaped 3.6.0-canary.0 → 3.6.0-canary.1

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 (122) hide show
  1. package/CHANGELOG.md +17 -2
  2. package/dist/bundle.css +1 -1
  3. package/dist/bundle.d.ts +1 -1
  4. package/dist/bundle.js +11 -11
  5. package/dist/components/Accordion/AccordionControlled.js +1 -1
  6. package/dist/components/Accordion/AccordionTrigger.js +1 -1
  7. package/dist/components/ActionBar/ActionBar.js +1 -1
  8. package/dist/components/Actionable/Actionable.js +1 -1
  9. package/dist/components/Autocomplete/tests/Autocomplete.stories.js +1 -0
  10. package/dist/components/Avatar/Avatar.js +1 -1
  11. package/dist/components/Badge/Badge.js +1 -1
  12. package/dist/components/Badge/BadgeContainer.js +1 -1
  13. package/dist/components/Breadcrumbs/Breadcrumbs.js +1 -1
  14. package/dist/components/Button/Button.js +1 -1
  15. package/dist/components/Button/ButtonGroup.js +1 -1
  16. package/dist/components/Calendar/CalendarDate.js +1 -1
  17. package/dist/components/Card/Card.d.ts +1 -1
  18. package/dist/components/Card/Card.js +1 -1
  19. package/dist/components/Card/tests/Card.stories.d.ts +1 -1
  20. package/dist/components/Card/tests/Card.test.stories.d.ts +1 -1
  21. package/dist/components/Carousel/Carousel.js +4 -3
  22. package/dist/components/Carousel/CarouselControl.js +1 -1
  23. package/dist/components/Checkbox/Checkbox.js +1 -1
  24. package/dist/components/Checkbox/Checkbox.module.css +1 -1
  25. package/dist/components/Container/Container.js +1 -1
  26. package/dist/components/Dismissible/Dismissible.js +1 -1
  27. package/dist/components/Divider/Divider.js +1 -1
  28. package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
  29. package/dist/components/FileUpload/FileUpload.js +1 -1
  30. package/dist/components/Flyout/FlyoutContent.js +4 -3
  31. package/dist/components/Flyout/utilities/calculatePosition.d.ts +1 -1
  32. package/dist/components/Flyout/utilities/calculatePosition.js +1 -1
  33. package/dist/components/FormControl/FormControl.context.d.ts +0 -2
  34. package/dist/components/Grid/Grid.js +1 -1
  35. package/dist/components/Hidden/Hidden.js +1 -1
  36. package/dist/components/Hotkey/Hotkey.js +1 -1
  37. package/dist/components/Icon/Icon.js +1 -1
  38. package/dist/components/Image/Image.js +1 -1
  39. package/dist/components/Link/Link.js +1 -1
  40. package/dist/components/Loader/Loader.js +1 -1
  41. package/dist/components/MenuItem/MenuItem.js +1 -1
  42. package/dist/components/Modal/Modal.js +1 -1
  43. package/dist/components/NumberField/NumberFieldControlled.js +1 -1
  44. package/dist/components/Overlay/Overlay.js +1 -1
  45. package/dist/components/PinField/PinFieldControlled.js +1 -1
  46. package/dist/components/Popover/Popover.js +3 -3
  47. package/dist/components/Popover/Popover.module.css +1 -1
  48. package/dist/components/Popover/Popover.types.d.ts +1 -0
  49. package/dist/components/Popover/tests/Popover.stories.d.ts +46 -7
  50. package/dist/components/Popover/tests/Popover.stories.js +209 -85
  51. package/dist/components/Progress/Progress.js +1 -1
  52. package/dist/components/ProgressIndicator/ProgressIndicator.js +1 -1
  53. package/dist/components/Radio/Radio.js +1 -1
  54. package/dist/components/Radio/Radio.module.css +1 -1
  55. package/dist/components/Reshaped/Reshaped.js +1 -1
  56. package/dist/components/Resizable/Resizable.js +1 -1
  57. package/dist/components/Scrim/Scrim.js +1 -1
  58. package/dist/components/ScrollArea/ScrollArea.js +8 -11
  59. package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
  60. package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +13 -4
  61. package/dist/components/ScrollArea/tests/ScrollArea.stories.js +129 -30
  62. package/dist/components/Select/Select.js +1 -1
  63. package/dist/components/Skeleton/Skeleton.js +1 -1
  64. package/dist/components/Slider/Slider.types.d.ts +34 -7
  65. package/dist/components/Slider/SliderControlled.js +32 -20
  66. package/dist/components/Slider/SliderThumb.js +4 -4
  67. package/dist/components/Slider/SliderUncontrolled.js +3 -2
  68. package/dist/components/Slider/tests/Slider.stories.d.ts +38 -8
  69. package/dist/components/Slider/tests/Slider.stories.js +268 -54
  70. package/dist/components/Stepper/Stepper.js +1 -1
  71. package/dist/components/Switch/Switch.js +1 -1
  72. package/dist/components/Table/Table.js +6 -3
  73. package/dist/components/Table/Table.module.css +1 -1
  74. package/dist/components/Tabs/TabsItem.js +1 -1
  75. package/dist/components/Tabs/TabsList.js +3 -34
  76. package/dist/components/Tabs/TabsPanel.js +1 -1
  77. package/dist/components/Text/Text.js +1 -1
  78. package/dist/components/TextArea/TextArea.js +1 -1
  79. package/dist/components/TextField/TextField.js +1 -1
  80. package/dist/components/Theme/Theme.js +1 -1
  81. package/dist/components/Timeline/Timeline.js +1 -1
  82. package/dist/components/Toast/ToastContainer.js +1 -1
  83. package/dist/components/Toast/ToastRegion.js +1 -1
  84. package/dist/components/View/View.js +1 -1
  85. package/dist/components/_private/Aligner/Aligner.js +1 -1
  86. package/dist/components/_private/Expandable/Expandable.js +1 -1
  87. package/dist/components/_private/HiddenInput/HiddenInput.js +1 -1
  88. package/dist/hooks/_private/useFadeSide.d.ts +5 -0
  89. package/dist/hooks/_private/useFadeSide.js +47 -0
  90. package/dist/index.d.ts +1 -1
  91. package/dist/index.js +1 -1
  92. package/dist/styles/align/index.js +1 -1
  93. package/dist/styles/aspectRatio/index.js +1 -1
  94. package/dist/styles/bleed/index.js +1 -1
  95. package/dist/styles/border/index.js +1 -1
  96. package/dist/styles/height/index.js +1 -1
  97. package/dist/styles/inset/index.js +1 -1
  98. package/dist/styles/justify/index.js +1 -1
  99. package/dist/styles/maxHeight/index.js +1 -1
  100. package/dist/styles/maxWidth/index.js +1 -1
  101. package/dist/styles/minHeight/index.js +1 -1
  102. package/dist/styles/minWidth/index.js +1 -1
  103. package/dist/styles/padding/index.js +1 -1
  104. package/dist/styles/position/index.js +1 -1
  105. package/dist/styles/radius/index.js +1 -1
  106. package/dist/styles/textAlign/index.js +1 -1
  107. package/dist/styles/width/index.js +1 -1
  108. package/dist/utilities/dom/event.d.ts +7 -0
  109. package/dist/utilities/dom/event.js +11 -0
  110. package/dist/utilities/dom/index.d.ts +1 -0
  111. package/dist/utilities/dom/index.js +1 -0
  112. package/dist/utilities/helpers.d.ts +1 -15
  113. package/dist/utilities/helpers.js +11 -133
  114. package/dist/utilities/props.d.ts +13 -0
  115. package/dist/utilities/props.js +83 -0
  116. package/package.json +25 -26
  117. package/dist/components/Popover/tests/Popover.test.stories.d.ts +0 -39
  118. package/dist/components/Popover/tests/Popover.test.stories.js +0 -167
  119. package/dist/components/ScrollArea/tests/ScrollArea.test.stories.d.ts +0 -23
  120. package/dist/components/ScrollArea/tests/ScrollArea.test.stories.js +0 -66
  121. package/dist/components/Slider/tests/Slider.test.stories.d.ts +0 -38
  122. package/dist/components/Slider/tests/Slider.test.stories.js +0 -150
package/dist/index.d.ts CHANGED
@@ -139,7 +139,7 @@ export { default as useToggle } from "./hooks/useToggle";
139
139
  /**
140
140
  * Utility functions
141
141
  */
142
- export { classNames, responsiveClassNames, responsivePropDependency } from "./utilities/helpers";
142
+ export { classNames, responsivePropDependency } from "./utilities/props";
143
143
  export { TrapFocus } from "./utilities/a11y";
144
144
  /**
145
145
  * Types
package/dist/index.js CHANGED
@@ -80,7 +80,7 @@ export { default as useToggle } from "./hooks/useToggle.js";
80
80
  /**
81
81
  * Utility functions
82
82
  */
83
- export { classNames, responsiveClassNames, responsivePropDependency } from "./utilities/helpers.js";
83
+ export { classNames, responsivePropDependency } from "./utilities/props.js";
84
84
  export { TrapFocus } from "./utilities/a11y/index.js";
85
85
  /**
86
86
  * Dev utilities
@@ -1,4 +1,4 @@
1
- import { responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveVariables } from "../../utilities/props.js";
2
2
  import "./align.css";
3
3
  const getAlignStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveVariables } from "../../utilities/props.js";
2
2
  import "./aspectRatio.css";
3
3
  const getAspectRatioStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveClassNames, responsiveVariables, responsivePropDependency, } from "../../utilities/helpers.js";
1
+ import { responsiveClassNames, responsiveVariables, responsivePropDependency, } from "../../utilities/props.js";
2
2
  import s from "./bleed.module.css";
3
3
  const getBleedStyles = (value) => {
4
4
  if (value === undefined)
@@ -1,4 +1,4 @@
1
- import { responsiveClassNames } from "../../utilities/helpers.js";
1
+ import { responsiveClassNames } from "../../utilities/props.js";
2
2
  import s from "./border.module.css";
3
3
  const getBorderStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveClassNames, responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveClassNames, responsiveVariables } from "../../utilities/props.js";
2
2
  import s from "./height.module.css";
3
3
  const getHeightStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveVariables } from "../../utilities/props.js";
2
2
  import "./inset.css";
3
3
  const getInsetStyles = (value, side) => {
4
4
  if (value === undefined)
@@ -1,4 +1,4 @@
1
- import { responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveVariables } from "../../utilities/props.js";
2
2
  import "./justify.css";
3
3
  const getJustifyStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveClassNames, responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveClassNames, responsiveVariables } from "../../utilities/props.js";
2
2
  import s from "./maxHeight.module.css";
3
3
  const getMaxHeightStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveClassNames, responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveClassNames, responsiveVariables } from "../../utilities/props.js";
2
2
  import s from "./maxWidth.module.css";
3
3
  const getMaxWidthStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveClassNames, responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveClassNames, responsiveVariables } from "../../utilities/props.js";
2
2
  import s from "./minHeight.module.css";
3
3
  const getMinHeightStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveClassNames, responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveClassNames, responsiveVariables } from "../../utilities/props.js";
2
2
  import s from "./minWidth.module.css";
3
3
  const getMinWidthStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveVariables } from "../../utilities/props.js";
2
2
  import "./padding.css";
3
3
  const getPaddingStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveVariables } from "../../utilities/props.js";
2
2
  import "./position.css";
3
3
  const getPositionStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveClassNames } from "../../utilities/helpers.js";
1
+ import { responsiveClassNames } from "../../utilities/props.js";
2
2
  import s from "./radius.module.css";
3
3
  const getRadiusStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveVariables } from "../../utilities/props.js";
2
2
  import "./textAlign.css";
3
3
  const getTextAlignStyles = (value) => {
4
4
  if (!value)
@@ -1,4 +1,4 @@
1
- import { responsiveClassNames, responsiveVariables } from "../../utilities/helpers.js";
1
+ import { responsiveClassNames, responsiveVariables } from "../../utilities/props.js";
2
2
  import s from "./width.module.css";
3
3
  const getWidthStyles = (value) => {
4
4
  if (!value)
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Workaround for changing a hidden input value with triggerring
3
+ * React input onChange and form onChange handlers
4
+ *
5
+ * Based on https://stackoverflow.com/a/60378508
6
+ */
7
+ export declare const triggerChangeEvent: (el: HTMLInputElement, value: string) => void;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Workaround for changing a hidden input value with triggerring
3
+ * React input onChange and form onChange handlers
4
+ *
5
+ * Based on https://stackoverflow.com/a/60378508
6
+ */
7
+ export const triggerChangeEvent = (el, value) => {
8
+ const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
9
+ nativeInputValueSetter.call(el, value);
10
+ el.dispatchEvent(new Event("change", { bubbles: true }));
11
+ };
@@ -2,3 +2,4 @@ export { getRectFromCoordinates } from "./flyout";
2
2
  export { getShadowRoot } from "./shadowDom";
3
3
  export { enableUserSelect, disableUserSelect } from "./userSelect";
4
4
  export { findParent, findClosestScrollableContainer, findClosestPositionContainer } from "./find";
5
+ export { triggerChangeEvent } from "./event";
@@ -2,3 +2,4 @@ export { getRectFromCoordinates } from "./flyout.js";
2
2
  export { getShadowRoot } from "./shadowDom.js";
3
3
  export { enableUserSelect, disableUserSelect } from "./userSelect.js";
4
4
  export { findParent, findClosestScrollableContainer, findClosestPositionContainer } from "./find.js";
5
+ export { triggerChangeEvent } from "./event.js";
@@ -1,17 +1,3 @@
1
- import type * as G from "../types/global";
2
1
  export declare const sleep: (milliseconds: number) => Promise<unknown>;
3
2
  export declare const range: (start: number, end: number) => number[];
4
- export declare const debounce: <T extends Function>(cb: T, wait?: number) => T;
5
- export declare function debounceHandler<T extends React.SyntheticEvent | Event>(handler: (event: T) => void, timeout: number): (event: T) => void;
6
- export declare const throttle: <T extends Function>(cb: T, wait: number) => (...args: unknown[]) => void;
7
- export declare function throttleHandler<T extends React.SyntheticEvent | Event>(handler: (event: T) => void, timeout: number): (event: T) => void;
8
- type Value = string | boolean | number | undefined;
9
- type ClassNameResolver = string | ((value: Value) => string);
10
- export declare const classNames: (...args: G.ClassName[]) => string;
11
- export declare const responsiveClassNames: <V extends G.Responsive<Value>>(s: Record<string, string>, className: ClassNameResolver, value: V, options?: {
12
- excludeValueFromClassName?: boolean;
13
- }) => string[];
14
- export declare const responsiveVariables: <V extends Value = Value>(variableName: G.CSSVariable, value?: G.Responsive<V>) => Record<G.CSSVariable, V>;
15
- export declare const responsivePropDependency: <Result, T>(prop: G.Responsive<T>, resolver: (value: T, key: G.Viewport) => Result) => Result;
16
- export declare const resolveViewportValue: <T>(viewport: G.Viewport, value: G.Responsive<T>) => T | undefined;
17
- export {};
3
+ export declare const rafThrottle: <T extends (...args: any[]) => void>(fn: T) => T;
@@ -6,139 +6,17 @@ export const range = (start, end) => {
6
6
  return [];
7
7
  return Array.from({ length: end - start + 1 }, (_, i) => start + i);
8
8
  };
9
- // from https://gist.github.com/ca0v/73a31f57b397606c9813472f7493a940
10
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
11
- export const debounce = (cb, wait = 20) => {
12
- let timer;
13
- const callable = (...args) => {
14
- clearTimeout(timer);
15
- timer = setTimeout(() => cb(...args), wait);
16
- };
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
- return callable;
19
- };
20
- export function debounceHandler(handler, timeout) {
21
- const debounced = debounce(handler, timeout);
22
- return (event) => {
23
- if ("persist" in event)
24
- event.persist();
25
- return debounced(event);
26
- };
27
- }
28
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
29
- export const throttle = (cb, wait) => {
30
- let waiting = false;
31
- return (...args) => {
32
- if (!waiting) {
33
- cb(...args);
34
- waiting = true;
35
- setTimeout(() => {
36
- waiting = false;
37
- setTimeout(() => {
38
- if (waiting)
39
- return;
40
- cb(...args);
41
- }, wait);
42
- }, wait);
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ export const rafThrottle = (fn) => {
11
+ let rafId = null;
12
+ let args = null;
13
+ return function (...newArgs) {
14
+ args = newArgs;
15
+ if (rafId === null) {
16
+ rafId = requestAnimationFrame(() => {
17
+ rafId = null;
18
+ fn(...args);
19
+ });
43
20
  }
44
21
  };
45
22
  };
46
- export function throttleHandler(handler, timeout) {
47
- const throttled = throttle(handler, timeout);
48
- return (event) => {
49
- if ("persist" in event)
50
- event.persist();
51
- return throttled(event);
52
- };
53
- }
54
- export const classNames = (...args) => {
55
- return args.reduce((acc, cur) => {
56
- if (Array.isArray(cur)) {
57
- const className = classNames(...cur);
58
- if (!className)
59
- return acc;
60
- return `${acc} ${className}`;
61
- }
62
- if (cur)
63
- return `${acc} ${cur}`;
64
- return acc;
65
- }, "");
66
- };
67
- const applyClassName = (passedClassName, value, options) => {
68
- const { base, excludeValueFromClassName } = options || {};
69
- const className = typeof passedClassName === "string" ? passedClassName : passedClassName(value);
70
- if ((value === true && base) || excludeValueFromClassName)
71
- return className;
72
- // CSS should be turned on/off for non base viewport with mobile first approach
73
- if (value === true && !base)
74
- return `${className}-true`;
75
- if (value === false && !base)
76
- return `${className}-false`;
77
- if (value !== undefined)
78
- return `${className}-${value}`;
79
- return null;
80
- };
81
- export const responsiveClassNames = (s, className, value, options) => {
82
- if (typeof value !== "object") {
83
- const staticClassName = applyClassName(className, value, {
84
- base: true,
85
- excludeValueFromClassName: options?.excludeValueFromClassName,
86
- });
87
- return staticClassName ? [s[staticClassName]] : [];
88
- }
89
- return Object.keys(value).reduce((acc, viewport) => {
90
- const base = viewport === "s";
91
- const viewportClassName = applyClassName(className, value[viewport], {
92
- base,
93
- excludeValueFromClassName: options?.excludeValueFromClassName,
94
- });
95
- const suffix = base ? "" : `--${viewport}`;
96
- return [...acc, s[`${viewportClassName}${suffix}`]];
97
- }, []);
98
- };
99
- export const responsiveVariables = (variableName, value) => {
100
- if (value === undefined)
101
- return {};
102
- if (typeof value !== "object")
103
- return { [`${variableName}-s`]: value };
104
- return Object.keys(value).reduce((acc, key) => {
105
- const viewportValue = value[key];
106
- if (viewportValue === undefined)
107
- return acc;
108
- if (viewportValue === false)
109
- return acc;
110
- return {
111
- ...acc,
112
- [`${variableName}-${key}`]: viewportValue,
113
- };
114
- }, {});
115
- };
116
- const isResponsive = (prop) => {
117
- if (prop === null)
118
- return false;
119
- return typeof prop === "object" && prop !== null && "s" in prop;
120
- };
121
- export const responsivePropDependency = (prop, resolver) => {
122
- if (!isResponsive(prop))
123
- return resolver(prop, "s");
124
- const keys = Object.keys(prop);
125
- return keys.reduce((acc, viewport) => {
126
- const viewportValue = prop[viewport];
127
- if (viewportValue === undefined || viewportValue === null)
128
- return acc;
129
- return { ...acc, [viewport]: resolver(viewportValue, viewport) };
130
- }, {});
131
- };
132
- const viewports = ["s", "m", "l", "xl"];
133
- export const resolveViewportValue = (viewport, value) => {
134
- let result;
135
- if (!isResponsive(value))
136
- return value;
137
- for (const currentViewport of viewports) {
138
- const viewportValue = value[currentViewport];
139
- if (viewportValue !== undefined)
140
- result = viewportValue;
141
- if (currentViewport === viewport)
142
- return result;
143
- }
144
- };
@@ -0,0 +1,13 @@
1
+ import type * as G from "../types/global";
2
+ type Value = string | boolean | number | undefined;
3
+ type ClassNameResolver = string | ((value: Value) => string);
4
+ /**
5
+ * Resolve an array of values into a classname string
6
+ */
7
+ export declare const classNames: (...args: G.ClassName[]) => string;
8
+ export declare const responsiveClassNames: <V extends G.Responsive<Value>>(s: Record<string, string>, className: ClassNameResolver, value: V, options?: {
9
+ excludeValueFromClassName?: boolean;
10
+ }) => string[];
11
+ export declare const responsiveVariables: <V extends Value = Value>(variableName: G.CSSVariable, value?: G.Responsive<V>) => Record<G.CSSVariable, V>;
12
+ export declare const responsivePropDependency: <Result, T>(prop: G.Responsive<T>, resolver: (value: T, key: G.Viewport) => Result) => Result;
13
+ export {};
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Resolve an array of values into a classname string
3
+ */
4
+ export const classNames = (...args) => {
5
+ return args
6
+ .reduce((acc, cur) => {
7
+ if (Array.isArray(cur)) {
8
+ const className = classNames(...cur);
9
+ if (!className)
10
+ return acc;
11
+ return `${acc} ${className}`;
12
+ }
13
+ if (cur)
14
+ return `${acc} ${cur}`;
15
+ return acc;
16
+ }, "")
17
+ .trim();
18
+ };
19
+ const applyClassName = (passedClassName, value, options) => {
20
+ const { base, excludeValueFromClassName } = options || {};
21
+ const className = typeof passedClassName === "string" ? passedClassName : passedClassName(value);
22
+ if ((value === true && base) || excludeValueFromClassName)
23
+ return className;
24
+ // CSS should be turned on/off for non base viewport with mobile first approach
25
+ if (value === true && !base)
26
+ return `${className}-true`;
27
+ if (value === false && !base)
28
+ return `${className}-false`;
29
+ if (value !== undefined)
30
+ return `${className}-${value}`;
31
+ return null;
32
+ };
33
+ export const responsiveClassNames = (s, className, value, options) => {
34
+ if (typeof value !== "object") {
35
+ const staticClassName = applyClassName(className, value, {
36
+ base: true,
37
+ excludeValueFromClassName: options?.excludeValueFromClassName,
38
+ });
39
+ return staticClassName ? [s[staticClassName]] : [];
40
+ }
41
+ return Object.keys(value).reduce((acc, viewport) => {
42
+ const base = viewport === "s";
43
+ const viewportClassName = applyClassName(className, value[viewport], {
44
+ base,
45
+ excludeValueFromClassName: options?.excludeValueFromClassName,
46
+ });
47
+ const suffix = base ? "" : `--${viewport}`;
48
+ return [...acc, s[`${viewportClassName}${suffix}`]];
49
+ }, []);
50
+ };
51
+ export const responsiveVariables = (variableName, value) => {
52
+ if (value === undefined)
53
+ return {};
54
+ if (typeof value !== "object")
55
+ return { [`${variableName}-s`]: value };
56
+ return Object.keys(value).reduce((acc, key) => {
57
+ const viewportValue = value[key];
58
+ if (viewportValue === undefined)
59
+ return acc;
60
+ if (viewportValue === false)
61
+ return acc;
62
+ return {
63
+ ...acc,
64
+ [`${variableName}-${key}`]: viewportValue,
65
+ };
66
+ }, {});
67
+ };
68
+ const isResponsive = (prop) => {
69
+ if (prop === null)
70
+ return false;
71
+ return typeof prop === "object" && prop !== null && "s" in prop;
72
+ };
73
+ export const responsivePropDependency = (prop, resolver) => {
74
+ if (!isResponsive(prop))
75
+ return resolver(prop, "s");
76
+ const keys = Object.keys(prop);
77
+ return keys.reduce((acc, viewport) => {
78
+ const viewportValue = prop[viewport];
79
+ if (viewportValue === undefined || viewportValue === null)
80
+ return acc;
81
+ return { ...acc, [viewport]: resolver(viewportValue, viewport) };
82
+ }, {});
83
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reshaped",
3
3
  "description": "Professionally crafted design system in React & Figma for building products of any scale and complexity",
4
- "version": "3.6.0-canary.0",
4
+ "version": "3.6.0-canary.1",
5
5
  "license": "MIT",
6
6
  "email": "hello@reshaped.so",
7
7
  "homepage": "https://reshaped.so",
@@ -21,10 +21,9 @@
21
21
  "bugs": {
22
22
  "url": "https://github.com/formaat-design/reshaped/issues"
23
23
  },
24
- "repository": {
25
- "type": "git",
26
- "url": "https://github.com/formaat-design/reshaped"
27
- },
24
+ "sideEffects": [
25
+ "*.css"
26
+ ],
28
27
  "files": [
29
28
  "bin/cli.js",
30
29
  "dist/**/*"
@@ -58,7 +57,6 @@
58
57
  "./themes/fragments/twitter/*": "./dist/themes/fragments/twitter/*",
59
58
  "./package.json": "./package.json"
60
59
  },
61
- "sideEffects": false,
62
60
  "bin": {
63
61
  "reshaped": "./bin/cli.js"
64
62
  },
@@ -95,10 +93,10 @@
95
93
  "defaults and not IE 11"
96
94
  ],
97
95
  "devDependencies": {
98
- "@commitlint/cli": "19.8.0",
99
- "@commitlint/config-conventional": "19.8.0",
100
- "@commitlint/types": "19.8.0",
101
- "@eslint/js": "9.25.1",
96
+ "@commitlint/cli": "19.8.1",
97
+ "@commitlint/config-conventional": "19.8.1",
98
+ "@commitlint/types": "19.8.1",
99
+ "@eslint/js": "9.26.0",
102
100
  "@size-limit/preset-big-lib": "11.2.0",
103
101
  "@storybook/addon-a11y": "8.6.12",
104
102
  "@storybook/addon-actions": "8.6.12",
@@ -108,24 +106,25 @@
108
106
  "@storybook/experimental-addon-test": "8.6.12",
109
107
  "@storybook/react": "8.6.12",
110
108
  "@storybook/react-vite": "8.6.12",
111
- "@types/culori": "2.1.1",
109
+ "@types/culori": "4.0.0",
112
110
  "@types/events": "3.0.3",
113
- "@types/node": "22.14.1",
114
- "@types/react": "19.1.2",
115
- "@types/react-dom": "19.1.2",
111
+ "@types/node": "22.15.17",
112
+ "@types/react": "19.1.3",
113
+ "@types/react-dom": "19.1.3",
116
114
  "@vitejs/plugin-react": "4.4.1",
117
- "@vitest/browser": "3.1.2",
118
- "@vitest/coverage-istanbul": "3.1.2",
119
- "@vitest/coverage-v8": "3.1.2",
115
+ "@vitest/browser": "3.1.3",
116
+ "@vitest/coverage-istanbul": "3.1.3",
117
+ "@vitest/coverage-v8": "3.1.3",
120
118
  "chromatic": "11.28.2",
119
+ "conventional-changelog-cli": "^5.0.0",
121
120
  "cz-conventional-changelog": "3.3.0",
122
- "eslint": "9.25.1",
123
- "eslint-config-prettier": "10.1.2",
121
+ "eslint": "9.26.0",
122
+ "eslint-config-prettier": "10.1.5",
124
123
  "eslint-plugin-jsx-a11y": "6.10.2",
125
- "eslint-plugin-prettier": "5.2.6",
124
+ "eslint-plugin-prettier": "5.4.0",
126
125
  "eslint-plugin-react": "7.37.5",
127
126
  "eslint-plugin-react-hooks": "5.2.0",
128
- "lefthook": "1.11.11",
127
+ "lefthook": "1.11.12",
129
128
  "playwright": "1.52.0",
130
129
  "postcss": "8.5.3",
131
130
  "postcss-cli": "11.0.1",
@@ -138,15 +137,15 @@
138
137
  "resolve-tspaths": "0.8.23",
139
138
  "size-limit": "11.2.0",
140
139
  "storybook": "8.6.12",
141
- "stylelint": "16.18.0",
140
+ "stylelint": "16.19.1",
142
141
  "stylelint-config-prettier": "9.0.5",
143
142
  "stylelint-config-standard": "38.0.0",
144
143
  "ts-node": "10.9.2",
145
144
  "typescript": "5.8.3",
146
- "typescript-eslint": "8.31.0",
147
- "vite": "6.3.2",
145
+ "typescript-eslint": "8.32.0",
146
+ "vite": "6.3.5",
148
147
  "vite-tsconfig-paths": "5.1.4",
149
- "vitest": "3.1.2",
148
+ "vitest": "3.1.3",
150
149
  "vitest-browser-react": "0.1.1"
151
150
  },
152
151
  "peerDependencies": {
@@ -158,7 +157,7 @@
158
157
  "@csstools/postcss-global-data": "3.0.0",
159
158
  "chalk": "4.1.2",
160
159
  "commander": "13.1.0",
161
- "cssnano": "7.0.6",
160
+ "cssnano": "7.0.7",
162
161
  "csstype": "3.1.3",
163
162
  "culori": "4.0.1",
164
163
  "postcss-custom-media": "11.0.5"
@@ -1,39 +0,0 @@
1
- import { StoryObj } from "@storybook/react";
2
- import { fn } from "@storybook/test";
3
- declare const _default: {
4
- title: string;
5
- component: import("react").FC<import("./..").PopoverProps> & {
6
- Dismissible: import("react").FC<import("../../Dismissible").DismissibleProps>;
7
- Trigger: import("react").FC<import("../../Flyout").FlyoutTriggerProps>;
8
- Content: import("react").FC<import("../../Flyout").FlyoutContentProps>;
9
- };
10
- parameters: {
11
- iframe: {
12
- url: string;
13
- };
14
- chromatic: {
15
- disableSnapshot: boolean;
16
- };
17
- };
18
- };
19
- export default _default;
20
- export declare const defaultActive: StoryObj<{
21
- handleOpen: ReturnType<typeof fn>;
22
- handleClose: ReturnType<typeof fn>;
23
- }>;
24
- export declare const active: StoryObj<{
25
- handleOpen: ReturnType<typeof fn>;
26
- handleClose: ReturnType<typeof fn>;
27
- }>;
28
- export declare const activeFalse: StoryObj<{
29
- handleOpen: ReturnType<typeof fn>;
30
- handleClose: ReturnType<typeof fn>;
31
- }>;
32
- export declare const dismissible: StoryObj<{
33
- handleClose: ReturnType<typeof fn>;
34
- }>;
35
- export declare const triggerType: StoryObj<{
36
- handleOpen: ReturnType<typeof fn>;
37
- handleClose: ReturnType<typeof fn>;
38
- }>;
39
- export declare const className: StoryObj;