etudes 5.2.0 → 5.3.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 (164) hide show
  1. package/components/Accordion.js +171 -205
  2. package/components/BurgerButton.js +40 -94
  3. package/components/Carousel.js +87 -123
  4. package/components/Collection.js +84 -120
  5. package/components/Counter.js +32 -63
  6. package/components/CoverImage.js +24 -68
  7. package/components/CoverVideo.js +25 -69
  8. package/components/DebugConsole.js +27 -79
  9. package/components/Dial.js +28 -65
  10. package/components/Dropdown.js +86 -98
  11. package/components/FlatSVG.js +22 -71
  12. package/components/Image.js +21 -50
  13. package/components/MasonryGrid.js +122 -257
  14. package/components/Panorama.js +48 -92
  15. package/components/PanoramaSlider.js +57 -113
  16. package/components/RangeSlider.js +125 -182
  17. package/components/RotatingGallery.js +28 -59
  18. package/components/SelectableButton.js +10 -54
  19. package/components/Slider.js +108 -159
  20. package/components/StepwiseSlider.js +124 -176
  21. package/components/SwipeContainer.js +30 -73
  22. package/components/TextField.js +12 -49
  23. package/components/Video.js +31 -61
  24. package/components/WithTooltip.js +117 -111
  25. package/components/index.js +24 -0
  26. package/hooks/index.js +17 -0
  27. package/hooks/useClickOutsideEffect.js +8 -38
  28. package/hooks/useDragEffect.js +20 -53
  29. package/hooks/useDragValueEffect.js +31 -81
  30. package/hooks/useImageSize.js +16 -38
  31. package/hooks/useInterval.js +9 -41
  32. package/hooks/useLoadImageEffect.js +15 -48
  33. package/hooks/useLoadVideoMetadataEffect.js +15 -48
  34. package/hooks/useMounted.js +5 -25
  35. package/hooks/usePrevious.js +4 -9
  36. package/hooks/useRect.js +9 -29
  37. package/hooks/useResizeEffect.js +10 -44
  38. package/hooks/useScrollPositionEffect.js +19 -50
  39. package/hooks/useSearchParamState.js +12 -34
  40. package/hooks/useSize.js +9 -29
  41. package/hooks/useTimeout.js +8 -38
  42. package/hooks/useVideoSize.js +16 -38
  43. package/hooks/useViewportSize.js +7 -27
  44. package/operators/Conditional.js +6 -11
  45. package/operators/Each.js +6 -14
  46. package/operators/ExtractChild.js +9 -36
  47. package/operators/ExtractChildren.js +7 -34
  48. package/operators/Repeat.js +4 -37
  49. package/operators/index.js +5 -0
  50. package/package.json +27 -41
  51. package/providers/ScrollPositionProvider.js +37 -60
  52. package/providers/index.js +1 -0
  53. package/utils/asClassNameDict.js +1 -5
  54. package/utils/asComponentDict.js +11 -16
  55. package/utils/asStyleDict.js +1 -5
  56. package/utils/cloneStyledElement.js +14 -61
  57. package/utils/index.js +5 -22
  58. package/utils/styles.js +5 -21
  59. package/components/Accordion.d.ts +0 -219
  60. package/components/Accordion.js.map +0 -1
  61. package/components/BurgerButton.d.ts +0 -34
  62. package/components/BurgerButton.js.map +0 -1
  63. package/components/Carousel.d.ts +0 -53
  64. package/components/Carousel.js.map +0 -1
  65. package/components/Collection.d.ts +0 -171
  66. package/components/Collection.js.map +0 -1
  67. package/components/Counter.d.ts +0 -11
  68. package/components/Counter.js.map +0 -1
  69. package/components/CoverImage.d.ts +0 -28
  70. package/components/CoverImage.js.map +0 -1
  71. package/components/CoverVideo.d.ts +0 -28
  72. package/components/CoverVideo.js.map +0 -1
  73. package/components/DebugConsole.d.ts +0 -15
  74. package/components/DebugConsole.js.map +0 -1
  75. package/components/Dial.d.ts +0 -79
  76. package/components/Dial.js.map +0 -1
  77. package/components/Dropdown.d.ts +0 -109
  78. package/components/Dropdown.js.map +0 -1
  79. package/components/FlatSVG.d.ts +0 -72
  80. package/components/FlatSVG.js.map +0 -1
  81. package/components/Image.d.ts +0 -144
  82. package/components/Image.js.map +0 -1
  83. package/components/MasonryGrid.d.ts +0 -29
  84. package/components/MasonryGrid.js.map +0 -1
  85. package/components/Panorama.d.ts +0 -77
  86. package/components/Panorama.js.map +0 -1
  87. package/components/PanoramaSlider.d.ts +0 -71
  88. package/components/PanoramaSlider.js.map +0 -1
  89. package/components/RangeSlider.d.ts +0 -34
  90. package/components/RangeSlider.js.map +0 -1
  91. package/components/RotatingGallery.d.ts +0 -91
  92. package/components/RotatingGallery.js.map +0 -1
  93. package/components/SelectableButton.d.ts +0 -19
  94. package/components/SelectableButton.js.map +0 -1
  95. package/components/Slider.d.ts +0 -160
  96. package/components/Slider.js.map +0 -1
  97. package/components/StepwiseSlider.d.ts +0 -215
  98. package/components/StepwiseSlider.js.map +0 -1
  99. package/components/SwipeContainer.d.ts +0 -21
  100. package/components/SwipeContainer.js.map +0 -1
  101. package/components/TextField.d.ts +0 -21
  102. package/components/TextField.js.map +0 -1
  103. package/components/Video.d.ts +0 -38
  104. package/components/Video.js.map +0 -1
  105. package/components/WithTooltip.d.ts +0 -32
  106. package/components/WithTooltip.js.map +0 -1
  107. package/hooks/useClickOutsideEffect.d.ts +0 -2
  108. package/hooks/useClickOutsideEffect.js.map +0 -1
  109. package/hooks/useDragEffect.d.ts +0 -48
  110. package/hooks/useDragEffect.js.map +0 -1
  111. package/hooks/useDragValueEffect.d.ts +0 -56
  112. package/hooks/useDragValueEffect.js.map +0 -1
  113. package/hooks/useImageSize.d.ts +0 -21
  114. package/hooks/useImageSize.js.map +0 -1
  115. package/hooks/useInterval.d.ts +0 -18
  116. package/hooks/useInterval.js.map +0 -1
  117. package/hooks/useLoadImageEffect.d.ts +0 -43
  118. package/hooks/useLoadImageEffect.js.map +0 -1
  119. package/hooks/useLoadVideoMetadataEffect.d.ts +0 -35
  120. package/hooks/useLoadVideoMetadataEffect.js.map +0 -1
  121. package/hooks/useMounted.d.ts +0 -1
  122. package/hooks/useMounted.js.map +0 -1
  123. package/hooks/usePrevious.d.ts +0 -19
  124. package/hooks/usePrevious.js.map +0 -1
  125. package/hooks/useRect.d.ts +0 -11
  126. package/hooks/useRect.js.map +0 -1
  127. package/hooks/useResizeEffect.d.ts +0 -17
  128. package/hooks/useResizeEffect.js.map +0 -1
  129. package/hooks/useScrollPositionEffect.d.ts +0 -13
  130. package/hooks/useScrollPositionEffect.js.map +0 -1
  131. package/hooks/useSearchParamState.d.ts +0 -34
  132. package/hooks/useSearchParamState.js.map +0 -1
  133. package/hooks/useSize.d.ts +0 -10
  134. package/hooks/useSize.js.map +0 -1
  135. package/hooks/useTimeout.d.ts +0 -10
  136. package/hooks/useTimeout.js.map +0 -1
  137. package/hooks/useVideoSize.d.ts +0 -21
  138. package/hooks/useVideoSize.js.map +0 -1
  139. package/hooks/useViewportSize.d.ts +0 -7
  140. package/hooks/useViewportSize.js.map +0 -1
  141. package/operators/Conditional.d.ts +0 -5
  142. package/operators/Conditional.js.map +0 -1
  143. package/operators/Each.d.ts +0 -7
  144. package/operators/Each.js.map +0 -1
  145. package/operators/ExtractChild.d.ts +0 -8
  146. package/operators/ExtractChild.js.map +0 -1
  147. package/operators/ExtractChildren.d.ts +0 -6
  148. package/operators/ExtractChildren.js.map +0 -1
  149. package/operators/Repeat.d.ts +0 -11
  150. package/operators/Repeat.js.map +0 -1
  151. package/providers/ScrollPositionProvider.d.ts +0 -15
  152. package/providers/ScrollPositionProvider.js.map +0 -1
  153. package/utils/asClassNameDict.d.ts +0 -3
  154. package/utils/asClassNameDict.js.map +0 -1
  155. package/utils/asComponentDict.d.ts +0 -5
  156. package/utils/asComponentDict.js.map +0 -1
  157. package/utils/asStyleDict.d.ts +0 -4
  158. package/utils/asStyleDict.js.map +0 -1
  159. package/utils/cloneStyledElement.d.ts +0 -18
  160. package/utils/cloneStyledElement.js.map +0 -1
  161. package/utils/index.d.ts +0 -5
  162. package/utils/index.js.map +0 -1
  163. package/utils/styles.d.ts +0 -2
  164. package/utils/styles.js.map +0 -1
