@eightshift/ui-components 1.4.5 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/style.css +1 -1
- package/dist/components/animated-visibility/animated-visibility.js +132 -162
- package/dist/components/component-toggle/component-toggle.js +1 -0
- package/dist/components/link-input/link-input.js +3 -2
- package/dist/components/menu/menu.js +1 -2
- package/dist/components/number-picker/number-picker.js +1 -1
- package/dist/components/option-select/option-select.js +3 -2
- package/dist/components/popover/popover.js +8 -2
- package/dist/components/repeater/repeater.js +1 -1
- package/dist/components/select/async-multi-select.js +6 -3
- package/dist/components/select/async-single-select.js +4 -1
- package/dist/components/select/multi-select.js +11 -4
- package/dist/components/select/shared.js +7 -56
- package/dist/components/select/single-select.js +9 -2
- package/dist/utilities/index.js +2 -1
- package/dist/utilities/text-helpers.js +38 -0
- package/package.json +9 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { createContext, useLayoutEffect, useEffect, useContext, useRef, useInsertionEffect, useCallback, useMemo, forwardRef, Fragment, createElement, useId, Component,
|
|
3
|
+
import { createContext, useLayoutEffect, useEffect, useContext, useRef, useInsertionEffect, useCallback, useMemo, forwardRef, Fragment, createElement, useId, Component, Children, isValidElement, useState } from "react";
|
|
4
4
|
const MotionConfigContext = createContext({
|
|
5
5
|
transformPagePoint: (p) => p,
|
|
6
6
|
isStatic: false,
|
|
@@ -498,40 +498,6 @@ function isForcedMotionValue(key, { layout: layout2, layoutId }) {
|
|
|
498
498
|
return transformProps.has(key) || key.startsWith("origin") || (layout2 || layoutId !== void 0) && (!!scaleCorrectors[key] || key === "opacity");
|
|
499
499
|
}
|
|
500
500
|
const isMotionValue = (value) => Boolean(value && value.getVelocity);
|
|
501
|
-
const translateAlias = {
|
|
502
|
-
x: "translateX",
|
|
503
|
-
y: "translateY",
|
|
504
|
-
z: "translateZ",
|
|
505
|
-
transformPerspective: "perspective"
|
|
506
|
-
};
|
|
507
|
-
const numTransforms = transformPropOrder.length;
|
|
508
|
-
function buildTransform(transform, transformIsDefault, transformTemplate) {
|
|
509
|
-
let transformString = "";
|
|
510
|
-
for (let i = 0; i < numTransforms; i++) {
|
|
511
|
-
const key = transformPropOrder[i];
|
|
512
|
-
if (transform[key] !== void 0) {
|
|
513
|
-
const transformName = translateAlias[key] || key;
|
|
514
|
-
transformString += `${transformName}(${transform[key]}) `;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
transformString = transformString.trim();
|
|
518
|
-
if (transformTemplate) {
|
|
519
|
-
transformString = transformTemplate(transform, transformIsDefault ? "" : transformString);
|
|
520
|
-
} else if (transformIsDefault) {
|
|
521
|
-
transformString = "none";
|
|
522
|
-
}
|
|
523
|
-
return transformString;
|
|
524
|
-
}
|
|
525
|
-
const checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
|
|
526
|
-
const isCSSVariableName = checkStringStartsWith("--");
|
|
527
|
-
const startsAsVariableToken = checkStringStartsWith("var(--");
|
|
528
|
-
const isCSSVariableToken = (value) => {
|
|
529
|
-
const startsWithToken = startsAsVariableToken(value);
|
|
530
|
-
if (!startsWithToken)
|
|
531
|
-
return false;
|
|
532
|
-
return singleCssVariableRegex.test(value.split("/*")[0].trim());
|
|
533
|
-
};
|
|
534
|
-
const singleCssVariableRegex = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;
|
|
535
501
|
const getValueAsType = (value, type) => {
|
|
536
502
|
return type && typeof value === "number" ? type.transform(value) : value;
|
|
537
503
|
};
|
|
@@ -652,36 +618,82 @@ const numberValueTypes = {
|
|
|
652
618
|
strokeOpacity: alpha,
|
|
653
619
|
numOctaves: int
|
|
654
620
|
};
|
|
621
|
+
const translateAlias = {
|
|
622
|
+
x: "translateX",
|
|
623
|
+
y: "translateY",
|
|
624
|
+
z: "translateZ",
|
|
625
|
+
transformPerspective: "perspective"
|
|
626
|
+
};
|
|
627
|
+
const numTransforms = transformPropOrder.length;
|
|
628
|
+
function buildTransform(latestValues, transform, transformTemplate) {
|
|
629
|
+
let transformString = "";
|
|
630
|
+
let transformIsDefault = true;
|
|
631
|
+
for (let i = 0; i < numTransforms; i++) {
|
|
632
|
+
const key = transformPropOrder[i];
|
|
633
|
+
const value = latestValues[key];
|
|
634
|
+
if (value === void 0)
|
|
635
|
+
continue;
|
|
636
|
+
let valueIsDefault = true;
|
|
637
|
+
if (typeof value === "number") {
|
|
638
|
+
valueIsDefault = value === (key.startsWith("scale") ? 1 : 0);
|
|
639
|
+
} else {
|
|
640
|
+
valueIsDefault = parseFloat(value) === 0;
|
|
641
|
+
}
|
|
642
|
+
if (!valueIsDefault || transformTemplate) {
|
|
643
|
+
const valueAsType = getValueAsType(value, numberValueTypes[key]);
|
|
644
|
+
if (!valueIsDefault) {
|
|
645
|
+
transformIsDefault = false;
|
|
646
|
+
const transformName = translateAlias[key] || key;
|
|
647
|
+
transformString += `${transformName}(${valueAsType}) `;
|
|
648
|
+
}
|
|
649
|
+
if (transformTemplate) {
|
|
650
|
+
transform[key] = valueAsType;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
transformString = transformString.trim();
|
|
655
|
+
if (transformTemplate) {
|
|
656
|
+
transformString = transformTemplate(transform, transformIsDefault ? "" : transformString);
|
|
657
|
+
} else if (transformIsDefault) {
|
|
658
|
+
transformString = "none";
|
|
659
|
+
}
|
|
660
|
+
return transformString;
|
|
661
|
+
}
|
|
662
|
+
const checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
|
|
663
|
+
const isCSSVariableName = checkStringStartsWith("--");
|
|
664
|
+
const startsAsVariableToken = checkStringStartsWith("var(--");
|
|
665
|
+
const isCSSVariableToken = (value) => {
|
|
666
|
+
const startsWithToken = startsAsVariableToken(value);
|
|
667
|
+
if (!startsWithToken)
|
|
668
|
+
return false;
|
|
669
|
+
return singleCssVariableRegex.test(value.split("/*")[0].trim());
|
|
670
|
+
};
|
|
671
|
+
const singleCssVariableRegex = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;
|
|
655
672
|
function buildHTMLStyles(state, latestValues, transformTemplate) {
|
|
656
|
-
const { style, vars,
|
|
673
|
+
const { style, vars, transformOrigin } = state;
|
|
657
674
|
let hasTransform2 = false;
|
|
658
675
|
let hasTransformOrigin = false;
|
|
659
|
-
let transformIsNone = true;
|
|
660
676
|
for (const key in latestValues) {
|
|
661
677
|
const value = latestValues[key];
|
|
662
|
-
if (isCSSVariableName(key)) {
|
|
663
|
-
vars[key] = value;
|
|
664
|
-
continue;
|
|
665
|
-
}
|
|
666
|
-
const valueType = numberValueTypes[key];
|
|
667
|
-
const valueAsType = getValueAsType(value, valueType);
|
|
668
678
|
if (transformProps.has(key)) {
|
|
669
679
|
hasTransform2 = true;
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
transformIsNone = false;
|
|
675
|
-
} else if (key.startsWith("origin")) {
|
|
676
|
-
hasTransformOrigin = true;
|
|
677
|
-
transformOrigin[key] = valueAsType;
|
|
680
|
+
continue;
|
|
681
|
+
} else if (isCSSVariableName(key)) {
|
|
682
|
+
vars[key] = value;
|
|
683
|
+
continue;
|
|
678
684
|
} else {
|
|
679
|
-
|
|
685
|
+
const valueAsType = getValueAsType(value, numberValueTypes[key]);
|
|
686
|
+
if (key.startsWith("origin")) {
|
|
687
|
+
hasTransformOrigin = true;
|
|
688
|
+
transformOrigin[key] = valueAsType;
|
|
689
|
+
} else {
|
|
690
|
+
style[key] = valueAsType;
|
|
691
|
+
}
|
|
680
692
|
}
|
|
681
693
|
}
|
|
682
694
|
if (!latestValues.transform) {
|
|
683
695
|
if (hasTransform2 || transformTemplate) {
|
|
684
|
-
style.transform = buildTransform(state.transform,
|
|
696
|
+
style.transform = buildTransform(latestValues, state.transform, transformTemplate);
|
|
685
697
|
} else if (style.transform) {
|
|
686
698
|
style.transform = "none";
|
|
687
699
|
}
|
|
@@ -2358,13 +2370,9 @@ function spring({ keyframes: keyframes2, restDelta, restSpeed, ...options }) {
|
|
|
2358
2370
|
next: (t) => {
|
|
2359
2371
|
const current = resolveSpring(t);
|
|
2360
2372
|
if (!isResolvedFromDuration) {
|
|
2361
|
-
let currentVelocity =
|
|
2362
|
-
if (
|
|
2363
|
-
|
|
2364
|
-
currentVelocity = calcGeneratorVelocity(resolveSpring, t, current);
|
|
2365
|
-
} else {
|
|
2366
|
-
currentVelocity = 0;
|
|
2367
|
-
}
|
|
2373
|
+
let currentVelocity = 0;
|
|
2374
|
+
if (dampingRatio < 1) {
|
|
2375
|
+
currentVelocity = t === 0 ? secondsToMilliseconds(initialVelocity) : calcGeneratorVelocity(resolveSpring, t, current);
|
|
2368
2376
|
}
|
|
2369
2377
|
const isBelowVelocityThreshold = Math.abs(currentVelocity) <= restSpeed;
|
|
2370
2378
|
const isBelowDisplacementThreshold = Math.abs(target - current) <= restDelta;
|
|
@@ -3231,6 +3239,8 @@ class AcceleratedAnimation extends BaseAnimation {
|
|
|
3231
3239
|
this.isStopped = true;
|
|
3232
3240
|
if (this.state === "idle")
|
|
3233
3241
|
return;
|
|
3242
|
+
this.resolveFinishedPromise();
|
|
3243
|
+
this.updateFinishedPromise();
|
|
3234
3244
|
const { resolved } = this;
|
|
3235
3245
|
if (!resolved)
|
|
3236
3246
|
return;
|
|
@@ -3477,7 +3487,7 @@ class MotionValue {
|
|
|
3477
3487
|
* @internal
|
|
3478
3488
|
*/
|
|
3479
3489
|
constructor(init, options = {}) {
|
|
3480
|
-
this.version = "11.3.
|
|
3490
|
+
this.version = "11.3.22";
|
|
3481
3491
|
this.canTrackVelocity = null;
|
|
3482
3492
|
this.events = {};
|
|
3483
3493
|
this.updateAndNotify = (v, render = true) => {
|
|
@@ -3895,9 +3905,7 @@ function animateVisualElement(visualElement, definition, options = {}) {
|
|
|
3895
3905
|
animation = Promise.all(animateTarget(visualElement, resolvedDefinition, options));
|
|
3896
3906
|
}
|
|
3897
3907
|
return animation.then(() => {
|
|
3898
|
-
|
|
3899
|
-
visualElement.notify("AnimationComplete", definition);
|
|
3900
|
-
});
|
|
3908
|
+
visualElement.notify("AnimationComplete", definition);
|
|
3901
3909
|
});
|
|
3902
3910
|
}
|
|
3903
3911
|
const reversePriorityOrder = [...variantPriorityOrder].reverse();
|
|
@@ -6511,7 +6519,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
6511
6519
|
if (isMotionValue(nextValue)) {
|
|
6512
6520
|
element.addValue(key, nextValue);
|
|
6513
6521
|
if (process.env.NODE_ENV === "development") {
|
|
6514
|
-
warnOnce(nextValue.version === "11.3.
|
|
6522
|
+
warnOnce(nextValue.version === "11.3.22", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.3.22 may not work as expected.`);
|
|
6515
6523
|
}
|
|
6516
6524
|
} else if (isMotionValue(prevValue)) {
|
|
6517
6525
|
element.addValue(key, motionValue(nextValue, { owner: element }));
|
|
@@ -7011,25 +7019,6 @@ const preloadedFeatures = {
|
|
|
7011
7019
|
...layout
|
|
7012
7020
|
};
|
|
7013
7021
|
const motion = /* @__PURE__ */ createMotionProxy((Component2, config) => createDomMotionConfig(Component2, config, preloadedFeatures, createDomVisualElement));
|
|
7014
|
-
function useIsMounted() {
|
|
7015
|
-
const isMounted = useRef(false);
|
|
7016
|
-
useIsomorphicLayoutEffect(() => {
|
|
7017
|
-
isMounted.current = true;
|
|
7018
|
-
return () => {
|
|
7019
|
-
isMounted.current = false;
|
|
7020
|
-
};
|
|
7021
|
-
}, []);
|
|
7022
|
-
return isMounted;
|
|
7023
|
-
}
|
|
7024
|
-
function useForceUpdate() {
|
|
7025
|
-
const isMounted = useIsMounted();
|
|
7026
|
-
const [forcedRenderCount, setForcedRenderCount] = useState(0);
|
|
7027
|
-
const forceRender = useCallback(() => {
|
|
7028
|
-
isMounted.current && setForcedRenderCount(forcedRenderCount + 1);
|
|
7029
|
-
}, [forcedRenderCount]);
|
|
7030
|
-
const deferredForceRender = useCallback(() => frame.postRender(forceRender), [forceRender]);
|
|
7031
|
-
return [deferredForceRender, forcedRenderCount];
|
|
7032
|
-
}
|
|
7033
7022
|
class PopChildMeasure extends React.Component {
|
|
7034
7023
|
getSnapshotBeforeUpdate(prevProps) {
|
|
7035
7024
|
const element = this.props.childRef.current;
|
|
@@ -7130,16 +7119,7 @@ const PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, p
|
|
|
7130
7119
|
function newChildrenMap() {
|
|
7131
7120
|
return /* @__PURE__ */ new Map();
|
|
7132
7121
|
}
|
|
7133
|
-
function useUnmountEffect(callback) {
|
|
7134
|
-
return useEffect(() => () => callback(), []);
|
|
7135
|
-
}
|
|
7136
7122
|
const getChildKey = (child) => child.key || "";
|
|
7137
|
-
function updateChildLookup(children, allChildren) {
|
|
7138
|
-
children.forEach((child) => {
|
|
7139
|
-
const key = getChildKey(child);
|
|
7140
|
-
allChildren.set(key, child);
|
|
7141
|
-
});
|
|
7142
|
-
}
|
|
7143
7123
|
function onlyElements(children) {
|
|
7144
7124
|
const filtered = [];
|
|
7145
7125
|
Children.forEach(children, (child) => {
|
|
@@ -7148,83 +7128,73 @@ function onlyElements(children) {
|
|
|
7148
7128
|
});
|
|
7149
7129
|
return filtered;
|
|
7150
7130
|
}
|
|
7151
|
-
const AnimatePresence = ({ children, custom, initial = true, onExitComplete,
|
|
7131
|
+
const AnimatePresence = ({ children, exitBeforeEnter, custom, initial = true, onExitComplete, presenceAffectsLayout = true, mode = "sync" }) => {
|
|
7152
7132
|
invariant(!exitBeforeEnter, "Replace exitBeforeEnter with mode='wait'");
|
|
7153
|
-
const
|
|
7154
|
-
const
|
|
7155
|
-
const filteredChildren = onlyElements(children);
|
|
7156
|
-
let childrenToRender = filteredChildren;
|
|
7157
|
-
const exitingChildren = useRef(/* @__PURE__ */ new Map()).current;
|
|
7158
|
-
const presentChildren = useRef(childrenToRender);
|
|
7159
|
-
const allChildren = useRef(/* @__PURE__ */ new Map()).current;
|
|
7133
|
+
const presentChildren = useMemo(() => onlyElements(children), [children]);
|
|
7134
|
+
const presentKeys = presentChildren.map(getChildKey);
|
|
7160
7135
|
const isInitialRender = useRef(true);
|
|
7136
|
+
const pendingPresentChildren = useRef(presentChildren);
|
|
7137
|
+
const exitComplete = useConstant(() => /* @__PURE__ */ new Map());
|
|
7138
|
+
const [diffedChildren, setDiffedChildren] = useState(presentChildren);
|
|
7139
|
+
const [renderedChildren, setRenderedChildren] = useState(presentChildren);
|
|
7161
7140
|
useIsomorphicLayoutEffect(() => {
|
|
7162
7141
|
isInitialRender.current = false;
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
exitingChildren.clear();
|
|
7170
|
-
});
|
|
7171
|
-
if (isInitialRender.current) {
|
|
7172
|
-
return jsx(Fragment$1, { children: childrenToRender.map((child) => jsx(PresenceChild, { isPresent: true, initial: initial ? void 0 : false, presenceAffectsLayout, mode, children: child }, getChildKey(child))) });
|
|
7173
|
-
}
|
|
7174
|
-
childrenToRender = [...childrenToRender];
|
|
7175
|
-
const presentKeys = presentChildren.current.map(getChildKey);
|
|
7176
|
-
const targetKeys = filteredChildren.map(getChildKey);
|
|
7177
|
-
const numPresent = presentKeys.length;
|
|
7178
|
-
for (let i = 0; i < numPresent; i++) {
|
|
7179
|
-
const key = presentKeys[i];
|
|
7180
|
-
if (targetKeys.indexOf(key) === -1 && !exitingChildren.has(key)) {
|
|
7181
|
-
exitingChildren.set(key, void 0);
|
|
7182
|
-
}
|
|
7183
|
-
}
|
|
7184
|
-
if (mode === "wait" && exitingChildren.size) {
|
|
7185
|
-
childrenToRender = [];
|
|
7186
|
-
}
|
|
7187
|
-
exitingChildren.forEach((component, key) => {
|
|
7188
|
-
if (targetKeys.indexOf(key) !== -1)
|
|
7189
|
-
return;
|
|
7190
|
-
const child = allChildren.get(key);
|
|
7191
|
-
if (!child)
|
|
7192
|
-
return;
|
|
7193
|
-
const insertionIndex = presentKeys.indexOf(key);
|
|
7194
|
-
let exitingComponent = component;
|
|
7195
|
-
if (!exitingComponent) {
|
|
7196
|
-
const onExit = () => {
|
|
7197
|
-
exitingChildren.delete(key);
|
|
7198
|
-
const leftOverKeys = Array.from(allChildren.keys()).filter((childKey) => !targetKeys.includes(childKey));
|
|
7199
|
-
leftOverKeys.forEach((leftOverKey) => allChildren.delete(leftOverKey));
|
|
7200
|
-
presentChildren.current = filteredChildren.filter((presentChild) => {
|
|
7201
|
-
const presentChildKey = getChildKey(presentChild);
|
|
7202
|
-
return (
|
|
7203
|
-
// filter out the node exiting
|
|
7204
|
-
presentChildKey === key || // filter out the leftover children
|
|
7205
|
-
leftOverKeys.includes(presentChildKey)
|
|
7206
|
-
);
|
|
7207
|
-
});
|
|
7208
|
-
if (!exitingChildren.size) {
|
|
7209
|
-
if (isMounted.current === false)
|
|
7210
|
-
return;
|
|
7211
|
-
forceRender();
|
|
7212
|
-
onExitComplete && onExitComplete();
|
|
7142
|
+
pendingPresentChildren.current = presentChildren;
|
|
7143
|
+
for (let i = 0; i < renderedChildren.length; i++) {
|
|
7144
|
+
const key = getChildKey(renderedChildren[i]);
|
|
7145
|
+
if (!presentKeys.includes(key)) {
|
|
7146
|
+
if (exitComplete.get(key) !== true) {
|
|
7147
|
+
exitComplete.set(key, false);
|
|
7213
7148
|
}
|
|
7214
|
-
}
|
|
7215
|
-
|
|
7216
|
-
|
|
7149
|
+
} else {
|
|
7150
|
+
exitComplete.delete(key);
|
|
7151
|
+
}
|
|
7217
7152
|
}
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7153
|
+
}, [renderedChildren, presentKeys.length, presentKeys.join("-")]);
|
|
7154
|
+
const exitingChildren = [];
|
|
7155
|
+
if (presentChildren !== diffedChildren) {
|
|
7156
|
+
let nextChildren = [...presentChildren];
|
|
7157
|
+
for (let i = 0; i < renderedChildren.length; i++) {
|
|
7158
|
+
const child = renderedChildren[i];
|
|
7159
|
+
const key = getChildKey(child);
|
|
7160
|
+
if (!presentKeys.includes(key)) {
|
|
7161
|
+
nextChildren.splice(i, 0, child);
|
|
7162
|
+
exitingChildren.push(child);
|
|
7163
|
+
}
|
|
7164
|
+
}
|
|
7165
|
+
if (mode === "wait" && exitingChildren.length) {
|
|
7166
|
+
nextChildren = exitingChildren;
|
|
7167
|
+
}
|
|
7168
|
+
setRenderedChildren(onlyElements(nextChildren));
|
|
7169
|
+
setDiffedChildren(presentChildren);
|
|
7170
|
+
return;
|
|
7171
|
+
}
|
|
7172
|
+
if (process.env.NODE_ENV !== "production" && mode === "wait" && renderedChildren.length > 1) {
|
|
7225
7173
|
console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
|
|
7226
7174
|
}
|
|
7227
|
-
|
|
7175
|
+
const { forceRender } = useContext(LayoutGroupContext);
|
|
7176
|
+
return jsx(Fragment$1, { children: renderedChildren.map((child) => {
|
|
7177
|
+
const key = getChildKey(child);
|
|
7178
|
+
const isPresent = presentChildren === renderedChildren || presentKeys.includes(key);
|
|
7179
|
+
const onExit = () => {
|
|
7180
|
+
if (exitComplete.has(key)) {
|
|
7181
|
+
exitComplete.set(key, true);
|
|
7182
|
+
} else {
|
|
7183
|
+
return;
|
|
7184
|
+
}
|
|
7185
|
+
let isEveryExitComplete = true;
|
|
7186
|
+
exitComplete.forEach((isExitComplete) => {
|
|
7187
|
+
if (!isExitComplete)
|
|
7188
|
+
isEveryExitComplete = false;
|
|
7189
|
+
});
|
|
7190
|
+
if (isEveryExitComplete) {
|
|
7191
|
+
forceRender === null || forceRender === void 0 ? void 0 : forceRender();
|
|
7192
|
+
setRenderedChildren(pendingPresentChildren.current);
|
|
7193
|
+
onExitComplete && onExitComplete();
|
|
7194
|
+
}
|
|
7195
|
+
};
|
|
7196
|
+
return jsx(PresenceChild, { isPresent, initial: !isInitialRender.current || initial ? void 0 : false, custom: isPresent ? void 0 : custom, presenceAffectsLayout, mode, onExitComplete: isPresent ? void 0 : onExit, children: child }, key);
|
|
7197
|
+
}) });
|
|
7228
7198
|
};
|
|
7229
7199
|
/**
|
|
7230
7200
|
* Component that allows animating the visibility of its children.
|
|
@@ -1755,6 +1755,7 @@ const LinkInput = (props) => {
|
|
|
1755
1755
|
} = props;
|
|
1756
1756
|
const triggerRef = useRef(null);
|
|
1757
1757
|
const suggestionList = $f86e6c1ec7da6ebb$export$bc3384a35de93d66({
|
|
1758
|
+
initialFilterText: url,
|
|
1758
1759
|
async load({ signal, filterText }) {
|
|
1759
1760
|
const items = await fetchSuggestions(filterText, signal);
|
|
1760
1761
|
return {
|
|
@@ -1854,8 +1855,8 @@ const LinkInput = (props) => {
|
|
|
1854
1855
|
"aria-label": __("URL suggestions", "eightshift-ui-components"),
|
|
1855
1856
|
className: ({ isEntering, isExiting }) => clsx(
|
|
1856
1857
|
"es-uic-rounded-md es-uic-border es-uic-border-gray-200 es-uic-bg-white es-uic-shadow-lg es-uic-outline-none",
|
|
1857
|
-
isEntering && "es-uic-
|
|
1858
|
-
isExiting && "es-uic-
|
|
1858
|
+
isEntering && "es-uic-animate-in es-uic-fade-in-0 es-uic-slide-in-from-top-3 es-uic-fill-mode-forwards",
|
|
1859
|
+
isExiting && "es-uic-animate-out es-uic-fade-out-0 es-uic-slide-out-to-top-2 es-uic-fill-mode-forwards",
|
|
1859
1860
|
!shouldShowSuggestions && suggestionList.items.length < 1 && "es-uic-invisible"
|
|
1860
1861
|
),
|
|
1861
1862
|
style: {
|
|
@@ -1086,8 +1086,7 @@ const Menu = (props) => {
|
|
|
1086
1086
|
children: /* @__PURE__ */ jsx(
|
|
1087
1087
|
$3674c52c6b3c5bce$export$d9b273488cd8ce6f,
|
|
1088
1088
|
{
|
|
1089
|
-
"
|
|
1090
|
-
className: "focus:es-uic-outline-none",
|
|
1089
|
+
className: "es-uic-outline-none",
|
|
1091
1090
|
...props,
|
|
1092
1091
|
...additionalProps,
|
|
1093
1092
|
children
|
|
@@ -236,7 +236,7 @@ const NumberPicker = ({
|
|
|
236
236
|
{
|
|
237
237
|
onFocus: () => setIsInputFocused(true),
|
|
238
238
|
onBlur: () => setIsInputFocused(false),
|
|
239
|
-
className: "es-uic-col-start-2 es-uic-row-span-2 es-uic-bg-transparent es-uic-py-1 es-uic-text-sm es-uic-tabular-nums selection:es-uic-bg-teal-500/20 selection:es-uic-text-teal-950 focus:es-uic-outline-none",
|
|
239
|
+
className: "es-uic-col-start-2 es-uic-row-span-2 !es-uic-border-none es-uic-bg-transparent !es-uic-px-0 !es-uic-py-1 es-uic-text-sm es-uic-tabular-nums !es-uic-shadow-none !es-uic-outline-none selection:es-uic-bg-teal-500/20 selection:es-uic-text-teal-950 focus:!es-uic-shadow-none focus:es-uic-outline-none",
|
|
240
240
|
placeholder,
|
|
241
241
|
style: {
|
|
242
242
|
width: fixedWidth ? `${fixedWidth}ch` : `calc(${min < 0 ? "0.75ch + " : ""}${(_d = (_c = max ?? 1e3) == null ? void 0 : _c.toString()) == null ? void 0 : _d.length} * 1ch)`
|
|
@@ -181,7 +181,7 @@ const OptionSelect = (props) => {
|
|
|
181
181
|
type === "menu" && /* @__PURE__ */ jsxs(
|
|
182
182
|
Menu,
|
|
183
183
|
{
|
|
184
|
-
triggerLabel:
|
|
184
|
+
triggerLabel: noTriggerLabel ? null : (currentItem == null ? void 0 : currentItem.label) ?? notSetLabel,
|
|
185
185
|
triggerIcon: !noTriggerIcon && // eslint-disable-next-line no-nested-ternary
|
|
186
186
|
(currentItem ? typeof (currentItem == null ? void 0 : currentItem.icon) === "string" ? (_a = icons) == null ? void 0 : _a[currentItem == null ? void 0 : currentItem.icon] : currentItem == null ? void 0 : currentItem.icon : (noTriggerLabel || noTriggerIcon) && notSetLabel),
|
|
187
187
|
tooltip: noTriggerLabel ? /* @__PURE__ */ jsx(
|
|
@@ -194,9 +194,10 @@ const OptionSelect = (props) => {
|
|
|
194
194
|
) : tooltip,
|
|
195
195
|
triggerProps: {
|
|
196
196
|
...wrapperProps == null ? void 0 : wrapperProps.triggerProps,
|
|
197
|
-
"aria-label": typeof label !== "undefined" ? null : ariaLabel
|
|
197
|
+
"aria-label": typeof label !== "undefined" ? null : ariaLabel ?? label ?? tooltip
|
|
198
198
|
},
|
|
199
199
|
keepOpen: true,
|
|
200
|
+
"aria-label": ariaLabel ?? label ?? tooltip ?? __("Menu", "eightshift-ui-components"),
|
|
200
201
|
...wrapperProps,
|
|
201
202
|
children: [
|
|
202
203
|
options.map(
|
|
@@ -77,9 +77,14 @@ const Popover = (props) => {
|
|
|
77
77
|
containerPadding,
|
|
78
78
|
shouldFlip,
|
|
79
79
|
shouldCloseOnInteractOutside = () => true,
|
|
80
|
+
"aria-label": rawAriaLabel,
|
|
80
81
|
hidden,
|
|
81
82
|
...other
|
|
82
83
|
} = props;
|
|
84
|
+
let ariaLabel = rawAriaLabel;
|
|
85
|
+
if (ariaLabel === false) {
|
|
86
|
+
ariaLabel = void 0;
|
|
87
|
+
}
|
|
83
88
|
if (hidden) {
|
|
84
89
|
return null;
|
|
85
90
|
}
|
|
@@ -98,8 +103,8 @@ const Popover = (props) => {
|
|
|
98
103
|
containerPadding,
|
|
99
104
|
className: ({ isEntering, isExiting }) => clsx(
|
|
100
105
|
"es-uic-rounded-md es-uic-border es-uic-border-gray-200 es-uic-bg-white es-uic-shadow-lg es-uic-outline-none",
|
|
101
|
-
isEntering && "es-uic-
|
|
102
|
-
isExiting && "es-uic-
|
|
106
|
+
isEntering && "es-uic-animate-in es-uic-fade-in-0 es-uic-slide-in-from-top-3 es-uic-fill-mode-forwards",
|
|
107
|
+
isExiting && "es-uic-animate-out es-uic-fade-out-0 es-uic-slide-out-to-top-2 es-uic-fill-mode-forwards",
|
|
103
108
|
wrapperClassName
|
|
104
109
|
),
|
|
105
110
|
style,
|
|
@@ -107,6 +112,7 @@ const Popover = (props) => {
|
|
|
107
112
|
$de32f1b87079253c$export$3ddf2d174ce01153,
|
|
108
113
|
{
|
|
109
114
|
className: clsx("es-uic-p-1 es-uic-text-sm es-uic-outline-none", className),
|
|
115
|
+
"aria-label": ariaLabel,
|
|
110
116
|
...other,
|
|
111
117
|
children
|
|
112
118
|
}
|
|
@@ -5082,7 +5082,7 @@ const Repeater = (props) => {
|
|
|
5082
5082
|
const [items, setItems] = useState(fixIds(rawItems));
|
|
5083
5083
|
const [canDelete, setCanDelete] = useState(false);
|
|
5084
5084
|
const [isPanelOpen, setIsPanelOpen] = useState({});
|
|
5085
|
-
const isAnyPanelOpen = ((_a3 = Object.keys(isPanelOpen)) == null ? void 0 : _a3.length) < 1 ? false : Object.entries(isPanelOpen).
|
|
5085
|
+
const isAnyPanelOpen = ((_a3 = Object.keys(isPanelOpen)) == null ? void 0 : _a3.length) < 1 ? false : Object.entries(isPanelOpen).some(([_2, v2]) => v2 === true);
|
|
5086
5086
|
if (canDelete && items.length < (minItems ?? 1)) {
|
|
5087
5087
|
setCanDelete(false);
|
|
5088
5088
|
}
|
|
@@ -92,8 +92,11 @@ const AsyncMultiSelect = (props) => {
|
|
|
92
92
|
const idBase = useId();
|
|
93
93
|
const value = rawValue.map((item, index) => ({
|
|
94
94
|
...item,
|
|
95
|
-
id: `${idBase}-${index}`
|
|
95
|
+
id: (item == null ? void 0 : item.value) ?? `${idBase}-${index}`
|
|
96
96
|
}));
|
|
97
|
+
const modifiedOnChange = (v) => {
|
|
98
|
+
onChange(v == null ? void 0 : v.map((item) => ({ ...item, id: void 0 })));
|
|
99
|
+
};
|
|
97
100
|
if (hidden) {
|
|
98
101
|
return null;
|
|
99
102
|
}
|
|
@@ -114,7 +117,7 @@ const AsyncMultiSelect = (props) => {
|
|
|
114
117
|
DndContext,
|
|
115
118
|
{
|
|
116
119
|
modifiers: [restrictToParentElement],
|
|
117
|
-
onDragEnd: getDragEndHandler(
|
|
120
|
+
onDragEnd: getDragEndHandler(modifiedOnChange, value),
|
|
118
121
|
children: /* @__PURE__ */ jsx(SortableContext, { items: value.map(({ id }) => id), children: /* @__PURE__ */ jsx(
|
|
119
122
|
AsyncSelect$1,
|
|
120
123
|
{
|
|
@@ -123,7 +126,7 @@ const AsyncMultiSelect = (props) => {
|
|
|
123
126
|
loadOptions: customLoadOptions,
|
|
124
127
|
defaultOptions: preloadOptions,
|
|
125
128
|
value,
|
|
126
|
-
onChange,
|
|
129
|
+
onChange: modifiedOnChange,
|
|
127
130
|
closeMenuOnSelect: !keepMenuOpenAfterSelect,
|
|
128
131
|
isClearable: clearable,
|
|
129
132
|
isSearchable: !noSearch,
|
|
@@ -105,7 +105,10 @@ const AsyncSelect = (props) => {
|
|
|
105
105
|
loadOptions: customLoadOptions,
|
|
106
106
|
defaultOptions: preloadOptions,
|
|
107
107
|
value,
|
|
108
|
-
onChange
|
|
108
|
+
onChange: (value2) => {
|
|
109
|
+
delete value2.id;
|
|
110
|
+
onChange(value2);
|
|
111
|
+
},
|
|
109
112
|
closeMenuOnSelect: !keepMenuOpenAfterSelect,
|
|
110
113
|
isClearable: clearable,
|
|
111
114
|
isSearchable: !noSearch,
|
|
@@ -4,7 +4,7 @@ import { S as StateManagedSelect$1 } from "../../react-select.esm-DkSeQzOP.js";
|
|
|
4
4
|
import { D as DndContext, g as getDragEndHandler, S as SortableContext, a as getMultiValue, b as getMultiValueRemove } from "../../multi-select-components-DTvEidE3.js";
|
|
5
5
|
import { r as restrictToParentElement } from "../../modifiers.esm-BuJQPI1X.js";
|
|
6
6
|
import { CustomSelectDefaultMultiValueRemove, CustomSelectDefaultDropdownIndicator, CustomSelectDefaultClearIndicator } from "./custom-select-default-components.js";
|
|
7
|
-
import { getValue
|
|
7
|
+
import { getValue } from "./shared.js";
|
|
8
8
|
import { BaseControl } from "../base-control/base-control.js";
|
|
9
9
|
import { eightshiftSelectClasses } from "./styles.js";
|
|
10
10
|
import { c as components } from "../../index-a301f526.esm-B9tWL9yi.js";
|
|
@@ -87,8 +87,15 @@ const MultiSelect = (props) => {
|
|
|
87
87
|
const idBase = useId();
|
|
88
88
|
const value = getValue(simpleValue, rawValue, options).map((item, index) => ({
|
|
89
89
|
...item,
|
|
90
|
-
id: `${idBase}-${index}`
|
|
90
|
+
id: (simpleValue ? item : item == null ? void 0 : item.value) ?? `${idBase}-${index}`
|
|
91
91
|
}));
|
|
92
|
+
const modifiedOnChange = (v) => {
|
|
93
|
+
if (simpleValue) {
|
|
94
|
+
onChange(v == null ? void 0 : v.map(({ value: value2 }) => value2));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
onChange(v == null ? void 0 : v.map((item) => ({ ...item, id: void 0 })));
|
|
98
|
+
};
|
|
92
99
|
if (hidden) {
|
|
93
100
|
return null;
|
|
94
101
|
}
|
|
@@ -105,7 +112,7 @@ const MultiSelect = (props) => {
|
|
|
105
112
|
DndContext,
|
|
106
113
|
{
|
|
107
114
|
modifiers: [restrictToParentElement],
|
|
108
|
-
onDragEnd: getDragEndHandler(
|
|
115
|
+
onDragEnd: getDragEndHandler(modifiedOnChange, value),
|
|
109
116
|
children: /* @__PURE__ */ jsx(SortableContext, { items: value.map(({ id }) => id), children: /* @__PURE__ */ jsx(
|
|
110
117
|
StateManagedSelect$1,
|
|
111
118
|
{
|
|
@@ -113,7 +120,7 @@ const MultiSelect = (props) => {
|
|
|
113
120
|
unstyled: true,
|
|
114
121
|
options: options.map((item) => ({ id: item.value, ...item })),
|
|
115
122
|
value,
|
|
116
|
-
onChange:
|
|
123
|
+
onChange: modifiedOnChange,
|
|
117
124
|
closeMenuOnSelect: !keepMenuOpenAfterSelect,
|
|
118
125
|
isClearable: clearable,
|
|
119
126
|
isSearchable: !noSearch,
|
|
@@ -10,66 +10,17 @@
|
|
|
10
10
|
* @preserve
|
|
11
11
|
*/
|
|
12
12
|
const getValue = (simpleValue, value, options) => {
|
|
13
|
-
if (!simpleValue) {
|
|
14
|
-
return value;
|
|
15
|
-
}
|
|
16
13
|
if (Array.isArray(value)) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Handles the `onChange` callback.
|
|
23
|
-
*
|
|
24
|
-
* @param {boolean} simpleValue - Whether `simpleValue` is set.
|
|
25
|
-
* @param {string|{label: string, value: string, metadata: Object<string, any>[]}} newValue - The new value to be set.
|
|
26
|
-
* @param {Function} onChange - The `onChange` callback passed to the component.
|
|
27
|
-
* @returns {void}
|
|
28
|
-
*
|
|
29
|
-
* @preserve
|
|
30
|
-
*/
|
|
31
|
-
const customOnChange = (simpleValue, newValue, onChange) => {
|
|
32
|
-
if (typeof newValue === "undefined" || newValue === null || newValue === "") {
|
|
33
|
-
onChange(void 0);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
delete newValue.id;
|
|
37
|
-
if (!simpleValue) {
|
|
38
|
-
onChange(newValue);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (Array.isArray(newValue)) {
|
|
42
|
-
onChange(newValue.map((item) => item == null ? void 0 : item.value));
|
|
43
|
-
return;
|
|
14
|
+
if (simpleValue) {
|
|
15
|
+
return value.map((value2) => options == null ? void 0 : options.find(({ value: itemValue }) => itemValue === value2));
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
44
18
|
}
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Handles the `onChange` callback.
|
|
49
|
-
*
|
|
50
|
-
* @param {object[]} items - Current items.
|
|
51
|
-
* @param {Function} onChange - The `onChange` callback passed to the component.
|
|
52
|
-
* @returns {void}
|
|
53
|
-
*
|
|
54
|
-
* @preserve
|
|
55
|
-
*/
|
|
56
|
-
const fixIds = (items, onChange) => {
|
|
57
|
-
const allIds = (items == null ? void 0 : items.map(({ id }) => id)) ?? [];
|
|
58
|
-
const hasDuplicates = (input) => {
|
|
59
|
-
var _a;
|
|
60
|
-
return ((_a = new Set(input)) == null ? void 0 : _a.size) !== (input == null ? void 0 : input.length);
|
|
61
|
-
};
|
|
62
|
-
const hasMissingIds = items == null ? void 0 : items.some(({ id }) => typeof id === "undefined" || id === null || id === "");
|
|
63
|
-
if (hasDuplicates(allIds) && (items == null ? void 0 : items.length) > 0 || hasMissingIds) {
|
|
64
|
-
const newItems = [...items].map((item, index) => ({
|
|
65
|
-
...item,
|
|
66
|
-
id: index + 1
|
|
67
|
-
}));
|
|
68
|
-
onChange(newItems);
|
|
19
|
+
if (simpleValue) {
|
|
20
|
+
return options == null ? void 0 : options.find(({ value: itemValue }) => itemValue === value);
|
|
69
21
|
}
|
|
22
|
+
return value;
|
|
70
23
|
};
|
|
71
24
|
export {
|
|
72
|
-
customOnChange,
|
|
73
|
-
fixIds,
|
|
74
25
|
getValue
|
|
75
26
|
};
|