@eightshift/ui-components 3.0.1 → 5.0.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 (144) hide show
  1. package/package.json +101 -101
  2. package/dist/Button-BPLceDeW.js +0 -185
  3. package/dist/Collection-CZxddMZS.js +0 -2332
  4. package/dist/Color-MV5kBVXr.js +0 -2452
  5. package/dist/ColorSwatch-BqQfVu4L.js +0 -64
  6. package/dist/ComboBox-_RfyhwZw.js +0 -1906
  7. package/dist/Dialog-8tYeQ9n4.js +0 -2300
  8. package/dist/FieldError-52GVSGgC.js +0 -42
  9. package/dist/FocusScope-Cri5BFRz.js +0 -831
  10. package/dist/Form-Cq3fu75_.js +0 -5
  11. package/dist/Group-_emcIVxI.js +0 -48
  12. package/dist/Heading-B2153VXe.js +0 -16
  13. package/dist/Hidden-rE6uR-lr.js +0 -41
  14. package/dist/Input-BxpFEIXV.js +0 -133
  15. package/dist/Label-icmbmNdI.js +0 -17
  16. package/dist/List-CZMUbkFU.js +0 -593
  17. package/dist/ListBox-Ca6hiCqz.js +0 -581
  18. package/dist/NumberFormatter-DA8u1Ot7.js +0 -140
  19. package/dist/OverlayArrow-CYXQSlEU.js +0 -629
  20. package/dist/RSPContexts-2lR5GG9p.js +0 -14
  21. package/dist/Select-aab027f3.esm-PDJCDE95.js +0 -2469
  22. package/dist/Separator-4IIDRlV_.js +0 -322
  23. package/dist/Slider-rz2XRMGm.js +0 -853
  24. package/dist/Text-DVSAPY-K.js +0 -16
  25. package/dist/VisuallyHidden-f9zX67a_.js +0 -48
  26. package/dist/_commonjsHelpers-CUmg6egw.js +0 -6
  27. package/dist/assets/index.css +0 -37
  28. package/dist/assets/style-admin.css +0 -5255
  29. package/dist/assets/style-editor.css +0 -5255
  30. package/dist/assets/style.css +0 -5261
  31. package/dist/assets/wp-font-enhancements.css +0 -8
  32. package/dist/assets/wp-ui-enhancements.css +0 -299
  33. package/dist/components/animated-visibility/animated-visibility.js +0 -105
  34. package/dist/components/base-control/base-control.js +0 -86
  35. package/dist/components/breakpoint-preview/breakpoint-preview.js +0 -161
  36. package/dist/components/button/button.js +0 -387
  37. package/dist/components/checkbox/checkbox.js +0 -320
  38. package/dist/components/color-pickers/color-picker.js +0 -272
  39. package/dist/components/color-pickers/color-swatch.js +0 -58
  40. package/dist/components/color-pickers/gradient-editor.js +0 -534
  41. package/dist/components/color-pickers/solid-color-picker.js +0 -1567
  42. package/dist/components/component-toggle/component-toggle.js +0 -158
  43. package/dist/components/container-panel/container-panel.js +0 -131
  44. package/dist/components/draggable/draggable-context.js +0 -5
  45. package/dist/components/draggable/draggable-handle.js +0 -46
  46. package/dist/components/draggable/draggable.js +0 -6207
  47. package/dist/components/draggable-list/draggable-list-context.js +0 -5
  48. package/dist/components/draggable-list/draggable-list-item.js +0 -77
  49. package/dist/components/draggable-list/draggable-list.js +0 -151
  50. package/dist/components/expandable/expandable.js +0 -342
  51. package/dist/components/index.js +0 -137
  52. package/dist/components/input-field/input-field.js +0 -231
  53. package/dist/components/item-collection/item-collection.js +0 -59
  54. package/dist/components/layout/hstack.js +0 -30
  55. package/dist/components/layout/vstack.js +0 -30
  56. package/dist/components/link-input/link-input.js +0 -293
  57. package/dist/components/matrix-align/matrix-align.js +0 -134
  58. package/dist/components/menu/menu.js +0 -285
  59. package/dist/components/modal/modal.js +0 -305
  60. package/dist/components/notice/notice.js +0 -123
  61. package/dist/components/number-picker/number-picker.js +0 -292
  62. package/dist/components/option-select/option-select.js +0 -264
  63. package/dist/components/options-panel/options-panel.js +0 -158
  64. package/dist/components/placeholders/file-placeholder.js +0 -42
  65. package/dist/components/placeholders/image-placeholder.js +0 -88
  66. package/dist/components/placeholders/media-placeholder.js +0 -63
  67. package/dist/components/popover/popover.js +0 -207
  68. package/dist/components/radio/radio.js +0 -579
  69. package/dist/components/repeater/repeater-context.js +0 -5
  70. package/dist/components/repeater/repeater-item.js +0 -119
  71. package/dist/components/repeater/repeater.js +0 -280
  72. package/dist/components/responsive/mini-responsive.js +0 -498
  73. package/dist/components/responsive/responsive-legacy.js +0 -343
  74. package/dist/components/responsive/responsive.js +0 -580
  75. package/dist/components/responsive-preview/responsive-preview.js +0 -123
  76. package/dist/components/rich-label/rich-label.js +0 -66
  77. package/dist/components/select/async-multi-select.js +0 -157
  78. package/dist/components/select/async-single-select.js +0 -137
  79. package/dist/components/select/custom-select-default-components.js +0 -38
  80. package/dist/components/select/multi-select-components.js +0 -8
  81. package/dist/components/select/multi-select.js +0 -151
  82. package/dist/components/select/react-select-component-wrappers.js +0 -90
  83. package/dist/components/select/shared.js +0 -26
  84. package/dist/components/select/single-select.js +0 -131
  85. package/dist/components/select/styles.js +0 -49
  86. package/dist/components/select/v2/async-select.js +0 -297
  87. package/dist/components/select/v2/shared.js +0 -24
  88. package/dist/components/select/v2/single-select.js +0 -990
  89. package/dist/components/slider/column-config-slider.js +0 -210
  90. package/dist/components/slider/slider.js +0 -343
  91. package/dist/components/slider/utils.js +0 -84
  92. package/dist/components/spacer/spacer.js +0 -97
  93. package/dist/components/tabs/tabs.js +0 -702
  94. package/dist/components/toggle/switch.js +0 -155
  95. package/dist/components/toggle/toggle.js +0 -64
  96. package/dist/components/toggle-button/toggle-button.js +0 -324
  97. package/dist/components/tooltip/tooltip.js +0 -525
  98. package/dist/context-D2KUdwNL.js +0 -92
  99. package/dist/default-i18n-CT_oS1Fy.js +0 -922
  100. package/dist/filterDOMProps-EDDcM64A.js +0 -28
  101. package/dist/icons/block-icon.js +0 -42
  102. package/dist/icons/generic-color-swatch.js +0 -113
  103. package/dist/icons/icons.js +0 -30371
  104. package/dist/icons/index.js +0 -11
  105. package/dist/icons/jsx-svg.js +0 -50
  106. package/dist/index-641ee5b8.esm-DIuJijyT.js +0 -3137
  107. package/dist/index-BKGQ6jGS.js +0 -44
  108. package/dist/index-CFozsmNS.js +0 -28321
  109. package/dist/index.js +0 -139
  110. package/dist/lite-DVmmD_-j.js +0 -7
  111. package/dist/modifiers.esm-BuJQPI1X.js +0 -31
  112. package/dist/multi-select-components-Sp-JEFEX.js +0 -3744
  113. package/dist/number-GajL10e1.js +0 -36
  114. package/dist/react-jsx-parser.min-DZCiis5V.js +0 -11753
  115. package/dist/react-select-async.esm-Bql4G5iV.js +0 -107
  116. package/dist/react-select.esm-B_TudhTU.js +0 -15
  117. package/dist/style-admin.js +0 -1
  118. package/dist/style-editor.js +0 -1
  119. package/dist/style.js +0 -1
  120. package/dist/textSelection-0UUS8Yfg.js +0 -46
  121. package/dist/useButton-Cg474OYB.js +0 -71
  122. package/dist/useEvent-B0b-6KBr.js +0 -23
  123. package/dist/useFocusRing-CV5l3lf6.js +0 -107
  124. package/dist/useFormReset-C5OggHsw.js +0 -22
  125. package/dist/useFormValidation-DhDNSjws.js +0 -224
  126. package/dist/useHover-DwDr6ozG.js +0 -900
  127. package/dist/useLabel-D7HkNEHT.js +0 -27
  128. package/dist/useLabels-D8cxd1Z8.js +0 -23
  129. package/dist/useListState-DVr6aYd_.js +0 -161
  130. package/dist/useLocalizedStringFormatter-CFP1YZWQ.js +0 -121
  131. package/dist/useNumberField-TwM0Z9D1.js +0 -1204
  132. package/dist/useNumberFormatter-321rAb4J.js +0 -13
  133. package/dist/usePress-Cucx-xSA.js +0 -664
  134. package/dist/useSingleSelectListState-CMGsRHHh.js +0 -38
  135. package/dist/useToggle-C0I3vs0g.js +0 -59
  136. package/dist/useToggleState-CmQX3SoX.js +0 -19
  137. package/dist/utilities/array-helpers.js +0 -56
  138. package/dist/utilities/debounce-throttle.js +0 -123
  139. package/dist/utilities/es-dash.js +0 -376
  140. package/dist/utilities/index.js +0 -27
  141. package/dist/utilities/text-helpers.js +0 -136
  142. package/dist/utils-DkCSC521.js +0 -370
  143. package/dist/wp/wp-font-enhancements.js +0 -1
  144. package/dist/wp/wp-ui-enhancements.js +0 -1
