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.
- package/components/Accordion.js +171 -205
- package/components/BurgerButton.js +40 -94
- package/components/Carousel.js +87 -123
- package/components/Collection.js +84 -120
- package/components/Counter.js +32 -63
- package/components/CoverImage.js +24 -68
- package/components/CoverVideo.js +25 -69
- package/components/DebugConsole.js +27 -79
- package/components/Dial.js +28 -65
- package/components/Dropdown.js +86 -98
- package/components/FlatSVG.js +22 -71
- package/components/Image.js +21 -50
- package/components/MasonryGrid.js +122 -257
- package/components/Panorama.js +48 -92
- package/components/PanoramaSlider.js +57 -113
- package/components/RangeSlider.js +125 -182
- package/components/RotatingGallery.js +28 -59
- package/components/SelectableButton.js +10 -54
- package/components/Slider.js +108 -159
- package/components/StepwiseSlider.js +124 -176
- package/components/SwipeContainer.js +30 -73
- package/components/TextField.js +12 -49
- package/components/Video.js +31 -61
- package/components/WithTooltip.js +117 -111
- package/components/index.js +24 -0
- package/hooks/index.js +17 -0
- package/hooks/useClickOutsideEffect.js +8 -38
- package/hooks/useDragEffect.js +20 -53
- package/hooks/useDragValueEffect.js +31 -81
- package/hooks/useImageSize.js +16 -38
- package/hooks/useInterval.js +9 -41
- package/hooks/useLoadImageEffect.js +15 -48
- package/hooks/useLoadVideoMetadataEffect.js +15 -48
- package/hooks/useMounted.js +5 -25
- package/hooks/usePrevious.js +4 -9
- package/hooks/useRect.js +9 -29
- package/hooks/useResizeEffect.js +10 -44
- package/hooks/useScrollPositionEffect.js +19 -50
- package/hooks/useSearchParamState.js +12 -34
- package/hooks/useSize.js +9 -29
- package/hooks/useTimeout.js +8 -38
- package/hooks/useVideoSize.js +16 -38
- package/hooks/useViewportSize.js +7 -27
- package/operators/Conditional.js +6 -11
- package/operators/Each.js +6 -14
- package/operators/ExtractChild.js +9 -36
- package/operators/ExtractChildren.js +7 -34
- package/operators/Repeat.js +4 -37
- package/operators/index.js +5 -0
- package/package.json +27 -41
- package/providers/ScrollPositionProvider.js +37 -60
- package/providers/index.js +1 -0
- package/utils/asClassNameDict.js +1 -5
- package/utils/asComponentDict.js +11 -16
- package/utils/asStyleDict.js +1 -5
- package/utils/cloneStyledElement.js +14 -61
- package/utils/index.js +5 -22
- package/utils/styles.js +5 -21
- package/components/Accordion.d.ts +0 -219
- package/components/Accordion.js.map +0 -1
- package/components/BurgerButton.d.ts +0 -34
- package/components/BurgerButton.js.map +0 -1
- package/components/Carousel.d.ts +0 -53
- package/components/Carousel.js.map +0 -1
- package/components/Collection.d.ts +0 -171
- package/components/Collection.js.map +0 -1
- package/components/Counter.d.ts +0 -11
- package/components/Counter.js.map +0 -1
- package/components/CoverImage.d.ts +0 -28
- package/components/CoverImage.js.map +0 -1
- package/components/CoverVideo.d.ts +0 -28
- package/components/CoverVideo.js.map +0 -1
- package/components/DebugConsole.d.ts +0 -15
- package/components/DebugConsole.js.map +0 -1
- package/components/Dial.d.ts +0 -79
- package/components/Dial.js.map +0 -1
- package/components/Dropdown.d.ts +0 -109
- package/components/Dropdown.js.map +0 -1
- package/components/FlatSVG.d.ts +0 -72
- package/components/FlatSVG.js.map +0 -1
- package/components/Image.d.ts +0 -144
- package/components/Image.js.map +0 -1
- package/components/MasonryGrid.d.ts +0 -29
- package/components/MasonryGrid.js.map +0 -1
- package/components/Panorama.d.ts +0 -77
- package/components/Panorama.js.map +0 -1
- package/components/PanoramaSlider.d.ts +0 -71
- package/components/PanoramaSlider.js.map +0 -1
- package/components/RangeSlider.d.ts +0 -34
- package/components/RangeSlider.js.map +0 -1
- package/components/RotatingGallery.d.ts +0 -91
- package/components/RotatingGallery.js.map +0 -1
- package/components/SelectableButton.d.ts +0 -19
- package/components/SelectableButton.js.map +0 -1
- package/components/Slider.d.ts +0 -160
- package/components/Slider.js.map +0 -1
- package/components/StepwiseSlider.d.ts +0 -215
- package/components/StepwiseSlider.js.map +0 -1
- package/components/SwipeContainer.d.ts +0 -21
- package/components/SwipeContainer.js.map +0 -1
- package/components/TextField.d.ts +0 -21
- package/components/TextField.js.map +0 -1
- package/components/Video.d.ts +0 -38
- package/components/Video.js.map +0 -1
- package/components/WithTooltip.d.ts +0 -32
- package/components/WithTooltip.js.map +0 -1
- package/hooks/useClickOutsideEffect.d.ts +0 -2
- package/hooks/useClickOutsideEffect.js.map +0 -1
- package/hooks/useDragEffect.d.ts +0 -48
- package/hooks/useDragEffect.js.map +0 -1
- package/hooks/useDragValueEffect.d.ts +0 -56
- package/hooks/useDragValueEffect.js.map +0 -1
- package/hooks/useImageSize.d.ts +0 -21
- package/hooks/useImageSize.js.map +0 -1
- package/hooks/useInterval.d.ts +0 -18
- package/hooks/useInterval.js.map +0 -1
- package/hooks/useLoadImageEffect.d.ts +0 -43
- package/hooks/useLoadImageEffect.js.map +0 -1
- package/hooks/useLoadVideoMetadataEffect.d.ts +0 -35
- package/hooks/useLoadVideoMetadataEffect.js.map +0 -1
- package/hooks/useMounted.d.ts +0 -1
- package/hooks/useMounted.js.map +0 -1
- package/hooks/usePrevious.d.ts +0 -19
- package/hooks/usePrevious.js.map +0 -1
- package/hooks/useRect.d.ts +0 -11
- package/hooks/useRect.js.map +0 -1
- package/hooks/useResizeEffect.d.ts +0 -17
- package/hooks/useResizeEffect.js.map +0 -1
- package/hooks/useScrollPositionEffect.d.ts +0 -13
- package/hooks/useScrollPositionEffect.js.map +0 -1
- package/hooks/useSearchParamState.d.ts +0 -34
- package/hooks/useSearchParamState.js.map +0 -1
- package/hooks/useSize.d.ts +0 -10
- package/hooks/useSize.js.map +0 -1
- package/hooks/useTimeout.d.ts +0 -10
- package/hooks/useTimeout.js.map +0 -1
- package/hooks/useVideoSize.d.ts +0 -21
- package/hooks/useVideoSize.js.map +0 -1
- package/hooks/useViewportSize.d.ts +0 -7
- package/hooks/useViewportSize.js.map +0 -1
- package/operators/Conditional.d.ts +0 -5
- package/operators/Conditional.js.map +0 -1
- package/operators/Each.d.ts +0 -7
- package/operators/Each.js.map +0 -1
- package/operators/ExtractChild.d.ts +0 -8
- package/operators/ExtractChild.js.map +0 -1
- package/operators/ExtractChildren.d.ts +0 -6
- package/operators/ExtractChildren.js.map +0 -1
- package/operators/Repeat.d.ts +0 -11
- package/operators/Repeat.js.map +0 -1
- package/providers/ScrollPositionProvider.d.ts +0 -15
- package/providers/ScrollPositionProvider.js.map +0 -1
- package/utils/asClassNameDict.d.ts +0 -3
- package/utils/asClassNameDict.js.map +0 -1
- package/utils/asComponentDict.d.ts +0 -5
- package/utils/asComponentDict.js.map +0 -1
- package/utils/asStyleDict.d.ts +0 -4
- package/utils/asStyleDict.js.map +0 -1
- package/utils/cloneStyledElement.d.ts +0 -18
- package/utils/cloneStyledElement.js.map +0 -1
- package/utils/index.d.ts +0 -5
- package/utils/index.js.map +0 -1
- package/utils/styles.d.ts +0 -2
- package/utils/styles.js.map +0 -1
package/components/Dropdown.js
CHANGED
|
@@ -1,47 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
42
|
-
|
|
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
|
-
|
|
54
|
-
|
|
23
|
+
const sanitizedSelection = (selection) => sortIndices(selection).filter(t => !isIndexOutOfRange(t));
|
|
24
|
+
const expand = () => {
|
|
55
25
|
if (!isCollapsed)
|
|
56
26
|
return;
|
|
57
|
-
onExpand
|
|
27
|
+
onExpand?.();
|
|
58
28
|
};
|
|
59
|
-
|
|
29
|
+
const collapse = () => {
|
|
60
30
|
if (isCollapsed)
|
|
61
31
|
return;
|
|
62
|
-
onCollapse
|
|
32
|
+
onCollapse?.();
|
|
63
33
|
};
|
|
64
|
-
|
|
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
|
-
|
|
73
|
-
onSelectAt
|
|
42
|
+
const selectAtHandler = (index) => {
|
|
43
|
+
onSelectAt?.(index);
|
|
74
44
|
if (selectionMode === 'single' && collapsesOnSelect)
|
|
75
45
|
collapse();
|
|
76
46
|
};
|
|
77
|
-
|
|
78
|
-
onSelectionChange
|
|
47
|
+
const selectionChangeHandler = (value) => {
|
|
48
|
+
onSelectionChange?.(value);
|
|
79
49
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
98
|
-
|
|
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
|
|
83
|
+
return () => {
|
|
114
84
|
window.removeEventListener('click', clickOutsideHandler);
|
|
115
85
|
};
|
|
116
86
|
}, [isCollapsed]);
|
|
117
|
-
return ((
|
|
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(
|
|
89
|
+
Object.defineProperty(Dropdown, 'displayName', { value: 'Dropdown', writable: false });
|
|
120
90
|
function sortIndices(indices) {
|
|
121
|
-
return indices.sort(
|
|
91
|
+
return indices.sort((a, b) => a - b);
|
|
122
92
|
}
|
|
123
|
-
function getFixedStyles(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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(
|
|
167
|
-
|
|
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:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
package/components/FlatSVG.js
CHANGED
|
@@ -1,93 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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:
|
|
57
|
-
var e_1, _a;
|
|
19
|
+
updateTag: (tagName, jPath, attrs) => {
|
|
58
20
|
if (shouldStripStyles && tagName === 'style')
|
|
59
21
|
return false;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
83
|
-
attributeNamePrefix
|
|
34
|
+
const builder = new XMLBuilder({
|
|
35
|
+
attributeNamePrefix,
|
|
84
36
|
format: true,
|
|
85
37
|
ignoreAttributes: false,
|
|
86
38
|
});
|
|
87
|
-
|
|
39
|
+
const xml = parser.parse(svg);
|
|
88
40
|
return builder.build(xml);
|
|
89
41
|
};
|
|
90
|
-
return ((
|
|
42
|
+
return (_jsx("figure", { ...props, ref: ref, dangerouslySetInnerHTML: { __html: sanitizedMarkup() }, "data-component": 'flat-svg' }));
|
|
91
43
|
});
|
|
92
|
-
Object.defineProperty(
|
|
93
|
-
//# sourceMappingURL=FlatSVG.js.map
|
|
44
|
+
Object.defineProperty(FlatSVG, 'displayName', { value: 'FlatSVG', writable: false });
|
package/components/Image.js
CHANGED
|
@@ -1,76 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
10
|
+
let t = src;
|
|
38
11
|
if (width !== undefined) {
|
|
39
|
-
|
|
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 +=
|
|
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 +=
|
|
20
|
+
t += ` ${pixelDensity}x`;
|
|
48
21
|
}
|
|
49
22
|
return t;
|
|
50
23
|
}).join(', ');
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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 =
|
|
30
|
+
t = `${mediaCondition} ${t}`;
|
|
59
31
|
return t;
|
|
60
32
|
}).join(', ');
|
|
61
|
-
|
|
33
|
+
const size = useImageSize({
|
|
62
34
|
src: fallbackSrc,
|
|
63
35
|
srcSet: srcSetValue,
|
|
64
36
|
sizes: sizesValue,
|
|
65
37
|
}, {
|
|
66
|
-
onLoadStart
|
|
67
|
-
onLoadComplete
|
|
68
|
-
onLoadError
|
|
38
|
+
onLoadStart,
|
|
39
|
+
onLoadComplete,
|
|
40
|
+
onLoadError,
|
|
69
41
|
});
|
|
70
|
-
|
|
71
|
-
onSizeChange
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
onSizeChange?.(size);
|
|
72
44
|
}, [size]);
|
|
73
|
-
return ((
|
|
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(
|
|
76
|
-
//# sourceMappingURL=Image.js.map
|
|
47
|
+
Object.defineProperty(Image, 'displayName', { value: 'Image', writable: false });
|