@@ -1,47 +1,17 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- var __importDefault = (this && this.__importDefault) || function (mod) {
25
- return (mod && mod.__esModule) ? mod : { "default": mod };
26
- };
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.Dropdown = void 0;
29
- var jsx_runtime_1 = require("react/jsx-runtime");
30
- var clsx_1 = __importDefault(require("clsx"));
31
- var react_1 = require("react");
32
- var useRect_1 = require("../hooks/useRect");
33
- var utils_1 = require("../utils");
34
- var Collection_1 = require("./Collection");
35
- var FlatSVG_1 = require("./FlatSVG");
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import clsx from 'clsx';
3
+ import { forwardRef, useEffect, useRef } from 'react';
4
+ import { useRect } from '../hooks/useRect.js';
5
+ import { asStyleDict, cloneStyledElement, styles } from '../utils/index.js';
6
+ import { Collection } from './Collection.js';
7
+ import { FlatSVG } from './FlatSVG.js';
36
8
  /**
37
9
  * A dropdown component that is invertible (i.e. can "dropup" instead) and
38
10
  * supports both horizontal and vertical orientations. Provide `items` and
39
11
  * `ItemComponent` props to populate.
40
12
  */
41
- exports.Dropdown = (0, react_1.forwardRef)(function (_a, ref) {
42
- var _b;
43
- var children = _a.children, className = _a.className, style = _a.style, collapseIconSvg = _a.collapseIconSvg, _c = _a.collapsesOnSelect, collapsesOnSelect = _c === void 0 ? true : _c, _d = _a.collectionPadding, collectionPadding = _d === void 0 ? 0 : _d, expandIconSvg = _a.expandIconSvg, _e = _a.isCollapsed, isCollapsed = _e === void 0 ? true : _e, _f = _a.isInverted, isInverted = _f === void 0 ? false : _f, label = _a.label, layout = _a.layout, _g = _a.isSelectionTogglable, isSelectionTogglable = _g === void 0 ? false : _g, externalItemLength = _a.itemLength, _h = _a.itemPadding, itemPadding = _h === void 0 ? 0 : _h, items = _a.items, _j = _a.maxVisibleItems, maxVisibleItems = _j === void 0 ? -1 : _j, numSegments = _a.numSegments, _k = _a.orientation, orientation = _k === void 0 ? 'vertical' : _k, _l = _a.selection, externalSelection = _l === void 0 ? [] : _l, _m = _a.selectionMode, selectionMode = _m === void 0 ? 'single' : _m, _o = _a.usesDefaultStyles, usesDefaultStyles = _o === void 0 ? false : _o, onActivateAt = _a.onActivateAt, onCollapse = _a.onCollapse, onDeselectAt = _a.onDeselectAt, onExpand = _a.onExpand, onSelectAt = _a.onSelectAt, onSelectionChange = _a.onSelectionChange, onToggleCustomEvent = _a.onToggleCustomEvent, ItemComponent = _a.ItemComponent, ToggleComponent = _a.ToggleComponent, props = __rest(_a, ["children", "className", "style", "collapseIconSvg", "collapsesOnSelect", "collectionPadding", "expandIconSvg", "isCollapsed", "isInverted", "label", "layout", "isSelectionTogglable", "itemLength", "itemPadding", "items", "maxVisibleItems", "numSegments", "orientation", "selection", "selectionMode", "usesDefaultStyles", "onActivateAt", "onCollapse", "onDeselectAt", "onExpand", "onSelectAt", "onSelectionChange", "onToggleCustomEvent", "ItemComponent", "ToggleComponent"]);
44
- var isIndexOutOfRange = function (index) {
13
+ export const Dropdown = forwardRef(({ children, className, style, collapseIconSvg, collapsesOnSelect = true, collectionPadding = 0, expandIconSvg, isCollapsed = true, isInverted = false, label, layout, isSelectionTogglable = false, itemLength: externalItemLength, itemPadding = 0, items, maxVisibleItems = -1, numSegments, orientation = 'vertical', selection: externalSelection = [], selectionMode = 'single', usesDefaultStyles = false, onActivateAt, onCollapse, onDeselectAt, onExpand, onSelectAt, onSelectionChange, onToggleCustomEvent, ItemComponent, ToggleComponent, ...props }, ref) => {
14
+ const isIndexOutOfRange = (index) => {
45
15
  if (isNaN(index))
46
16
  return true;
47
17
  if (index >= items.length)
@@ -50,18 +20,18 @@ exports.Dropdown = (0, react_1.forwardRef)(function (_a, ref) {
50
20
  return true;
51
21
  return false;
52
22
  };
53
- var sanitizedSelection = function (selection) { return sortIndices(selection).filter(function (t) { return !isIndexOutOfRange(t); }); };
54
- var expand = function () {
23
+ const sanitizedSelection = (selection) => sortIndices(selection).filter(t => !isIndexOutOfRange(t));
24
+ const expand = () => {
55
25
  if (!isCollapsed)
56
26
  return;
57
- onExpand === null || onExpand === void 0 ? void 0 : onExpand();
27
+ onExpand?.();
58
28
  };
59
- var collapse = function () {
29
+ const collapse = () => {
60
30
  if (isCollapsed)
61
31
  return;
62
- onCollapse === null || onCollapse === void 0 ? void 0 : onCollapse();
32
+ onCollapse?.();
63
33
  };
64
- var toggle = function () {
34
+ const toggle = () => {
65
35
  if (isCollapsed) {
66
36
  expand();
67
37
  }
@@ -69,33 +39,33 @@ exports.Dropdown = (0, react_1.forwardRef)(function (_a, ref) {
69
39
  collapse();
70
40
  }
71
41
  };
72
- var selectAtHandler = function (index) {
73
- onSelectAt === null || onSelectAt === void 0 ? void 0 : onSelectAt(index);
42
+ const selectAtHandler = (index) => {
43
+ onSelectAt?.(index);
74
44
  if (selectionMode === 'single' && collapsesOnSelect)
75
45
  collapse();
76
46
  };
77
- var selectionChangeHandler = function (value) {
78
- onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(value);
47
+ const selectionChangeHandler = (value) => {
48
+ onSelectionChange?.(value);
79
49
  };
80
- var selection = sanitizedSelection(externalSelection);
81
- var bodyRef = (0, react_1.useRef)(null);
82
- var bodyRect = (0, useRect_1.useRect)(bodyRef);
83
- var itemLength = externalItemLength !== null && externalItemLength !== void 0 ? externalItemLength : (orientation === 'vertical' ? bodyRect.height : bodyRect.width);
84
- var numItems = items.length;
85
- var numVisibleItems = maxVisibleItems < 0 ? numItems : Math.min(numItems, maxVisibleItems);
86
- var menuLength = itemLength * numVisibleItems + itemPadding * (numVisibleItems - 1);
87
- var fixedStyles = getFixedStyles({ isCollapsed: isCollapsed, isInverted: isInverted, maxVisibleItems: maxVisibleItems, menuLength: menuLength, numItems: numItems, orientation: orientation });
88
- var defaultStyles = usesDefaultStyles ? getDefaultStyles({ orientation: orientation }) : undefined;
89
- var ExpandIcon = expandIconSvg ? (0, jsx_runtime_1.jsx)(FlatSVG_1.FlatSVG, { style: defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.expandIcon, svg: expandIconSvg }) : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
90
- var CollapseIcon = collapseIconSvg ? (0, jsx_runtime_1.jsx)(FlatSVG_1.FlatSVG, { style: defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.collapseIcon, svg: collapseIconSvg }) : ExpandIcon;
91
- (0, react_1.useEffect)(function () {
92
- var clickOutsideHandler = function (event) {
50
+ const selection = sanitizedSelection(externalSelection);
51
+ const bodyRef = useRef(null);
52
+ const bodyRect = useRect(bodyRef);
53
+ const itemLength = externalItemLength ?? (orientation === 'vertical' ? bodyRect.height : bodyRect.width);
54
+ const numItems = items.length;
55
+ const numVisibleItems = maxVisibleItems < 0 ? numItems : Math.min(numItems, maxVisibleItems);
56
+ const menuLength = itemLength * numVisibleItems + itemPadding * (numVisibleItems - 1);
57
+ const fixedStyles = getFixedStyles({ isCollapsed, isInverted, maxVisibleItems, menuLength, numItems, orientation });
58
+ const defaultStyles = usesDefaultStyles ? getDefaultStyles({ orientation }) : undefined;
59
+ const ExpandIcon = expandIconSvg ? _jsx(FlatSVG, { style: defaultStyles?.expandIcon, svg: expandIconSvg }) : _jsx(_Fragment, {});
60
+ const CollapseIcon = collapseIconSvg ? _jsx(FlatSVG, { style: defaultStyles?.collapseIcon, svg: collapseIconSvg }) : ExpandIcon;
61
+ useEffect(() => {
62
+ const clickOutsideHandler = (event) => {
93
63
  if (isCollapsed)
94
64
  return;
95
65
  if (!(event.target instanceof Node))
96
66
  return;
97
- var isOutside = true;
98
- var node = event.target;
67
+ let isOutside = true;
68
+ let node = event.target;
99
69
  while (node) {
100
70
  if (node === bodyRef.current) {
101
71
  isOutside = false;
@@ -110,24 +80,29 @@ exports.Dropdown = (0, react_1.forwardRef)(function (_a, ref) {
110
80
  collapse();
111
81
  };
112
82
  window.addEventListener('click', clickOutsideHandler);
113
- return function () {
83
+ return () => {
114
84
  window.removeEventListener('click', clickOutsideHandler);
115
85
  };
116
86
  }, [isCollapsed]);
117
- return ((0, jsx_runtime_1.jsx)("div", __assign({}, props, { ref: ref, className: (0, clsx_1.default)(className, { collapsed: isCollapsed, expanded: !isCollapsed }), "data-component": 'dropdown', style: (0, utils_1.styles)(style, fixedStyles.root), children: (0, jsx_runtime_1.jsxs)("div", { ref: bodyRef, style: (0, utils_1.styles)(fixedStyles.body), children: [ToggleComponent ? ((0, jsx_runtime_1.jsx)(ToggleComponent, { "data-child": 'toggle', style: (0, utils_1.styles)(fixedStyles.toggle), onClick: function () { return toggle(); }, onCustomEvent: function (name, info) { return onToggleCustomEvent === null || onToggleCustomEvent === void 0 ? void 0 : onToggleCustomEvent(name, info); } })) : ((0, jsx_runtime_1.jsxs)("button", { "data-child": 'toggle', style: (0, utils_1.styles)(fixedStyles.toggle, defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.toggle), onClick: function () { return toggle(); }, children: [(0, jsx_runtime_1.jsx)("span", { dangerouslySetInnerHTML: { __html: (_b = label === null || label === void 0 ? void 0 : label(selection)) !== null && _b !== void 0 ? _b : (selection.length > 0 ? selection.map(function (t) { return items[t].label; }).join(', ') : '') }, style: fixedStyles.toggleLabel }), (0, utils_1.cloneStyledElement)(isCollapsed ? ExpandIcon : CollapseIcon)] })), (0, jsx_runtime_1.jsx)(Collection_1.Collection, { "data-child": 'collection', isSelectionTogglable: isSelectionTogglable, ItemComponent: ItemComponent, itemLength: itemLength, itemPadding: itemPadding, items: items, layout: layout, numSegments: numSegments, orientation: orientation, selection: selection, selectionMode: selectionMode, style: (0, utils_1.styles)(fixedStyles.collection, defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.collection), onActivateAt: onActivateAt, onDeselectAt: onDeselectAt, onSelectAt: selectAtHandler, onSelectionChange: selectionChangeHandler })] }) })));
87
+ return (_jsx("div", { ...props, ref: ref, className: clsx(className, { collapsed: isCollapsed, expanded: !isCollapsed }), "data-component": 'dropdown', style: styles(style, fixedStyles.root), children: _jsxs("div", { ref: bodyRef, style: styles(fixedStyles.body), children: [ToggleComponent ? (_jsx(ToggleComponent, { "data-child": 'toggle', style: styles(fixedStyles.toggle), onClick: () => toggle(), onCustomEvent: (name, info) => onToggleCustomEvent?.(name, info) })) : (_jsxs("button", { "data-child": 'toggle', style: styles(fixedStyles.toggle, defaultStyles?.toggle), onClick: () => toggle(), children: [_jsx("span", { dangerouslySetInnerHTML: { __html: label?.(selection) ?? (selection.length > 0 ? selection.map(t => items[t].label).join(', ') : '') }, style: fixedStyles.toggleLabel }), cloneStyledElement(isCollapsed ? ExpandIcon : CollapseIcon)] })), _jsx(Collection, { "data-child": 'collection', isSelectionTogglable: isSelectionTogglable, ItemComponent: ItemComponent, itemLength: itemLength, itemPadding: itemPadding, items: items, layout: layout, numSegments: numSegments, orientation: orientation, selection: selection, selectionMode: selectionMode, style: styles(fixedStyles.collection, defaultStyles?.collection), onActivateAt: onActivateAt, onDeselectAt: onDeselectAt, onSelectAt: selectAtHandler, onSelectionChange: selectionChangeHandler })] }) }));
118
88
  });
119
- Object.defineProperty(exports.Dropdown, 'displayName', { value: 'Dropdown', writable: false });
89
+ Object.defineProperty(Dropdown, 'displayName', { value: 'Dropdown', writable: false });
120
90
  function sortIndices(indices) {
121
- return indices.sort(function (a, b) { return a - b; });
91
+ return indices.sort((a, b) => a - b);
122
92
  }
123
- function getFixedStyles(_a) {
124
- var _b = _a.isCollapsed, isCollapsed = _b === void 0 ? true : _b, _c = _a.isInverted, isInverted = _c === void 0 ? false : _c, _d = _a.collectionPadding, collectionPadding = _d === void 0 ? 0 : _d, _e = _a.maxVisibleItems, maxVisibleItems = _e === void 0 ? 0 : _e, _f = _a.menuLength, menuLength = _f === void 0 ? NaN : _f, _g = _a.numItems, numItems = _g === void 0 ? 0 : _g, _h = _a.orientation, orientation = _h === void 0 ? 'vertical' : _h;
125
- return (0, utils_1.asStyleDict)({
126
- root: __assign({ alignItems: 'center', display: 'flex', justifyContent: 'flex-start', overflow: 'visible' }, orientation === 'vertical' ? {
127
- flexDirection: isInverted ? 'column-reverse' : 'column',
128
- } : {
129
- flexDirection: isInverted ? 'row-reverse' : 'row',
130
- }),
93
+ function getFixedStyles({ isCollapsed = true, isInverted = false, collectionPadding = 0, maxVisibleItems = 0, menuLength = NaN, numItems = 0, orientation = 'vertical' }) {
94
+ return asStyleDict({
95
+ root: {
96
+ alignItems: 'center',
97
+ display: 'flex',
98
+ justifyContent: 'flex-start',
99
+ overflow: 'visible',
100
+ ...orientation === 'vertical' ? {
101
+ flexDirection: isInverted ? 'column-reverse' : 'column',
102
+ } : {
103
+ flexDirection: isInverted ? 'row-reverse' : 'row',
104
+ },
105
+ },
131
106
  body: {
132
107
  height: '100%',
133
108
  width: '100%',
@@ -148,24 +123,36 @@ function getFixedStyles(_a) {
148
123
  letterSpacing: 'inherit',
149
124
  lineHeight: 'inherit',
150
125
  },
151
- collection: __assign({ position: 'absolute' }, orientation === 'vertical' ? __assign({ width: '100%', height: isCollapsed ? '0px' : "".concat(menuLength, "px"), overflowY: maxVisibleItems !== -1 && maxVisibleItems < numItems ? 'scroll' : 'hidden' }, isInverted ? {
152
- marginBottom: "".concat(collectionPadding, "px"),
153
- bottom: '100%',
154
- } : {
155
- top: '100%',
156
- marginTop: "".concat(collectionPadding, "px"),
157
- }) : __assign({ width: isCollapsed ? '0px' : "".concat(menuLength, "px"), height: '100%', overflowX: maxVisibleItems !== -1 && maxVisibleItems < numItems ? 'scroll' : 'hidden' }, isInverted ? {
158
- marginRight: "".concat(collectionPadding, "px"),
159
- right: '100%',
160
- } : {
161
- left: '100%',
162
- marginLeft: "".concat(collectionPadding, "px"),
163
- })),
126
+ collection: {
127
+ position: 'absolute',
128
+ ...orientation === 'vertical' ? {
129
+ width: '100%',
130
+ height: isCollapsed ? '0px' : `${menuLength}px`,
131
+ overflowY: maxVisibleItems !== -1 && maxVisibleItems < numItems ? 'scroll' : 'hidden',
132
+ ...isInverted ? {
133
+ marginBottom: `${collectionPadding}px`,
134
+ bottom: '100%',
135
+ } : {
136
+ top: '100%',
137
+ marginTop: `${collectionPadding}px`,
138
+ },
139
+ } : {
140
+ width: isCollapsed ? '0px' : `${menuLength}px`,
141
+ height: '100%',
142
+ overflowX: maxVisibleItems !== -1 && maxVisibleItems < numItems ? 'scroll' : 'hidden',
143
+ ...isInverted ? {
144
+ marginRight: `${collectionPadding}px`,
145
+ right: '100%',
146
+ } : {
147
+ left: '100%',
148
+ marginLeft: `${collectionPadding}px`,
149
+ },
150
+ },
151
+ },
164
152
  });
165
153
  }
166
- function getDefaultStyles(_a) {
167
- var _b = _a.orientation, orientation = _b === void 0 ? 'vertical' : _b;
168
- return (0, utils_1.asStyleDict)({
154
+ function getDefaultStyles({ orientation = 'vertical' }) {
155
+ return asStyleDict({
169
156
  toggle: {
170
157
  alignItems: 'center',
171
158
  background: '#fff',
@@ -190,11 +177,12 @@ function getDefaultStyles(_a) {
190
177
  padding: '0',
191
178
  width: '15px',
192
179
  },
193
- collection: __assign({}, orientation === 'vertical' ? {
194
- transition: 'height 100ms ease-out',
195
- } : {
196
- transition: 'width 100ms ease-out',
197
- }),
180
+ collection: {
181
+ ...orientation === 'vertical' ? {
182
+ transition: 'height 100ms ease-out',
183
+ } : {
184
+ transition: 'width 100ms ease-out',
185
+ },
186
+ },
198
187
  });
199
188
  }
200
- //# sourceMappingURL=Dropdown.js.map
@@ -1,93 +1,44 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- var __values = (this && this.__values) || function(o) {
25
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
26
- if (m) return m.call(o);
27
- if (o && typeof o.length === "number") return {
28
- next: function () {
29
- if (o && i >= o.length) o = void 0;
30
- return { value: o && o[i++], done: !o };
31
- }
32
- };
33
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.FlatSVG = void 0;
37
- var jsx_runtime_1 = require("react/jsx-runtime");
38
- var fast_xml_parser_1 = require("fast-xml-parser");
39
- var react_1 = require("react");
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { XMLBuilder, XMLParser } from 'fast-xml-parser';
3
+ import { forwardRef } from 'react';
40
4
  /**
41
5
  * A component whose root element wraps an SVG markup. When wrapping the SVG, it
42
6
  * will attempt to sanitize the markup (i.e. stripping useless attributes)
43
7
  * according to the props specified.
44
8
  */
45
- exports.FlatSVG = (0, react_1.forwardRef)(function (_a, ref) {
46
- var svg = _a.svg, _b = _a.shouldStripClasses, shouldStripClasses = _b === void 0 ? true : _b, _c = _a.shouldStripExtraneousAttributes, shouldStripExtraneousAttributes = _c === void 0 ? true : _c, _d = _a.shouldStripIds, shouldStripIds = _d === void 0 ? true : _d, _e = _a.shouldStripStyles, shouldStripStyles = _e === void 0 ? true : _e, _f = _a.whitelistedAttributes, whitelistedAttributes = _f === void 0 ? ['viewBox'] : _f, props = __rest(_a, ["svg", "shouldStripClasses", "shouldStripExtraneousAttributes", "shouldStripIds", "shouldStripStyles", "whitelistedAttributes"]);
47
- var attributeNamePrefix = '@_';
48
- var sanitizedMarkup = function () {
49
- var parser = new fast_xml_parser_1.XMLParser({
50
- attributeNamePrefix: attributeNamePrefix,
9
+ export const FlatSVG = forwardRef(({ svg, shouldStripClasses = true, shouldStripExtraneousAttributes = true, shouldStripIds = true, shouldStripStyles = true, whitelistedAttributes = ['viewBox'], ...props }, ref) => {
10
+ const attributeNamePrefix = '@_';
11
+ const sanitizedMarkup = () => {
12
+ const parser = new XMLParser({
13
+ attributeNamePrefix,
51
14
  ignoreAttributes: false,
52
15
  ignoreDeclaration: true,
53
16
  ignorePiTags: true,
54
17
  removeNSPrefix: true,
55
18
  trimValues: true,
56
- updateTag: function (tagName, jPath, attrs) {
57
- var e_1, _a;
19
+ updateTag: (tagName, jPath, attrs) => {
58
20
  if (shouldStripStyles && tagName === 'style')
59
21
  return false;
60
- var attrNames = Object.keys(attrs);
61
- try {
62
- for (var attrNames_1 = __values(attrNames), attrNames_1_1 = attrNames_1.next(); !attrNames_1_1.done; attrNames_1_1 = attrNames_1.next()) {
63
- var attrName = attrNames_1_1.value;
64
- if (shouldStripIds && attrName.toLowerCase() === "".concat(attributeNamePrefix, "id"))
65
- delete attrs[attrName];
66
- if (shouldStripClasses && attrName.toLowerCase() === "".concat(attributeNamePrefix, "class"))
67
- delete attrs[attrName];
68
- if (shouldStripStyles && attrName.toLowerCase() === "".concat(attributeNamePrefix, "style"))
69
- delete attrs[attrName];
70
- }
71
- }
72
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
73
- finally {
74
- try {
75
- if (attrNames_1_1 && !attrNames_1_1.done && (_a = attrNames_1.return)) _a.call(attrNames_1);
76
- }
77
- finally { if (e_1) throw e_1.error; }
22
+ const attrNames = Object.keys(attrs);
23
+ for (const attrName of attrNames) {
24
+ if (shouldStripIds && attrName.toLowerCase() === `${attributeNamePrefix}id`)
25
+ delete attrs[attrName];
26
+ if (shouldStripClasses && attrName.toLowerCase() === `${attributeNamePrefix}class`)
27
+ delete attrs[attrName];
28
+ if (shouldStripStyles && attrName.toLowerCase() === `${attributeNamePrefix}style`)
29
+ delete attrs[attrName];
78
30
  }
79
31
  return tagName;
80
32
  },
81
33
  });
82
- var builder = new fast_xml_parser_1.XMLBuilder({
83
- attributeNamePrefix: attributeNamePrefix,
34
+ const builder = new XMLBuilder({
35
+ attributeNamePrefix,
84
36
  format: true,
85
37
  ignoreAttributes: false,
86
38
  });
87
- var xml = parser.parse(svg);
39
+ const xml = parser.parse(svg);
88
40
  return builder.build(xml);
89
41
  };
90
- return ((0, jsx_runtime_1.jsx)("figure", __assign({}, props, { ref: ref, dangerouslySetInnerHTML: { __html: sanitizedMarkup() }, "data-component": 'flat-svg' })));
42
+ return (_jsx("figure", { ...props, ref: ref, dangerouslySetInnerHTML: { __html: sanitizedMarkup() }, "data-component": 'flat-svg' }));
91
43
  });
92
- Object.defineProperty(exports.FlatSVG, 'displayName', { value: 'FlatSVG', writable: false });
93
- //# sourceMappingURL=FlatSVG.js.map
44
+ Object.defineProperty(FlatSVG, 'displayName', { value: 'FlatSVG', writable: false });
@@ -1,76 +1,47 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.Image = void 0;
26
- var jsx_runtime_1 = require("react/jsx-runtime");
27
- var react_1 = require("react");
28
- var useImageSize_1 = require("../hooks/useImageSize");
29
- exports.Image = (0, react_1.forwardRef)(function (_a, ref) {
30
- var alt = _a.alt, _b = _a.loadingMode, loadingMode = _b === void 0 ? 'preload' : _b, sizes = _a.sizes, fallbackSrc = _a.src, srcSet = _a.srcSet, onLoadStart = _a.onLoadStart, onLoadComplete = _a.onLoadComplete, onLoadError = _a.onLoadError, onSizeChange = _a.onSizeChange, props = __rest(_a, ["alt", "loadingMode", "sizes", "src", "srcSet", "onLoadStart", "onLoadComplete", "onLoadError", "onSizeChange"]);
31
- var srcSetValue = srcSet === null || srcSet === void 0 ? void 0 : srcSet.map(function (_a) {
32
- var pixelDensity = _a.pixelDensity, src = _a.src, width = _a.width;
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect } from 'react';
3
+ import { useImageSize } from '../hooks/useImageSize.js';
4
+ export const Image = forwardRef(({ alt, loadingMode = 'preload', sizes, src: fallbackSrc, srcSet, onLoadStart, onLoadComplete, onLoadError, onSizeChange, ...props }, ref) => {
5
+ const srcSetValue = srcSet?.map(({ pixelDensity, src, width }) => {
33
6
  if (sizes && width === undefined)
34
7
  throw Error('`width` must be specified if `sizes` is specified');
35
8
  if (width !== undefined && pixelDensity !== undefined)
36
9
  throw Error('Only one of `width` or `pixelDensity` can be specified.');
37
- var t = src;
10
+ let t = src;
38
11
  if (width !== undefined) {
39
- var w = Math.floor(width);
12
+ const w = Math.floor(width);
40
13
  if (!isFinite(w) || String(w) !== String(width) || w <= 0)
41
14
  throw Error('The specified width must be a positive integer greater than 0');
42
- t += " ".concat(w, "w");
15
+ t += ` ${w}w`;
43
16
  }
44
17
  else if (pixelDensity !== undefined) {
45
18
  if (!isFinite(pixelDensity) || pixelDensity <= 0)
46
19
  throw Error('The specified pixel density must be a positive floating number than 0');
47
- t += " ".concat(pixelDensity, "x");
20
+ t += ` ${pixelDensity}x`;
48
21
  }
49
22
  return t;
50
23
  }).join(', ');
51
- var sizesValue = sizes === null || sizes === void 0 ? void 0 : sizes.map(function (_a, idx) {
52
- var mediaCondition = _a.mediaCondition, width = _a.width;
53
- var isLast = idx === sizes.length - 1;
54
- var t = width;
24
+ const sizesValue = sizes?.map(({ mediaCondition, width }, idx) => {
25
+ const isLast = idx === sizes.length - 1;
26
+ let t = width;
55
27
  if (isLast && mediaCondition)
56
28
  throw Error('The last item in `sizes` must not have a `mediaCondition` specified.');
57
29
  if (mediaCondition)
58
- t = "".concat(mediaCondition, " ").concat(t);
30
+ t = `${mediaCondition} ${t}`;
59
31
  return t;
60
32
  }).join(', ');
61
- var size = (0, useImageSize_1.useImageSize)({
33
+ const size = useImageSize({
62
34
  src: fallbackSrc,
63
35
  srcSet: srcSetValue,
64
36
  sizes: sizesValue,
65
37
  }, {
66
- onLoadStart: onLoadStart,
67
- onLoadComplete: onLoadComplete,
68
- onLoadError: onLoadError,
38
+ onLoadStart,
39
+ onLoadComplete,
40
+ onLoadError,
69
41
  });
70
- (0, react_1.useEffect)(function () {
71
- onSizeChange === null || onSizeChange === void 0 ? void 0 : onSizeChange(size);
42
+ useEffect(() => {
43
+ onSizeChange?.(size);
72
44
  }, [size]);
73
- return ((0, jsx_runtime_1.jsx)("img", __assign({}, props, { ref: ref, alt: alt, "data-component": 'image', loading: loadingMode === 'lazy' ? 'lazy' : 'eager', sizes: sizesValue, src: fallbackSrc, srcSet: srcSetValue })));
45
+ return (_jsx("img", { ...props, ref: ref, alt: alt, "data-component": 'image', loading: loadingMode === 'lazy' ? 'lazy' : 'eager', sizes: sizesValue, src: fallbackSrc, srcSet: srcSetValue }));
74
46
  });
75
- Object.defineProperty(exports.Image, 'displayName', { value: 'Image', writable: false });
76
- //# sourceMappingURL=Image.js.map
47
+ Object.defineProperty(Image, 'displayName', { value: 'Image', writable: false });