@@ -1,107 +0,0 @@
1
- import { a as _objectWithoutProperties, b as _slicedToArray, h as handleInputChange, d as _objectSpread2, e as _defineProperty, _ as _extends } from "./index-641ee5b8.esm-DIuJijyT.js";
2
- import * as React from "react";
3
- import { useRef, useState, useEffect, useCallback, forwardRef } from "react";
4
- import { u as useStateManager, S as Select } from "./Select-aab027f3.esm-PDJCDE95.js";
5
- import "./index-CFozsmNS.js";
6
- var _excluded = ["defaultOptions", "cacheOptions", "loadOptions", "options", "isLoading", "onInputChange", "filterOption"];
7
- function useAsync(_ref) {
8
- var _ref$defaultOptions = _ref.defaultOptions, propsDefaultOptions = _ref$defaultOptions === void 0 ? false : _ref$defaultOptions, _ref$cacheOptions = _ref.cacheOptions, cacheOptions = _ref$cacheOptions === void 0 ? false : _ref$cacheOptions, propsLoadOptions = _ref.loadOptions;
9
- _ref.options;
10
- var _ref$isLoading = _ref.isLoading, propsIsLoading = _ref$isLoading === void 0 ? false : _ref$isLoading, propsOnInputChange = _ref.onInputChange, _ref$filterOption = _ref.filterOption, filterOption = _ref$filterOption === void 0 ? null : _ref$filterOption, restSelectProps = _objectWithoutProperties(_ref, _excluded);
11
- var propsInputValue = restSelectProps.inputValue;
12
- var lastRequest = useRef(void 0);
13
- var mounted = useRef(false);
14
- var _useState = useState(Array.isArray(propsDefaultOptions) ? propsDefaultOptions : void 0), _useState2 = _slicedToArray(_useState, 2), defaultOptions = _useState2[0], setDefaultOptions = _useState2[1];
15
- var _useState3 = useState(typeof propsInputValue !== "undefined" ? propsInputValue : ""), _useState4 = _slicedToArray(_useState3, 2), stateInputValue = _useState4[0], setStateInputValue = _useState4[1];
16
- var _useState5 = useState(propsDefaultOptions === true), _useState6 = _slicedToArray(_useState5, 2), isLoading = _useState6[0], setIsLoading = _useState6[1];
17
- var _useState7 = useState(void 0), _useState8 = _slicedToArray(_useState7, 2), loadedInputValue = _useState8[0], setLoadedInputValue = _useState8[1];
18
- var _useState9 = useState([]), _useState10 = _slicedToArray(_useState9, 2), loadedOptions = _useState10[0], setLoadedOptions = _useState10[1];
19
- var _useState11 = useState(false), _useState12 = _slicedToArray(_useState11, 2), passEmptyOptions = _useState12[0], setPassEmptyOptions = _useState12[1];
20
- var _useState13 = useState({}), _useState14 = _slicedToArray(_useState13, 2), optionsCache = _useState14[0], setOptionsCache = _useState14[1];
21
- var _useState15 = useState(void 0), _useState16 = _slicedToArray(_useState15, 2), prevDefaultOptions = _useState16[0], setPrevDefaultOptions = _useState16[1];
22
- var _useState17 = useState(void 0), _useState18 = _slicedToArray(_useState17, 2), prevCacheOptions = _useState18[0], setPrevCacheOptions = _useState18[1];
23
- if (cacheOptions !== prevCacheOptions) {
24
- setOptionsCache({});
25
- setPrevCacheOptions(cacheOptions);
26
- }
27
- if (propsDefaultOptions !== prevDefaultOptions) {
28
- setDefaultOptions(Array.isArray(propsDefaultOptions) ? propsDefaultOptions : void 0);
29
- setPrevDefaultOptions(propsDefaultOptions);
30
- }
31
- useEffect(function() {
32
- mounted.current = true;
33
- return function() {
34
- mounted.current = false;
35
- };
36
- }, []);
37
- var loadOptions = useCallback(function(inputValue, callback) {
38
- if (!propsLoadOptions) return callback();
39
- var loader = propsLoadOptions(inputValue, callback);
40
- if (loader && typeof loader.then === "function") {
41
- loader.then(callback, function() {
42
- return callback();
43
- });
44
- }
45
- }, [propsLoadOptions]);
46
- useEffect(function() {
47
- if (propsDefaultOptions === true) {
48
- loadOptions(stateInputValue, function(options2) {
49
- if (!mounted.current) return;
50
- setDefaultOptions(options2 || []);
51
- setIsLoading(!!lastRequest.current);
52
- });
53
- }
54
- }, []);
55
- var onInputChange = useCallback(function(newValue, actionMeta) {
56
- var inputValue = handleInputChange(newValue, actionMeta, propsOnInputChange);
57
- if (!inputValue) {
58
- lastRequest.current = void 0;
59
- setStateInputValue("");
60
- setLoadedInputValue("");
61
- setLoadedOptions([]);
62
- setIsLoading(false);
63
- setPassEmptyOptions(false);
64
- return;
65
- }
66
- if (cacheOptions && optionsCache[inputValue]) {
67
- setStateInputValue(inputValue);
68
- setLoadedInputValue(inputValue);
69
- setLoadedOptions(optionsCache[inputValue]);
70
- setIsLoading(false);
71
- setPassEmptyOptions(false);
72
- } else {
73
- var request = lastRequest.current = {};
74
- setStateInputValue(inputValue);
75
- setIsLoading(true);
76
- setPassEmptyOptions(!loadedInputValue);
77
- loadOptions(inputValue, function(options2) {
78
- if (!mounted) return;
79
- if (request !== lastRequest.current) return;
80
- lastRequest.current = void 0;
81
- setIsLoading(false);
82
- setLoadedInputValue(inputValue);
83
- setLoadedOptions(options2 || []);
84
- setPassEmptyOptions(false);
85
- setOptionsCache(options2 ? _objectSpread2(_objectSpread2({}, optionsCache), {}, _defineProperty({}, inputValue, options2)) : optionsCache);
86
- });
87
- }
88
- }, [cacheOptions, loadOptions, loadedInputValue, optionsCache, propsOnInputChange]);
89
- var options = passEmptyOptions ? [] : stateInputValue && loadedInputValue ? loadedOptions : defaultOptions || [];
90
- return _objectSpread2(_objectSpread2({}, restSelectProps), {}, {
91
- options,
92
- isLoading: isLoading || propsIsLoading,
93
- onInputChange,
94
- filterOption
95
- });
96
- }
97
- var AsyncSelect = /* @__PURE__ */ forwardRef(function(props, ref) {
98
- var stateManagedProps = useAsync(props);
99
- var selectProps = useStateManager(stateManagedProps);
100
- return /* @__PURE__ */ React.createElement(Select, _extends({
101
- ref
102
- }, selectProps));
103
- });
104
- var AsyncSelect$1 = AsyncSelect;
105
- export {
106
- AsyncSelect$1 as A
107
- };
@@ -1,15 +0,0 @@
1
- import { u as useStateManager, S as Select } from "./Select-aab027f3.esm-PDJCDE95.js";
2
- import { _ as _extends } from "./index-641ee5b8.esm-DIuJijyT.js";
3
- import * as React from "react";
4
- import { forwardRef } from "react";
5
- import "./index-CFozsmNS.js";
6
- var StateManagedSelect = /* @__PURE__ */ forwardRef(function(props, ref) {
7
- var baseSelectProps = useStateManager(props);
8
- return /* @__PURE__ */ React.createElement(Select, _extends({
9
- ref
10
- }, baseSelectProps));
11
- });
12
- var StateManagedSelect$1 = StateManagedSelect;
13
- export {
14
- StateManagedSelect$1 as S
15
- };
@@ -1 +0,0 @@
1
- import './assets/style-admin.css';
@@ -1 +0,0 @@
1
- import './assets/index.css';import './assets/style-editor.css';/* empty css */
package/dist/style.js DELETED
@@ -1 +0,0 @@
1
- import './assets/index.css';import './assets/style.css';/* empty css */
@@ -1,46 +0,0 @@
1
- import { c as $c87311424ea30a05$export$fedb369cb70207f1, d as $431fbd86ca7dc216$export$b204af158042fbac, e as $bbed8b41f857bcc0$export$24490316f764c430 } from "./useHover-DwDr6ozG.js";
2
- let $14c0b72509d70225$var$state = "default";
3
- let $14c0b72509d70225$var$savedUserSelect = "";
4
- let $14c0b72509d70225$var$modifiedElementMap = /* @__PURE__ */ new WeakMap();
5
- function $14c0b72509d70225$export$16a4697467175487(target) {
6
- if ($c87311424ea30a05$export$fedb369cb70207f1()) {
7
- if ($14c0b72509d70225$var$state === "default") {
8
- const documentObject = $431fbd86ca7dc216$export$b204af158042fbac(target);
9
- $14c0b72509d70225$var$savedUserSelect = documentObject.documentElement.style.webkitUserSelect;
10
- documentObject.documentElement.style.webkitUserSelect = "none";
11
- }
12
- $14c0b72509d70225$var$state = "disabled";
13
- } else if (target instanceof HTMLElement || target instanceof SVGElement) {
14
- let property = "userSelect" in target.style ? "userSelect" : "webkitUserSelect";
15
- $14c0b72509d70225$var$modifiedElementMap.set(target, target.style[property]);
16
- target.style[property] = "none";
17
- }
18
- }
19
- function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
20
- if ($c87311424ea30a05$export$fedb369cb70207f1()) {
21
- if ($14c0b72509d70225$var$state !== "disabled") return;
22
- $14c0b72509d70225$var$state = "restoring";
23
- setTimeout(() => {
24
- $bbed8b41f857bcc0$export$24490316f764c430(() => {
25
- if ($14c0b72509d70225$var$state === "restoring") {
26
- const documentObject = $431fbd86ca7dc216$export$b204af158042fbac(target);
27
- if (documentObject.documentElement.style.webkitUserSelect === "none") documentObject.documentElement.style.webkitUserSelect = $14c0b72509d70225$var$savedUserSelect || "";
28
- $14c0b72509d70225$var$savedUserSelect = "";
29
- $14c0b72509d70225$var$state = "default";
30
- }
31
- });
32
- }, 300);
33
- } else if (target instanceof HTMLElement || target instanceof SVGElement) {
34
- if (target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
35
- let targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target);
36
- let property = "userSelect" in target.style ? "userSelect" : "webkitUserSelect";
37
- if (target.style[property] === "none") target.style[property] = targetOldUserSelect;
38
- if (target.getAttribute("style") === "") target.removeAttribute("style");
39
- $14c0b72509d70225$var$modifiedElementMap.delete(target);
40
- }
41
- }
42
- }
43
- export {
44
- $14c0b72509d70225$export$b0d6fa1ab32e3295 as $,
45
- $14c0b72509d70225$export$16a4697467175487 as a
46
- };
@@ -1,71 +0,0 @@
1
- import { d as $3ef42575df84b30b$export$9d1611c77c2fe928 } from "./utils-DkCSC521.js";
2
- import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "./filterDOMProps-EDDcM64A.js";
3
- import { $ as $f6c31cce2adf654f$export$45712eceda6fad21 } from "./usePress-Cucx-xSA.js";
4
- import { a as $f645667febf57a63$export$4c014de7c8940b4c } from "./useHover-DwDr6ozG.js";
5
- function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
6
- let {
7
- elementType = "button",
8
- isDisabled,
9
- onPress,
10
- onPressStart,
11
- onPressEnd,
12
- onPressUp,
13
- onPressChange,
14
- preventFocusOnPress,
15
- allowFocusWhenDisabled,
16
- // @ts-ignore
17
- onClick: deprecatedOnClick,
18
- href,
19
- target,
20
- rel,
21
- type = "button"
22
- } = props;
23
- let additionalProps;
24
- if (elementType === "button") additionalProps = {
25
- type,
26
- disabled: isDisabled
27
- };
28
- else additionalProps = {
29
- role: "button",
30
- href: elementType === "a" && !isDisabled ? href : void 0,
31
- target: elementType === "a" ? target : void 0,
32
- type: elementType === "input" ? type : void 0,
33
- disabled: elementType === "input" ? isDisabled : void 0,
34
- "aria-disabled": !isDisabled || elementType === "input" ? void 0 : isDisabled,
35
- rel: elementType === "a" ? rel : void 0
36
- };
37
- let { pressProps, isPressed } = $f6c31cce2adf654f$export$45712eceda6fad21({
38
- onPressStart,
39
- onPressEnd,
40
- onPressChange,
41
- onPress,
42
- onPressUp,
43
- isDisabled,
44
- preventFocusOnPress,
45
- ref
46
- });
47
- let { focusableProps } = $f645667febf57a63$export$4c014de7c8940b4c(props, ref);
48
- if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
49
- let buttonProps = $3ef42575df84b30b$export$9d1611c77c2fe928(focusableProps, pressProps, $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
50
- labelable: true
51
- }));
52
- return {
53
- isPressed,
54
- buttonProps: $3ef42575df84b30b$export$9d1611c77c2fe928(additionalProps, buttonProps, {
55
- "aria-haspopup": props["aria-haspopup"],
56
- "aria-expanded": props["aria-expanded"],
57
- "aria-controls": props["aria-controls"],
58
- "aria-pressed": props["aria-pressed"],
59
- "aria-current": props["aria-current"],
60
- onClick: (e) => {
61
- if (deprecatedOnClick) {
62
- deprecatedOnClick(e);
63
- console.warn("onClick is deprecated, please use onPress");
64
- }
65
- }
66
- })
67
- };
68
- }
69
- export {
70
- $701a24aa0da5b062$export$ea18c227d4417cc3 as $
71
- };
@@ -1,23 +0,0 @@
1
- import { f as $8ae05eaa5c114e9c$export$7f54fc3180508a52 } from "./utils-DkCSC521.js";
2
- import { useEffect } from "react";
3
- function $e9faafb641e167db$export$90fc3a17d93f704c(ref, event, handler, options) {
4
- let handleEvent = $8ae05eaa5c114e9c$export$7f54fc3180508a52(handler);
5
- let isDisabled = handler == null;
6
- useEffect(() => {
7
- if (isDisabled || !ref.current) return;
8
- let element = ref.current;
9
- element.addEventListener(event, handleEvent, options);
10
- return () => {
11
- element.removeEventListener(event, handleEvent, options);
12
- };
13
- }, [
14
- ref,
15
- event,
16
- options,
17
- isDisabled,
18
- handleEvent
19
- ]);
20
- }
21
- export {
22
- $e9faafb641e167db$export$90fc3a17d93f704c as $
23
- };
@@ -1,107 +0,0 @@
1
- import { g as $03deb23ff14920c4$export$4eaf04e54aa8eed6, h as $8a9cb279dc87e130$export$715c682d09d639cc, d as $431fbd86ca7dc216$export$b204af158042fbac, i as $d4ee10de306f2510$export$cd4e5573fbe2b576, j as $d4ee10de306f2510$export$e58f029f0fbfdb29, k as $d4ee10de306f2510$export$4282f70798064fe0, l as $8a9cb279dc87e130$export$905e7fc544a71f36, m as $507fabe10e71c6fb$export$b9b3dfddab17db27, n as $507fabe10e71c6fb$export$ec71b4b83ac08ec3, o as $a1ea59d68270f0dd$export$f8168d8dd8fd66e6 } from "./useHover-DwDr6ozG.js";
2
- import { useRef, useCallback, useState } from "react";
3
- function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
4
- let { isDisabled, onBlurWithin, onFocusWithin, onFocusWithinChange } = props;
5
- let state = useRef({
6
- isFocusWithin: false
7
- });
8
- let { addGlobalListener, removeAllGlobalListeners } = $03deb23ff14920c4$export$4eaf04e54aa8eed6();
9
- let onBlur = useCallback((e) => {
10
- if (!e.currentTarget.contains(e.target)) return;
11
- if (state.current.isFocusWithin && !e.currentTarget.contains(e.relatedTarget)) {
12
- state.current.isFocusWithin = false;
13
- removeAllGlobalListeners();
14
- if (onBlurWithin) onBlurWithin(e);
15
- if (onFocusWithinChange) onFocusWithinChange(false);
16
- }
17
- }, [
18
- onBlurWithin,
19
- onFocusWithinChange,
20
- state,
21
- removeAllGlobalListeners
22
- ]);
23
- let onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur);
24
- let onFocus = useCallback((e) => {
25
- if (!e.currentTarget.contains(e.target)) return;
26
- const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(e.target);
27
- const activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument);
28
- if (!state.current.isFocusWithin && activeElement === $d4ee10de306f2510$export$e58f029f0fbfdb29(e.nativeEvent)) {
29
- if (onFocusWithin) onFocusWithin(e);
30
- if (onFocusWithinChange) onFocusWithinChange(true);
31
- state.current.isFocusWithin = true;
32
- onSyntheticFocus(e);
33
- let currentTarget = e.currentTarget;
34
- addGlobalListener(ownerDocument, "focus", (e2) => {
35
- if (state.current.isFocusWithin && !$d4ee10de306f2510$export$4282f70798064fe0(currentTarget, e2.target)) {
36
- let event = new $8a9cb279dc87e130$export$905e7fc544a71f36("blur", new ownerDocument.defaultView.FocusEvent("blur", {
37
- relatedTarget: e2.target
38
- }));
39
- event.target = currentTarget;
40
- event.currentTarget = currentTarget;
41
- onBlur(event);
42
- }
43
- }, {
44
- capture: true
45
- });
46
- }
47
- }, [
48
- onFocusWithin,
49
- onFocusWithinChange,
50
- onSyntheticFocus,
51
- addGlobalListener,
52
- onBlur
53
- ]);
54
- if (isDisabled) return {
55
- focusWithinProps: {
56
- // These cannot be null, that would conflict in mergeProps
57
- onFocus: void 0,
58
- onBlur: void 0
59
- }
60
- };
61
- return {
62
- focusWithinProps: {
63
- onFocus,
64
- onBlur
65
- }
66
- };
67
- }
68
- function $f7dceffc5ad7768b$export$4e328f61c538687f(props = {}) {
69
- let { autoFocus = false, isTextInput, within } = props;
70
- let state = useRef({
71
- isFocused: false,
72
- isFocusVisible: autoFocus || $507fabe10e71c6fb$export$b9b3dfddab17db27()
73
- });
74
- let [isFocused, setFocused] = useState(false);
75
- let [isFocusVisibleState, setFocusVisible] = useState(() => state.current.isFocused && state.current.isFocusVisible);
76
- let updateState = useCallback(() => setFocusVisible(state.current.isFocused && state.current.isFocusVisible), []);
77
- let onFocusChange = useCallback((isFocused2) => {
78
- state.current.isFocused = isFocused2;
79
- setFocused(isFocused2);
80
- updateState();
81
- }, [
82
- updateState
83
- ]);
84
- $507fabe10e71c6fb$export$ec71b4b83ac08ec3((isFocusVisible) => {
85
- state.current.isFocusVisible = isFocusVisible;
86
- updateState();
87
- }, [], {
88
- isTextInput
89
- });
90
- let { focusProps } = $a1ea59d68270f0dd$export$f8168d8dd8fd66e6({
91
- isDisabled: within,
92
- onFocusChange
93
- });
94
- let { focusWithinProps } = $9ab94262bd0047c7$export$420e68273165f4ec({
95
- isDisabled: !within,
96
- onFocusWithinChange: onFocusChange
97
- });
98
- return {
99
- isFocused,
100
- isFocusVisible: isFocusVisibleState,
101
- focusProps: within ? focusWithinProps : focusProps
102
- };
103
- }
104
- export {
105
- $f7dceffc5ad7768b$export$4e328f61c538687f as $,
106
- $9ab94262bd0047c7$export$420e68273165f4ec as a
107
- };
@@ -1,22 +0,0 @@
1
- import { f as $8ae05eaa5c114e9c$export$7f54fc3180508a52 } from "./utils-DkCSC521.js";
2
- import { useRef, useEffect } from "react";
3
- function $99facab73266f662$export$5add1d006293d136(ref, initialValue, onReset) {
4
- let resetValue = useRef(initialValue);
5
- let handleReset = $8ae05eaa5c114e9c$export$7f54fc3180508a52(() => {
6
- if (onReset) onReset(resetValue.current);
7
- });
8
- useEffect(() => {
9
- var _ref_current;
10
- let form = ref === null || ref === void 0 ? void 0 : (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.form;
11
- form === null || form === void 0 ? void 0 : form.addEventListener("reset", handleReset);
12
- return () => {
13
- form === null || form === void 0 ? void 0 : form.removeEventListener("reset", handleReset);
14
- };
15
- }, [
16
- ref,
17
- handleReset
18
- ]);
19
- }
20
- export {
21
- $99facab73266f662$export$5add1d006293d136 as $
22
- };
@@ -1,224 +0,0 @@
1
- import { useMemo, useContext, createContext, useState, useRef, useEffect } from "react";
2
- import { p as $507fabe10e71c6fb$export$8397ddfc504fdb9a } from "./useHover-DwDr6ozG.js";
3
- import { k as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, f as $8ae05eaa5c114e9c$export$7f54fc3180508a52 } from "./utils-DkCSC521.js";
4
- const $e5be200c675c3b3a$export$aca958c65c314e6c = {
5
- badInput: false,
6
- customError: false,
7
- patternMismatch: false,
8
- rangeOverflow: false,
9
- rangeUnderflow: false,
10
- stepMismatch: false,
11
- tooLong: false,
12
- tooShort: false,
13
- typeMismatch: false,
14
- valueMissing: false,
15
- valid: true
16
- };
17
- const $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE = {
18
- ...$e5be200c675c3b3a$export$aca958c65c314e6c,
19
- customError: true,
20
- valid: false
21
- };
22
- const $e5be200c675c3b3a$export$dad6ae84456c676a = {
23
- isInvalid: false,
24
- validationDetails: $e5be200c675c3b3a$export$aca958c65c314e6c,
25
- validationErrors: []
26
- };
27
- const $e5be200c675c3b3a$export$571b5131b7e65c11 = createContext({});
28
- const $e5be200c675c3b3a$export$a763b9476acd3eb = "__formValidationState" + Date.now();
29
- function $e5be200c675c3b3a$export$fc1a364ae1f3ff10(props) {
30
- if (props[$e5be200c675c3b3a$export$a763b9476acd3eb]) {
31
- let { realtimeValidation, displayValidation, updateValidation, resetValidation, commitValidation } = props[$e5be200c675c3b3a$export$a763b9476acd3eb];
32
- return {
33
- realtimeValidation,
34
- displayValidation,
35
- updateValidation,
36
- resetValidation,
37
- commitValidation
38
- };
39
- }
40
- return $e5be200c675c3b3a$var$useFormValidationStateImpl(props);
41
- }
42
- function $e5be200c675c3b3a$var$useFormValidationStateImpl(props) {
43
- let { isInvalid, validationState, name, value, builtinValidation, validate, validationBehavior = "aria" } = props;
44
- if (validationState) isInvalid || (isInvalid = validationState === "invalid");
45
- let controlledError = isInvalid !== void 0 ? {
46
- isInvalid,
47
- validationErrors: [],
48
- validationDetails: $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE
49
- } : null;
50
- let clientError = useMemo(() => {
51
- if (!validate || value == null) return null;
52
- let validateErrors = $e5be200c675c3b3a$var$runValidate(validate, value);
53
- return $e5be200c675c3b3a$var$getValidationResult(validateErrors);
54
- }, [
55
- validate,
56
- value
57
- ]);
58
- if (builtinValidation === null || builtinValidation === void 0 ? void 0 : builtinValidation.validationDetails.valid) builtinValidation = void 0;
59
- let serverErrors = useContext($e5be200c675c3b3a$export$571b5131b7e65c11);
60
- let serverErrorMessages = useMemo(() => {
61
- if (name) return Array.isArray(name) ? name.flatMap((name2) => $e5be200c675c3b3a$var$asArray(serverErrors[name2])) : $e5be200c675c3b3a$var$asArray(serverErrors[name]);
62
- return [];
63
- }, [
64
- serverErrors,
65
- name
66
- ]);
67
- let [lastServerErrors, setLastServerErrors] = useState(serverErrors);
68
- let [isServerErrorCleared, setServerErrorCleared] = useState(false);
69
- if (serverErrors !== lastServerErrors) {
70
- setLastServerErrors(serverErrors);
71
- setServerErrorCleared(false);
72
- }
73
- let serverError = useMemo(() => $e5be200c675c3b3a$var$getValidationResult(isServerErrorCleared ? [] : serverErrorMessages), [
74
- isServerErrorCleared,
75
- serverErrorMessages
76
- ]);
77
- let nextValidation = useRef($e5be200c675c3b3a$export$dad6ae84456c676a);
78
- let [currentValidity, setCurrentValidity] = useState($e5be200c675c3b3a$export$dad6ae84456c676a);
79
- let lastError = useRef($e5be200c675c3b3a$export$dad6ae84456c676a);
80
- let commitValidation = () => {
81
- if (!commitQueued) return;
82
- setCommitQueued(false);
83
- let error = clientError || builtinValidation || nextValidation.current;
84
- if (!$e5be200c675c3b3a$var$isEqualValidation(error, lastError.current)) {
85
- lastError.current = error;
86
- setCurrentValidity(error);
87
- }
88
- };
89
- let [commitQueued, setCommitQueued] = useState(false);
90
- useEffect(commitValidation);
91
- let realtimeValidation = controlledError || serverError || clientError || builtinValidation || $e5be200c675c3b3a$export$dad6ae84456c676a;
92
- let displayValidation = validationBehavior === "native" ? controlledError || serverError || currentValidity : controlledError || serverError || clientError || builtinValidation || currentValidity;
93
- return {
94
- realtimeValidation,
95
- displayValidation,
96
- updateValidation(value2) {
97
- if (validationBehavior === "aria" && !$e5be200c675c3b3a$var$isEqualValidation(currentValidity, value2)) setCurrentValidity(value2);
98
- else nextValidation.current = value2;
99
- },
100
- resetValidation() {
101
- let error = $e5be200c675c3b3a$export$dad6ae84456c676a;
102
- if (!$e5be200c675c3b3a$var$isEqualValidation(error, lastError.current)) {
103
- lastError.current = error;
104
- setCurrentValidity(error);
105
- }
106
- if (validationBehavior === "native") setCommitQueued(false);
107
- setServerErrorCleared(true);
108
- },
109
- commitValidation() {
110
- if (validationBehavior === "native") setCommitQueued(true);
111
- setServerErrorCleared(true);
112
- }
113
- };
114
- }
115
- function $e5be200c675c3b3a$var$asArray(v) {
116
- if (!v) return [];
117
- return Array.isArray(v) ? v : [
118
- v
119
- ];
120
- }
121
- function $e5be200c675c3b3a$var$runValidate(validate, value) {
122
- if (typeof validate === "function") {
123
- let e = validate(value);
124
- if (e && typeof e !== "boolean") return $e5be200c675c3b3a$var$asArray(e);
125
- }
126
- return [];
127
- }
128
- function $e5be200c675c3b3a$var$getValidationResult(errors) {
129
- return errors.length ? {
130
- isInvalid: true,
131
- validationErrors: errors,
132
- validationDetails: $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE
133
- } : null;
134
- }
135
- function $e5be200c675c3b3a$var$isEqualValidation(a, b) {
136
- if (a === b) return true;
137
- return !!a && !!b && a.isInvalid === b.isInvalid && a.validationErrors.length === b.validationErrors.length && a.validationErrors.every((a2, i) => a2 === b.validationErrors[i]) && Object.entries(a.validationDetails).every(([k, v]) => b.validationDetails[k] === v);
138
- }
139
- function $e93e671b31057976$export$b8473d3665f3a75a(props, state, ref) {
140
- let { validationBehavior, focus } = props;
141
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
142
- if (validationBehavior === "native" && (ref === null || ref === void 0 ? void 0 : ref.current) && !ref.current.disabled) {
143
- let errorMessage = state.realtimeValidation.isInvalid ? state.realtimeValidation.validationErrors.join(" ") || "Invalid value." : "";
144
- ref.current.setCustomValidity(errorMessage);
145
- if (!ref.current.hasAttribute("title")) ref.current.title = "";
146
- if (!state.realtimeValidation.isInvalid) state.updateValidation($e93e671b31057976$var$getNativeValidity(ref.current));
147
- }
148
- });
149
- let onReset = $8ae05eaa5c114e9c$export$7f54fc3180508a52(() => {
150
- state.resetValidation();
151
- });
152
- let onInvalid = $8ae05eaa5c114e9c$export$7f54fc3180508a52((e) => {
153
- var _ref_current;
154
- if (!state.displayValidation.isInvalid) state.commitValidation();
155
- let form = ref === null || ref === void 0 ? void 0 : (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.form;
156
- if (!e.defaultPrevented && ref && form && $e93e671b31057976$var$getFirstInvalidInput(form) === ref.current) {
157
- var _ref_current1;
158
- if (focus) focus();
159
- else (_ref_current1 = ref.current) === null || _ref_current1 === void 0 ? void 0 : _ref_current1.focus();
160
- $507fabe10e71c6fb$export$8397ddfc504fdb9a("keyboard");
161
- }
162
- e.preventDefault();
163
- });
164
- let onChange = $8ae05eaa5c114e9c$export$7f54fc3180508a52(() => {
165
- state.commitValidation();
166
- });
167
- useEffect(() => {
168
- let input = ref === null || ref === void 0 ? void 0 : ref.current;
169
- if (!input) return;
170
- let form = input.form;
171
- input.addEventListener("invalid", onInvalid);
172
- input.addEventListener("change", onChange);
173
- form === null || form === void 0 ? void 0 : form.addEventListener("reset", onReset);
174
- return () => {
175
- input.removeEventListener("invalid", onInvalid);
176
- input.removeEventListener("change", onChange);
177
- form === null || form === void 0 ? void 0 : form.removeEventListener("reset", onReset);
178
- };
179
- }, [
180
- ref,
181
- onInvalid,
182
- onChange,
183
- onReset,
184
- validationBehavior
185
- ]);
186
- }
187
- function $e93e671b31057976$var$getValidity(input) {
188
- let validity = input.validity;
189
- return {
190
- badInput: validity.badInput,
191
- customError: validity.customError,
192
- patternMismatch: validity.patternMismatch,
193
- rangeOverflow: validity.rangeOverflow,
194
- rangeUnderflow: validity.rangeUnderflow,
195
- stepMismatch: validity.stepMismatch,
196
- tooLong: validity.tooLong,
197
- tooShort: validity.tooShort,
198
- typeMismatch: validity.typeMismatch,
199
- valueMissing: validity.valueMissing,
200
- valid: validity.valid
201
- };
202
- }
203
- function $e93e671b31057976$var$getNativeValidity(input) {
204
- return {
205
- isInvalid: !input.validity.valid,
206
- validationDetails: $e93e671b31057976$var$getValidity(input),
207
- validationErrors: input.validationMessage ? [
208
- input.validationMessage
209
- ] : []
210
- };
211
- }
212
- function $e93e671b31057976$var$getFirstInvalidInput(form) {
213
- for (let i = 0; i < form.elements.length; i++) {
214
- let element = form.elements[i];
215
- if (!element.validity.valid) return element;
216
- }
217
- return null;
218
- }
219
- export {
220
- $e5be200c675c3b3a$export$fc1a364ae1f3ff10 as $,
221
- $e93e671b31057976$export$b8473d3665f3a75a as a,
222
- $e5be200c675c3b3a$export$a763b9476acd3eb as b,
223
- $e5be200c675c3b3a$export$dad6ae84456c676a as c
224
- };