@eightshift/ui-components 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dist/Checkbox-BLcVbhiO.js +178 -0
- package/dist/ColorSwatch-Cmlex_kT.js +66 -0
- package/dist/FieldError-wtMA4667.js +42 -0
- package/dist/FocusScope-1u9yyfIN.js +725 -0
- package/dist/Form-Cq3fu75_.js +5 -0
- package/dist/GridList-BZPXp3_O.js +1256 -0
- package/dist/Group-DyqpTRPe.js +49 -0
- package/dist/Input-jsbb4ugq.js +130 -0
- package/dist/Label-BPzS-sR7.js +17 -0
- package/dist/ListBox-w9gDaJkV.js +4423 -0
- package/dist/LiveAnnouncer-IsokfWQ5.js +73 -0
- package/dist/NumberFormatter-LzoKy975.js +160 -0
- package/dist/RSPContexts-CrNYmadY.js +14 -0
- package/dist/Select-49a62830.esm-C-RFtLiD.js +2541 -0
- package/dist/SelectionManager-mefd0ThJ.js +2155 -0
- package/dist/Separator-DHn0CwdK.js +325 -0
- package/dist/Slider-Pyh2V4bY.js +885 -0
- package/dist/Text-BM136LvS.js +17 -0
- package/dist/VisuallyHidden-BYRI1Lfo.js +51 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
- package/dist/ariaHideOutside-ByKBPHmX.js +113 -0
- package/dist/assets/style.css +1 -0
- package/dist/button-BkkdyHfJ.js +307 -0
- package/dist/components/animated-visibility/animated-visibility.js +7165 -0
- package/dist/components/base-control/base-control.js +97 -0
- package/dist/components/breakpoint-preview/breakpoint-preview.js +218 -0
- package/dist/components/button/button.js +10 -0
- package/dist/components/checkbox/checkbox.js +119 -0
- package/dist/components/color-pickers/color-picker.js +242 -0
- package/dist/components/color-pickers/color-swatch.js +62 -0
- package/dist/components/color-pickers/gradient-editor.js +516 -0
- package/dist/components/color-pickers/solid-color-picker.js +1633 -0
- package/dist/components/component-toggle/component-toggle.js +71 -0
- package/dist/components/container-panel/container-panel.js +39 -0
- package/dist/components/expandable/expandable.js +144 -0
- package/dist/components/input-field/input-field.js +224 -0
- package/dist/components/link-input/link-input.js +937 -0
- package/dist/components/list-box/list-box.js +152 -0
- package/dist/components/matrix-align/matrix-align.js +185 -0
- package/dist/components/menu/menu.js +1608 -0
- package/dist/components/notice/notice.js +119 -0
- package/dist/components/number-picker/number-picker.js +277 -0
- package/dist/components/popover/popover.js +9 -0
- package/dist/components/radio/radio.js +552 -0
- package/dist/components/repeater/repeater-item.js +127 -0
- package/dist/components/repeater/repeater.js +248 -0
- package/dist/components/responsive/responsive-legacy.js +326 -0
- package/dist/components/responsive/responsive.js +499 -0
- package/dist/components/responsive-preview/responsive-preview.js +119 -0
- package/dist/components/rich-label/rich-label.js +56 -0
- package/dist/components/select/async-multi-select.js +144 -0
- package/dist/components/select/async-single-select.js +126 -0
- package/dist/components/select/custom-select-default-components.js +38 -0
- package/dist/components/select/multi-select-components.js +8 -0
- package/dist/components/select/multi-select.js +134 -0
- package/dist/components/select/react-select-component-wrappers.js +90 -0
- package/dist/components/select/shared.js +45 -0
- package/dist/components/select/single-select.js +116 -0
- package/dist/components/select/styles.js +55 -0
- package/dist/components/slider/column-config-slider.js +225 -0
- package/dist/components/slider/slider.js +362 -0
- package/dist/components/slider/utils.js +45 -0
- package/dist/components/spacer/spacer.js +93 -0
- package/dist/components/tabs/tabs.js +626 -0
- package/dist/components/toggle/switch.js +140 -0
- package/dist/components/toggle/toggle.js +58 -0
- package/dist/components/toggle-button/toggle-button.js +206 -0
- package/dist/components/tooltip/tooltip.js +10 -0
- package/dist/context-jMy6xdVq.js +98 -0
- package/dist/default-i18n-BhE-OUmt.js +873 -0
- package/dist/filterDOMProps-DG2RfOUr.js +30 -0
- package/dist/focusSafely-C3K8zAKj.js +743 -0
- package/dist/hooks/use-cell-edit-mode.js +35 -0
- package/dist/icons/block-icon.js +42 -0
- package/dist/icons/generic-color-swatch.js +21 -0
- package/dist/icons/icons.js +3636 -0
- package/dist/index-Bfb9bWcb.js +28844 -0
- package/dist/index-a301f526.esm-Bioi4cGX.js +3576 -0
- package/dist/index.js +109 -0
- package/dist/intlStrings-CUhoK9EN.js +2484 -0
- package/dist/isScrollable-PcyglExV.js +10 -0
- package/dist/modifiers.esm-BuJQPI1X.js +31 -0
- package/dist/multi-select-components-CjVpCNko.js +3677 -0
- package/dist/number-rWqELA8W.js +39 -0
- package/dist/popover-Dx3vKXUX.js +1061 -0
- package/dist/react-select-async.esm-TFb_ZX6C.js +111 -0
- package/dist/react-select.esm-BjRWqf0E.js +15 -0
- package/dist/style.js +1 -0
- package/dist/textSelection-BosCCRVE.js +89 -0
- package/dist/tooltip-CkCndvTI.js +1094 -0
- package/dist/useButton-CuG5UzUw.js +74 -0
- package/dist/useEvent-DHv-yhOH.js +24 -0
- package/dist/useFocusRing-Cc-4eouh.js +41 -0
- package/dist/useFocusable-5q1Gek1J.js +81 -0
- package/dist/useFormReset-Buc9YJcv.js +23 -0
- package/dist/useFormValidationState-BAPPNXic.js +238 -0
- package/dist/useHasTabbableChild-D3uUNhJ0.js +37 -0
- package/dist/useLabel-CGlkoFG0.js +28 -0
- package/dist/useLabels-Dg62M_3P.js +25 -0
- package/dist/useListData-BelKu4kx.js +211 -0
- package/dist/useListState-Domq0blV.js +137 -0
- package/dist/useLocalizedStringFormatter-Prmz0h0A.js +130 -0
- package/dist/useNumberFieldState-BLU3uhSR.js +1253 -0
- package/dist/useNumberFormatter-BLc2xjZn.js +13 -0
- package/dist/usePress-BQgVor4T.js +698 -0
- package/dist/useToggle-C9ETOBaZ.js +58 -0
- package/dist/useToggleState-DJ_z5E2S.js +21 -0
- package/dist/utilities/classnames.js +16 -0
- package/dist/utilities/text-helpers.js +79 -0
- package/dist/utils-BsiH7-5Y.js +488 -0
- package/package.json +71 -0
|
@@ -0,0 +1,937 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { $ as $d2b4bc8c273e7be6$export$24d547caef80ccd1, b as $d2b4bc8c273e7be6$export$353f5b6fc5456de1, c as $13c3c67164f4d5be$export$4c260019440d418f, B as Button } from "../../button-BkkdyHfJ.js";
|
|
3
|
+
import { $ as $a049562f99e7db0e$export$f9c6924e160136d1, a as $a049562f99e7db0e$export$eb2fcfdbd7ba97d4 } from "../../Group-DyqpTRPe.js";
|
|
4
|
+
import { b as $2d73ec29415bd339$export$712718f7aec83d5, $ as $3985021b0ad6602f$export$37fb8590cf2c088c, a as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../Input-jsbb4ugq.js";
|
|
5
|
+
import { a as $01b77f81d0f07f68$export$75b6ee27786ba447, $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-BPzS-sR7.js";
|
|
6
|
+
import { n as $ff5963eb1fccf552$export$e08e3b67e392101e, a as $64fa3d84918910a7$export$29f1550f4b0d4415, $ as $64fa3d84918910a7$export$fabf2dc03a41866e, h as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, i as $64fa3d84918910a7$export$ef03459518577ad4, c as $64fa3d84918910a7$export$4d86445c2cf5e3, j as $64fa3d84918910a7$export$2881499e37b75b9a } from "../../utils-BsiH7-5Y.js";
|
|
7
|
+
import { $ as $ee014567cb39d3f0$export$ff05c3ac10437e03 } from "../../FieldError-wtMA4667.js";
|
|
8
|
+
import { $ as $d3e0e05bdfcf66bd$export$c24727297075ec6a } from "../../Form-Cq3fu75_.js";
|
|
9
|
+
import { a as $514c0188e459b4c0$export$9afb8bc826b033ea } from "../../Text-BM136LvS.js";
|
|
10
|
+
import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-DG2RfOUr.js";
|
|
11
|
+
import React__default, { useReducer, useRef, useEffect, forwardRef, createContext, useMemo, useState, useCallback } from "react";
|
|
12
|
+
import { e as $458b0a5536c1a7cf$export$40bfa8c7b0832715 } from "../../focusSafely-C3K8zAKj.js";
|
|
13
|
+
import { $ as $fca6afa0e843324b$export$f12b703ca79dfbb1 } from "../../useLocalizedStringFormatter-Prmz0h0A.js";
|
|
14
|
+
import { _ as __ } from "../../default-i18n-BhE-OUmt.js";
|
|
15
|
+
import { icons } from "../../icons/icons.js";
|
|
16
|
+
import { classnames } from "../../utilities/classnames.js";
|
|
17
|
+
import { Spacer } from "../spacer/spacer.js";
|
|
18
|
+
import { T as Tooltip } from "../../tooltip-CkCndvTI.js";
|
|
19
|
+
import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
|
|
20
|
+
import { BaseControl } from "../base-control/base-control.js";
|
|
21
|
+
import { RichLabel } from "../rich-label/rich-label.js";
|
|
22
|
+
import { P as Popover } from "../../popover-Dx3vKXUX.js";
|
|
23
|
+
import { a as $0d86e9c8f07f9a7b$export$79c0c687a5963b0a } from "../../useListData-BelKu4kx.js";
|
|
24
|
+
var $03c9a1a10de12f06$exports = {};
|
|
25
|
+
$03c9a1a10de12f06$exports = {
|
|
26
|
+
"Clear search": `مسح البحث`
|
|
27
|
+
};
|
|
28
|
+
var $4da0c2ffa4ba4159$exports = {};
|
|
29
|
+
$4da0c2ffa4ba4159$exports = {
|
|
30
|
+
"Clear search": `Изчистване на търсене`
|
|
31
|
+
};
|
|
32
|
+
var $8c59fd0c2c96821b$exports = {};
|
|
33
|
+
$8c59fd0c2c96821b$exports = {
|
|
34
|
+
"Clear search": `Vymazat hledání`
|
|
35
|
+
};
|
|
36
|
+
var $0a371f9c1df8120f$exports = {};
|
|
37
|
+
$0a371f9c1df8120f$exports = {
|
|
38
|
+
"Clear search": `Ryd søgning`
|
|
39
|
+
};
|
|
40
|
+
var $67f4d0b0de9f8a52$exports = {};
|
|
41
|
+
$67f4d0b0de9f8a52$exports = {
|
|
42
|
+
"Clear search": `Suche zurücksetzen`
|
|
43
|
+
};
|
|
44
|
+
var $72a312d948f0214b$exports = {};
|
|
45
|
+
$72a312d948f0214b$exports = {
|
|
46
|
+
"Clear search": `Απαλοιφή αναζήτησης`
|
|
47
|
+
};
|
|
48
|
+
var $5012d21d933388c1$exports = {};
|
|
49
|
+
$5012d21d933388c1$exports = {
|
|
50
|
+
"Clear search": `Clear search`
|
|
51
|
+
};
|
|
52
|
+
var $0159854399308e2e$exports = {};
|
|
53
|
+
$0159854399308e2e$exports = {
|
|
54
|
+
"Clear search": `Borrar búsqueda`
|
|
55
|
+
};
|
|
56
|
+
var $390613981d970276$exports = {};
|
|
57
|
+
$390613981d970276$exports = {
|
|
58
|
+
"Clear search": `Tühjenda otsing`
|
|
59
|
+
};
|
|
60
|
+
var $961ae0833f811705$exports = {};
|
|
61
|
+
$961ae0833f811705$exports = {
|
|
62
|
+
"Clear search": `Tyhjennä haku`
|
|
63
|
+
};
|
|
64
|
+
var $26d76742decfd829$exports = {};
|
|
65
|
+
$26d76742decfd829$exports = {
|
|
66
|
+
"Clear search": `Effacer la recherche`
|
|
67
|
+
};
|
|
68
|
+
var $92ef254c82a5c769$exports = {};
|
|
69
|
+
$92ef254c82a5c769$exports = {
|
|
70
|
+
"Clear search": `נקה חיפוש`
|
|
71
|
+
};
|
|
72
|
+
var $e0321b43bdefb8b3$exports = {};
|
|
73
|
+
$e0321b43bdefb8b3$exports = {
|
|
74
|
+
"Clear search": `Obriši pretragu`
|
|
75
|
+
};
|
|
76
|
+
var $0c1ee0b8d50940d9$exports = {};
|
|
77
|
+
$0c1ee0b8d50940d9$exports = {
|
|
78
|
+
"Clear search": `Keresés törlése`
|
|
79
|
+
};
|
|
80
|
+
var $b09198915a38946f$exports = {};
|
|
81
|
+
$b09198915a38946f$exports = {
|
|
82
|
+
"Clear search": `Cancella ricerca`
|
|
83
|
+
};
|
|
84
|
+
var $3a9a3d180c3145c0$exports = {};
|
|
85
|
+
$3a9a3d180c3145c0$exports = {
|
|
86
|
+
"Clear search": `検索をクリア`
|
|
87
|
+
};
|
|
88
|
+
var $b7a611726449f4a3$exports = {};
|
|
89
|
+
$b7a611726449f4a3$exports = {
|
|
90
|
+
"Clear search": `검색 지우기`
|
|
91
|
+
};
|
|
92
|
+
var $d9a3d49db610dd5c$exports = {};
|
|
93
|
+
$d9a3d49db610dd5c$exports = {
|
|
94
|
+
"Clear search": `Išvalyti iešką`
|
|
95
|
+
};
|
|
96
|
+
var $3ab64b73ea27c23a$exports = {};
|
|
97
|
+
$3ab64b73ea27c23a$exports = {
|
|
98
|
+
"Clear search": `Notīrīt meklēšanu`
|
|
99
|
+
};
|
|
100
|
+
var $bf5cce1b47d23baf$exports = {};
|
|
101
|
+
$bf5cce1b47d23baf$exports = {
|
|
102
|
+
"Clear search": `Tøm søk`
|
|
103
|
+
};
|
|
104
|
+
var $4e0c9a9a010e4598$exports = {};
|
|
105
|
+
$4e0c9a9a010e4598$exports = {
|
|
106
|
+
"Clear search": `Zoekactie wissen`
|
|
107
|
+
};
|
|
108
|
+
var $63cf4a75ec270508$exports = {};
|
|
109
|
+
$63cf4a75ec270508$exports = {
|
|
110
|
+
"Clear search": `Wyczyść zawartość wyszukiwania`
|
|
111
|
+
};
|
|
112
|
+
var $083b0cad27fdbd06$exports = {};
|
|
113
|
+
$083b0cad27fdbd06$exports = {
|
|
114
|
+
"Clear search": `Limpar pesquisa`
|
|
115
|
+
};
|
|
116
|
+
var $1b7f0864d830ba6d$exports = {};
|
|
117
|
+
$1b7f0864d830ba6d$exports = {
|
|
118
|
+
"Clear search": `Limpar pesquisa`
|
|
119
|
+
};
|
|
120
|
+
var $d6d2588377fc9718$exports = {};
|
|
121
|
+
$d6d2588377fc9718$exports = {
|
|
122
|
+
"Clear search": `Ştergeţi căutarea`
|
|
123
|
+
};
|
|
124
|
+
var $701c918a4653e946$exports = {};
|
|
125
|
+
$701c918a4653e946$exports = {
|
|
126
|
+
"Clear search": `Очистить поиск`
|
|
127
|
+
};
|
|
128
|
+
var $7cacc29a1e5f4fbe$exports = {};
|
|
129
|
+
$7cacc29a1e5f4fbe$exports = {
|
|
130
|
+
"Clear search": `Vymazať vyhľadávanie`
|
|
131
|
+
};
|
|
132
|
+
var $c63231bcc300d0df$exports = {};
|
|
133
|
+
$c63231bcc300d0df$exports = {
|
|
134
|
+
"Clear search": `Počisti iskanje`
|
|
135
|
+
};
|
|
136
|
+
var $b61510478bc0e6f6$exports = {};
|
|
137
|
+
$b61510478bc0e6f6$exports = {
|
|
138
|
+
"Clear search": `Obriši pretragu`
|
|
139
|
+
};
|
|
140
|
+
var $ce325e6dd3f9c37a$exports = {};
|
|
141
|
+
$ce325e6dd3f9c37a$exports = {
|
|
142
|
+
"Clear search": `Rensa sökning`
|
|
143
|
+
};
|
|
144
|
+
var $1f7e1cf2285af2b2$exports = {};
|
|
145
|
+
$1f7e1cf2285af2b2$exports = {
|
|
146
|
+
"Clear search": `Aramayı temizle`
|
|
147
|
+
};
|
|
148
|
+
var $2d999353ca652e34$exports = {};
|
|
149
|
+
$2d999353ca652e34$exports = {
|
|
150
|
+
"Clear search": `Очистити пошук`
|
|
151
|
+
};
|
|
152
|
+
var $117b536bfb1ae554$exports = {};
|
|
153
|
+
$117b536bfb1ae554$exports = {
|
|
154
|
+
"Clear search": `清除搜索`
|
|
155
|
+
};
|
|
156
|
+
var $525f6fa4ac26e278$exports = {};
|
|
157
|
+
$525f6fa4ac26e278$exports = {
|
|
158
|
+
"Clear search": `清除搜尋條件`
|
|
159
|
+
};
|
|
160
|
+
var $8112f8b883c0272d$exports = {};
|
|
161
|
+
$8112f8b883c0272d$exports = {
|
|
162
|
+
"ar-AE": $03c9a1a10de12f06$exports,
|
|
163
|
+
"bg-BG": $4da0c2ffa4ba4159$exports,
|
|
164
|
+
"cs-CZ": $8c59fd0c2c96821b$exports,
|
|
165
|
+
"da-DK": $0a371f9c1df8120f$exports,
|
|
166
|
+
"de-DE": $67f4d0b0de9f8a52$exports,
|
|
167
|
+
"el-GR": $72a312d948f0214b$exports,
|
|
168
|
+
"en-US": $5012d21d933388c1$exports,
|
|
169
|
+
"es-ES": $0159854399308e2e$exports,
|
|
170
|
+
"et-EE": $390613981d970276$exports,
|
|
171
|
+
"fi-FI": $961ae0833f811705$exports,
|
|
172
|
+
"fr-FR": $26d76742decfd829$exports,
|
|
173
|
+
"he-IL": $92ef254c82a5c769$exports,
|
|
174
|
+
"hr-HR": $e0321b43bdefb8b3$exports,
|
|
175
|
+
"hu-HU": $0c1ee0b8d50940d9$exports,
|
|
176
|
+
"it-IT": $b09198915a38946f$exports,
|
|
177
|
+
"ja-JP": $3a9a3d180c3145c0$exports,
|
|
178
|
+
"ko-KR": $b7a611726449f4a3$exports,
|
|
179
|
+
"lt-LT": $d9a3d49db610dd5c$exports,
|
|
180
|
+
"lv-LV": $3ab64b73ea27c23a$exports,
|
|
181
|
+
"nb-NO": $bf5cce1b47d23baf$exports,
|
|
182
|
+
"nl-NL": $4e0c9a9a010e4598$exports,
|
|
183
|
+
"pl-PL": $63cf4a75ec270508$exports,
|
|
184
|
+
"pt-BR": $083b0cad27fdbd06$exports,
|
|
185
|
+
"pt-PT": $1b7f0864d830ba6d$exports,
|
|
186
|
+
"ro-RO": $d6d2588377fc9718$exports,
|
|
187
|
+
"ru-RU": $701c918a4653e946$exports,
|
|
188
|
+
"sk-SK": $7cacc29a1e5f4fbe$exports,
|
|
189
|
+
"sl-SI": $c63231bcc300d0df$exports,
|
|
190
|
+
"sr-SP": $b61510478bc0e6f6$exports,
|
|
191
|
+
"sv-SE": $ce325e6dd3f9c37a$exports,
|
|
192
|
+
"tr-TR": $1f7e1cf2285af2b2$exports,
|
|
193
|
+
"uk-UA": $2d999353ca652e34$exports,
|
|
194
|
+
"zh-CN": $117b536bfb1ae554$exports,
|
|
195
|
+
"zh-TW": $525f6fa4ac26e278$exports
|
|
196
|
+
};
|
|
197
|
+
function $parcel$interopDefault(a) {
|
|
198
|
+
return a && a.__esModule ? a.default : a;
|
|
199
|
+
}
|
|
200
|
+
function $4d52238874b24f86$export$9bb30bbe003b82e0(props, state, inputRef) {
|
|
201
|
+
let stringFormatter = $fca6afa0e843324b$export$f12b703ca79dfbb1($parcel$interopDefault($8112f8b883c0272d$exports), "@react-aria/searchfield");
|
|
202
|
+
let { isDisabled, isReadOnly, onSubmit = () => {
|
|
203
|
+
}, onClear, type = "search" } = props;
|
|
204
|
+
let onKeyDown = (e) => {
|
|
205
|
+
const key = e.key;
|
|
206
|
+
if (key === "Enter")
|
|
207
|
+
e.preventDefault();
|
|
208
|
+
if (isDisabled || isReadOnly)
|
|
209
|
+
return;
|
|
210
|
+
if (key === "Enter")
|
|
211
|
+
onSubmit(state.value);
|
|
212
|
+
if (key === "Escape") {
|
|
213
|
+
if (state.value === "")
|
|
214
|
+
e.continuePropagation();
|
|
215
|
+
else {
|
|
216
|
+
state.setValue("");
|
|
217
|
+
if (onClear)
|
|
218
|
+
onClear();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
let onClearButtonClick = () => {
|
|
223
|
+
state.setValue("");
|
|
224
|
+
if (onClear)
|
|
225
|
+
onClear();
|
|
226
|
+
};
|
|
227
|
+
let onPressStart = () => {
|
|
228
|
+
var _inputRef_current;
|
|
229
|
+
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
|
|
230
|
+
};
|
|
231
|
+
let { labelProps, inputProps, descriptionProps, errorMessageProps, ...validation } = $2d73ec29415bd339$export$712718f7aec83d5({
|
|
232
|
+
...props,
|
|
233
|
+
value: state.value,
|
|
234
|
+
onChange: state.setValue,
|
|
235
|
+
onKeyDown: !isReadOnly ? $ff5963eb1fccf552$export$e08e3b67e392101e(onKeyDown, props.onKeyDown) : props.onKeyDown,
|
|
236
|
+
type
|
|
237
|
+
}, inputRef);
|
|
238
|
+
return {
|
|
239
|
+
labelProps,
|
|
240
|
+
inputProps: {
|
|
241
|
+
...inputProps,
|
|
242
|
+
// already handled by useSearchFieldState
|
|
243
|
+
defaultValue: void 0
|
|
244
|
+
},
|
|
245
|
+
clearButtonProps: {
|
|
246
|
+
"aria-label": stringFormatter.format("Clear search"),
|
|
247
|
+
excludeFromTabOrder: true,
|
|
248
|
+
// @ts-ignore
|
|
249
|
+
preventFocusOnPress: true,
|
|
250
|
+
isDisabled: isDisabled || isReadOnly,
|
|
251
|
+
onPress: onClearButtonClick,
|
|
252
|
+
onPressStart
|
|
253
|
+
},
|
|
254
|
+
descriptionProps,
|
|
255
|
+
errorMessageProps,
|
|
256
|
+
...validation
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function $f86e6c1ec7da6ebb$var$reducer(data, action) {
|
|
260
|
+
let selectedKeys;
|
|
261
|
+
switch (data.state) {
|
|
262
|
+
case "idle":
|
|
263
|
+
case "error":
|
|
264
|
+
switch (action.type) {
|
|
265
|
+
case "loading":
|
|
266
|
+
case "loadingMore":
|
|
267
|
+
case "sorting":
|
|
268
|
+
case "filtering":
|
|
269
|
+
var _action_filterText, _action_sortDescriptor;
|
|
270
|
+
return {
|
|
271
|
+
...data,
|
|
272
|
+
filterText: (_action_filterText = action.filterText) !== null && _action_filterText !== void 0 ? _action_filterText : data.filterText,
|
|
273
|
+
state: action.type,
|
|
274
|
+
// Reset items to an empty list if loading, but not when sorting.
|
|
275
|
+
items: action.type === "loading" ? [] : data.items,
|
|
276
|
+
sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
|
|
277
|
+
abortController: action.abortController
|
|
278
|
+
};
|
|
279
|
+
case "update":
|
|
280
|
+
return {
|
|
281
|
+
...data,
|
|
282
|
+
...action.updater(data)
|
|
283
|
+
};
|
|
284
|
+
case "success":
|
|
285
|
+
case "error":
|
|
286
|
+
return data;
|
|
287
|
+
default:
|
|
288
|
+
throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
|
|
289
|
+
}
|
|
290
|
+
case "loading":
|
|
291
|
+
case "sorting":
|
|
292
|
+
case "filtering":
|
|
293
|
+
switch (action.type) {
|
|
294
|
+
case "success":
|
|
295
|
+
if (action.abortController !== data.abortController)
|
|
296
|
+
return data;
|
|
297
|
+
var _action_selectedKeys;
|
|
298
|
+
selectedKeys = (_action_selectedKeys = action.selectedKeys) !== null && _action_selectedKeys !== void 0 ? _action_selectedKeys : data.selectedKeys;
|
|
299
|
+
var _action_filterText1, _action_sortDescriptor1;
|
|
300
|
+
return {
|
|
301
|
+
...data,
|
|
302
|
+
filterText: (_action_filterText1 = action.filterText) !== null && _action_filterText1 !== void 0 ? _action_filterText1 : data.filterText,
|
|
303
|
+
state: "idle",
|
|
304
|
+
items: [
|
|
305
|
+
...action.items
|
|
306
|
+
],
|
|
307
|
+
selectedKeys: selectedKeys === "all" ? "all" : new Set(selectedKeys),
|
|
308
|
+
sortDescriptor: (_action_sortDescriptor1 = action.sortDescriptor) !== null && _action_sortDescriptor1 !== void 0 ? _action_sortDescriptor1 : data.sortDescriptor,
|
|
309
|
+
abortController: null,
|
|
310
|
+
cursor: action.cursor
|
|
311
|
+
};
|
|
312
|
+
case "error":
|
|
313
|
+
if (action.abortController !== data.abortController)
|
|
314
|
+
return data;
|
|
315
|
+
return {
|
|
316
|
+
...data,
|
|
317
|
+
state: "error",
|
|
318
|
+
error: action.error,
|
|
319
|
+
abortController: null
|
|
320
|
+
};
|
|
321
|
+
case "loading":
|
|
322
|
+
case "loadingMore":
|
|
323
|
+
case "sorting":
|
|
324
|
+
case "filtering":
|
|
325
|
+
data.abortController.abort();
|
|
326
|
+
var _action_filterText2;
|
|
327
|
+
return {
|
|
328
|
+
...data,
|
|
329
|
+
filterText: (_action_filterText2 = action.filterText) !== null && _action_filterText2 !== void 0 ? _action_filterText2 : data.filterText,
|
|
330
|
+
state: action.type,
|
|
331
|
+
// Reset items to an empty list if loading, but not when sorting.
|
|
332
|
+
items: action.type === "loading" ? [] : data.items,
|
|
333
|
+
abortController: action.abortController
|
|
334
|
+
};
|
|
335
|
+
case "update":
|
|
336
|
+
return {
|
|
337
|
+
...data,
|
|
338
|
+
...action.updater(data)
|
|
339
|
+
};
|
|
340
|
+
default:
|
|
341
|
+
throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
|
|
342
|
+
}
|
|
343
|
+
case "loadingMore":
|
|
344
|
+
switch (action.type) {
|
|
345
|
+
case "success":
|
|
346
|
+
var _action_selectedKeys1;
|
|
347
|
+
selectedKeys = data.selectedKeys === "all" || action.selectedKeys === "all" ? "all" : /* @__PURE__ */ new Set([
|
|
348
|
+
...data.selectedKeys,
|
|
349
|
+
...(_action_selectedKeys1 = action.selectedKeys) !== null && _action_selectedKeys1 !== void 0 ? _action_selectedKeys1 : []
|
|
350
|
+
]);
|
|
351
|
+
var _action_sortDescriptor2;
|
|
352
|
+
return {
|
|
353
|
+
...data,
|
|
354
|
+
state: "idle",
|
|
355
|
+
items: [
|
|
356
|
+
...data.items,
|
|
357
|
+
...action.items
|
|
358
|
+
],
|
|
359
|
+
selectedKeys,
|
|
360
|
+
sortDescriptor: (_action_sortDescriptor2 = action.sortDescriptor) !== null && _action_sortDescriptor2 !== void 0 ? _action_sortDescriptor2 : data.sortDescriptor,
|
|
361
|
+
abortController: null,
|
|
362
|
+
cursor: action.cursor
|
|
363
|
+
};
|
|
364
|
+
case "error":
|
|
365
|
+
if (action.abortController !== data.abortController)
|
|
366
|
+
return data;
|
|
367
|
+
return {
|
|
368
|
+
...data,
|
|
369
|
+
state: "error",
|
|
370
|
+
error: action.error
|
|
371
|
+
};
|
|
372
|
+
case "loading":
|
|
373
|
+
case "sorting":
|
|
374
|
+
case "filtering":
|
|
375
|
+
data.abortController.abort();
|
|
376
|
+
var _action_filterText3;
|
|
377
|
+
return {
|
|
378
|
+
...data,
|
|
379
|
+
filterText: (_action_filterText3 = action.filterText) !== null && _action_filterText3 !== void 0 ? _action_filterText3 : data.filterText,
|
|
380
|
+
state: action.type,
|
|
381
|
+
// Reset items to an empty list if loading, but not when sorting.
|
|
382
|
+
items: action.type === "loading" ? [] : data.items,
|
|
383
|
+
abortController: action.abortController
|
|
384
|
+
};
|
|
385
|
+
case "loadingMore":
|
|
386
|
+
action.abortController.abort();
|
|
387
|
+
return data;
|
|
388
|
+
case "update":
|
|
389
|
+
return {
|
|
390
|
+
...data,
|
|
391
|
+
...action.updater(data)
|
|
392
|
+
};
|
|
393
|
+
default:
|
|
394
|
+
throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
|
|
395
|
+
}
|
|
396
|
+
default:
|
|
397
|
+
throw new Error(`Invalid state "${data.state}"`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
|
|
401
|
+
const { load, sort, initialSelectedKeys, initialSortDescriptor, getKey = (item) => item.id || item.key, initialFilterText = "" } = options;
|
|
402
|
+
let [data, dispatch] = useReducer($f86e6c1ec7da6ebb$var$reducer, {
|
|
403
|
+
state: "idle",
|
|
404
|
+
error: null,
|
|
405
|
+
items: [],
|
|
406
|
+
selectedKeys: initialSelectedKeys === "all" ? "all" : new Set(initialSelectedKeys),
|
|
407
|
+
sortDescriptor: initialSortDescriptor,
|
|
408
|
+
filterText: initialFilterText
|
|
409
|
+
});
|
|
410
|
+
const dispatchFetch = async (action, fn) => {
|
|
411
|
+
let abortController = new AbortController();
|
|
412
|
+
try {
|
|
413
|
+
dispatch({
|
|
414
|
+
...action,
|
|
415
|
+
abortController
|
|
416
|
+
});
|
|
417
|
+
var _action_filterText;
|
|
418
|
+
let previousFilterText = (_action_filterText = action.filterText) !== null && _action_filterText !== void 0 ? _action_filterText : data.filterText;
|
|
419
|
+
var _action_sortDescriptor;
|
|
420
|
+
let response = await fn({
|
|
421
|
+
items: data.items.slice(),
|
|
422
|
+
selectedKeys: data.selectedKeys,
|
|
423
|
+
sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
|
|
424
|
+
signal: abortController.signal,
|
|
425
|
+
cursor: action.type === "loadingMore" ? data.cursor : null,
|
|
426
|
+
filterText: previousFilterText
|
|
427
|
+
});
|
|
428
|
+
var _response_filterText;
|
|
429
|
+
let filterText = (_response_filterText = response.filterText) !== null && _response_filterText !== void 0 ? _response_filterText : previousFilterText;
|
|
430
|
+
dispatch({
|
|
431
|
+
type: "success",
|
|
432
|
+
...response,
|
|
433
|
+
abortController
|
|
434
|
+
});
|
|
435
|
+
if (filterText && filterText !== previousFilterText && !abortController.signal.aborted)
|
|
436
|
+
dispatchFetch({
|
|
437
|
+
type: "filtering",
|
|
438
|
+
filterText
|
|
439
|
+
}, load);
|
|
440
|
+
} catch (e) {
|
|
441
|
+
dispatch({
|
|
442
|
+
type: "error",
|
|
443
|
+
error: e,
|
|
444
|
+
abortController
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
let didDispatchInitialFetch = useRef(false);
|
|
449
|
+
useEffect(() => {
|
|
450
|
+
if (!didDispatchInitialFetch.current) {
|
|
451
|
+
dispatchFetch({
|
|
452
|
+
type: "loading"
|
|
453
|
+
}, load);
|
|
454
|
+
didDispatchInitialFetch.current = true;
|
|
455
|
+
}
|
|
456
|
+
}, []);
|
|
457
|
+
return {
|
|
458
|
+
items: data.items,
|
|
459
|
+
selectedKeys: data.selectedKeys,
|
|
460
|
+
sortDescriptor: data.sortDescriptor,
|
|
461
|
+
isLoading: data.state === "loading" || data.state === "loadingMore" || data.state === "sorting" || data.state === "filtering",
|
|
462
|
+
loadingState: data.state,
|
|
463
|
+
error: data.error,
|
|
464
|
+
filterText: data.filterText,
|
|
465
|
+
getItem(key) {
|
|
466
|
+
return data.items.find((item) => getKey(item) === key);
|
|
467
|
+
},
|
|
468
|
+
reload() {
|
|
469
|
+
dispatchFetch({
|
|
470
|
+
type: "loading"
|
|
471
|
+
}, load);
|
|
472
|
+
},
|
|
473
|
+
loadMore() {
|
|
474
|
+
if (data.state === "loadingMore" || data.state === "filtering" || data.cursor == null)
|
|
475
|
+
return;
|
|
476
|
+
dispatchFetch({
|
|
477
|
+
type: "loadingMore"
|
|
478
|
+
}, load);
|
|
479
|
+
},
|
|
480
|
+
sort(sortDescriptor) {
|
|
481
|
+
dispatchFetch({
|
|
482
|
+
type: "sorting",
|
|
483
|
+
sortDescriptor
|
|
484
|
+
}, sort || load);
|
|
485
|
+
},
|
|
486
|
+
...$0d86e9c8f07f9a7b$export$79c0c687a5963b0a({
|
|
487
|
+
...options,
|
|
488
|
+
getKey,
|
|
489
|
+
cursor: data.cursor
|
|
490
|
+
}, (fn) => {
|
|
491
|
+
dispatch({
|
|
492
|
+
type: "update",
|
|
493
|
+
updater: fn
|
|
494
|
+
});
|
|
495
|
+
}),
|
|
496
|
+
setFilterText(filterText) {
|
|
497
|
+
dispatchFetch({
|
|
498
|
+
type: "filtering",
|
|
499
|
+
filterText
|
|
500
|
+
}, load);
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
function $0b2218c4e3fe7d7e$export$3f8be18b0f41eaf2(props) {
|
|
505
|
+
let [value, setValue] = $458b0a5536c1a7cf$export$40bfa8c7b0832715($0b2218c4e3fe7d7e$var$toString(props.value), $0b2218c4e3fe7d7e$var$toString(props.defaultValue) || "", props.onChange);
|
|
506
|
+
return {
|
|
507
|
+
value,
|
|
508
|
+
setValue
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
function $0b2218c4e3fe7d7e$var$toString(val) {
|
|
512
|
+
if (val == null)
|
|
513
|
+
return;
|
|
514
|
+
return val.toString();
|
|
515
|
+
}
|
|
516
|
+
const $440f4836bcb56932$export$d1c4e4c63cb03a11 = /* @__PURE__ */ createContext(null);
|
|
517
|
+
function $440f4836bcb56932$var$SearchField(props, ref) {
|
|
518
|
+
[props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $440f4836bcb56932$export$d1c4e4c63cb03a11);
|
|
519
|
+
let { validationBehavior: formValidationBehavior } = $64fa3d84918910a7$export$fabf2dc03a41866e($d3e0e05bdfcf66bd$export$c24727297075ec6a) || {};
|
|
520
|
+
var _props_validationBehavior, _ref;
|
|
521
|
+
let validationBehavior = (_ref = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : formValidationBehavior) !== null && _ref !== void 0 ? _ref : "native";
|
|
522
|
+
let inputRef = useRef(null);
|
|
523
|
+
let [labelRef, label] = $64fa3d84918910a7$export$9d4c57ee4c6ffdd8();
|
|
524
|
+
let state = $0b2218c4e3fe7d7e$export$3f8be18b0f41eaf2({
|
|
525
|
+
...props,
|
|
526
|
+
validationBehavior
|
|
527
|
+
});
|
|
528
|
+
let { labelProps, inputProps, clearButtonProps, descriptionProps, errorMessageProps, ...validation } = $4d52238874b24f86$export$9bb30bbe003b82e0({
|
|
529
|
+
...$64fa3d84918910a7$export$ef03459518577ad4(props),
|
|
530
|
+
label,
|
|
531
|
+
validationBehavior
|
|
532
|
+
}, state, inputRef);
|
|
533
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
534
|
+
...props,
|
|
535
|
+
values: {
|
|
536
|
+
isEmpty: state.value === "",
|
|
537
|
+
isDisabled: props.isDisabled || false,
|
|
538
|
+
isInvalid: validation.isInvalid || false,
|
|
539
|
+
state
|
|
540
|
+
},
|
|
541
|
+
defaultClassName: "react-aria-SearchField"
|
|
542
|
+
});
|
|
543
|
+
let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
|
|
544
|
+
delete DOMProps.id;
|
|
545
|
+
return /* @__PURE__ */ React__default.createElement("div", {
|
|
546
|
+
...DOMProps,
|
|
547
|
+
...renderProps,
|
|
548
|
+
ref,
|
|
549
|
+
slot: props.slot || void 0,
|
|
550
|
+
"data-empty": state.value === "" || void 0,
|
|
551
|
+
"data-disabled": props.isDisabled || void 0,
|
|
552
|
+
"data-invalid": validation.isInvalid || void 0
|
|
553
|
+
}, /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
|
|
554
|
+
values: [
|
|
555
|
+
[
|
|
556
|
+
$01b77f81d0f07f68$export$75b6ee27786ba447,
|
|
557
|
+
{
|
|
558
|
+
...labelProps,
|
|
559
|
+
ref: labelRef
|
|
560
|
+
}
|
|
561
|
+
],
|
|
562
|
+
[
|
|
563
|
+
$3985021b0ad6602f$export$37fb8590cf2c088c,
|
|
564
|
+
{
|
|
565
|
+
...inputProps,
|
|
566
|
+
ref: inputRef
|
|
567
|
+
}
|
|
568
|
+
],
|
|
569
|
+
[
|
|
570
|
+
$d2b4bc8c273e7be6$export$24d547caef80ccd1,
|
|
571
|
+
clearButtonProps
|
|
572
|
+
],
|
|
573
|
+
[
|
|
574
|
+
$514c0188e459b4c0$export$9afb8bc826b033ea,
|
|
575
|
+
{
|
|
576
|
+
slots: {
|
|
577
|
+
description: descriptionProps,
|
|
578
|
+
errorMessage: errorMessageProps
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
],
|
|
582
|
+
[
|
|
583
|
+
$a049562f99e7db0e$export$f9c6924e160136d1,
|
|
584
|
+
{
|
|
585
|
+
isInvalid: validation.isInvalid,
|
|
586
|
+
isDisabled: props.isDisabled || false
|
|
587
|
+
}
|
|
588
|
+
],
|
|
589
|
+
[
|
|
590
|
+
$ee014567cb39d3f0$export$ff05c3ac10437e03,
|
|
591
|
+
validation
|
|
592
|
+
]
|
|
593
|
+
]
|
|
594
|
+
}, renderProps.children));
|
|
595
|
+
}
|
|
596
|
+
const $440f4836bcb56932$export$b94867ecbd698f21 = /* @__PURE__ */ forwardRef($440f4836bcb56932$var$SearchField);
|
|
597
|
+
function c(e, u, c2) {
|
|
598
|
+
var i = this, a = useRef(null), o = useRef(0), f = useRef(null), l = useRef([]), v = useRef(), m = useRef(), d = useRef(e), g = useRef(true);
|
|
599
|
+
d.current = e;
|
|
600
|
+
var p = "undefined" != typeof window, w = !u && 0 !== u && p;
|
|
601
|
+
if ("function" != typeof e)
|
|
602
|
+
throw new TypeError("Expected a function");
|
|
603
|
+
u = +u || 0;
|
|
604
|
+
var s = !!(c2 = c2 || {}).leading, x = !("trailing" in c2) || !!c2.trailing, h = "maxWait" in c2, y = "debounceOnServer" in c2 && !!c2.debounceOnServer, F = h ? Math.max(+c2.maxWait || 0, u) : null;
|
|
605
|
+
useEffect(function() {
|
|
606
|
+
return g.current = true, function() {
|
|
607
|
+
g.current = false;
|
|
608
|
+
};
|
|
609
|
+
}, []);
|
|
610
|
+
var A = useMemo(function() {
|
|
611
|
+
var r = function(r2) {
|
|
612
|
+
var n2 = l.current, t2 = v.current;
|
|
613
|
+
return l.current = v.current = null, o.current = r2, m.current = d.current.apply(t2, n2);
|
|
614
|
+
}, n = function(r2, n2) {
|
|
615
|
+
w && cancelAnimationFrame(f.current), f.current = w ? requestAnimationFrame(r2) : setTimeout(r2, n2);
|
|
616
|
+
}, t = function(r2) {
|
|
617
|
+
if (!g.current)
|
|
618
|
+
return false;
|
|
619
|
+
var n2 = r2 - a.current;
|
|
620
|
+
return !a.current || n2 >= u || n2 < 0 || h && r2 - o.current >= F;
|
|
621
|
+
}, e2 = function(n2) {
|
|
622
|
+
return f.current = null, x && l.current ? r(n2) : (l.current = v.current = null, m.current);
|
|
623
|
+
}, c3 = function r2() {
|
|
624
|
+
var c4 = Date.now();
|
|
625
|
+
if (t(c4))
|
|
626
|
+
return e2(c4);
|
|
627
|
+
if (g.current) {
|
|
628
|
+
var i2 = u - (c4 - a.current), f2 = h ? Math.min(i2, F - (c4 - o.current)) : i2;
|
|
629
|
+
n(r2, f2);
|
|
630
|
+
}
|
|
631
|
+
}, A2 = function() {
|
|
632
|
+
if (p || y) {
|
|
633
|
+
var e3 = Date.now(), d2 = t(e3);
|
|
634
|
+
if (l.current = [].slice.call(arguments), v.current = i, a.current = e3, d2) {
|
|
635
|
+
if (!f.current && g.current)
|
|
636
|
+
return o.current = a.current, n(c3, u), s ? r(a.current) : m.current;
|
|
637
|
+
if (h)
|
|
638
|
+
return n(c3, u), r(a.current);
|
|
639
|
+
}
|
|
640
|
+
return f.current || n(c3, u), m.current;
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
return A2.cancel = function() {
|
|
644
|
+
f.current && (w ? cancelAnimationFrame(f.current) : clearTimeout(f.current)), o.current = 0, l.current = a.current = v.current = f.current = null;
|
|
645
|
+
}, A2.isPending = function() {
|
|
646
|
+
return !!f.current;
|
|
647
|
+
}, A2.flush = function() {
|
|
648
|
+
return f.current ? e2(Date.now()) : m.current;
|
|
649
|
+
}, A2;
|
|
650
|
+
}, [s, h, u, F, x, w, p, y]);
|
|
651
|
+
return A;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Component that allows URL selection, with a suggestionList of suggestions and type-to-search.
|
|
655
|
+
*
|
|
656
|
+
* @component
|
|
657
|
+
* @param {Object} props - Component props.
|
|
658
|
+
* @param {string} [props.url] - The current URL.
|
|
659
|
+
* @param {Function} [props.onChange] - Function to run when the URL changes.
|
|
660
|
+
* @param {string} [props.label] - Label to display.
|
|
661
|
+
* @param {string} [props.subtitle] - Subtitle to display.
|
|
662
|
+
* @param {string} [props.help] - Help text to display below the input.
|
|
663
|
+
* @param {string} [props.placeholder] - Placeholder to show in the input field.
|
|
664
|
+
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display to the right of the label.
|
|
665
|
+
* @param {JSX.Element} [props.icon=icons.globe] - Icon to display in the label.
|
|
666
|
+
* @param {JSX.Element} [props.removeIcon=icons.clearAlt] - Icon to display in the input's clear button.
|
|
667
|
+
* @param {boolean} [props.disabled=false] - If `true`, the input is disabled.
|
|
668
|
+
* @param {Function} [props.suggestionTypeIconOverride] - Function
|
|
669
|
+
* @param {Function} [props.fetchSuggestions] - A function that fetches suggestions based on the input value.
|
|
670
|
+
* @param {string} [props.className] - Classes to pass to the input field.
|
|
671
|
+
* @param {number} [props.inputDebounceDelay=500] - The delay in milliseconds before the input value is considered final.
|
|
672
|
+
* @param {Function} [props.suggestionTypeIconOverride] - Allows overriding the default icon for the suggestion type, e.g. when using CPTs. Should be in the format: `(type) => icon or React component`.
|
|
673
|
+
*
|
|
674
|
+
* @returns {JSX.Element} The LinkInput component.
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* <LinkInput
|
|
678
|
+
* url={url}
|
|
679
|
+
* onChange={setUrl}
|
|
680
|
+
* />
|
|
681
|
+
*
|
|
682
|
+
* @preserve
|
|
683
|
+
*/
|
|
684
|
+
const LinkInput = (props) => {
|
|
685
|
+
var _a;
|
|
686
|
+
const {
|
|
687
|
+
url,
|
|
688
|
+
onChange,
|
|
689
|
+
label = __("Link", "eightshift-ui-components"),
|
|
690
|
+
subtitle,
|
|
691
|
+
help,
|
|
692
|
+
actions,
|
|
693
|
+
placeholder = __("Type to search or enter URL", "eightshift-ui-components"),
|
|
694
|
+
icon = icons.globe,
|
|
695
|
+
removeIcon = icons.clearAlt,
|
|
696
|
+
disabled = false,
|
|
697
|
+
suggestionTypeIconOverride,
|
|
698
|
+
fetchSuggestions,
|
|
699
|
+
className,
|
|
700
|
+
inputDebounceDelay = 500
|
|
701
|
+
} = props;
|
|
702
|
+
const [inputValue, setInputValue] = useState(url ?? "");
|
|
703
|
+
const [suggestionsVisible, setSuggestionsVisible] = useState(false);
|
|
704
|
+
const triggerRef = useRef(null);
|
|
705
|
+
const inputRef = useRef(null);
|
|
706
|
+
const suggestionList = $f86e6c1ec7da6ebb$export$bc3384a35de93d66({
|
|
707
|
+
getKey: ({ item }) => item.value,
|
|
708
|
+
async load({ signal }) {
|
|
709
|
+
const items = await fetchSuggestions(inputValue, signal);
|
|
710
|
+
return {
|
|
711
|
+
items: items ?? []
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
const shouldNotShowSuggestions = (url2) => {
|
|
716
|
+
var _a2;
|
|
717
|
+
if (!url2) {
|
|
718
|
+
return true;
|
|
719
|
+
}
|
|
720
|
+
return ((_a2 = url2 == null ? void 0 : url2.trim()) == null ? void 0 : _a2.length) < 3 || (url2 == null ? void 0 : url2.startsWith("#")) || (url2 == null ? void 0 : url2.startsWith(":")) || (url2 == null ? void 0 : url2.startsWith("mailto:")) || (url2 == null ? void 0 : url2.startsWith("tel:")) || (url2 == null ? void 0 : url2.startsWith("http://")) || (url2 == null ? void 0 : url2.startsWith("https://"));
|
|
721
|
+
};
|
|
722
|
+
const debounced = c(
|
|
723
|
+
useCallback(
|
|
724
|
+
(value) => {
|
|
725
|
+
onChange({ url: value, isAnchor: value == null ? void 0 : value.includes("#") });
|
|
726
|
+
if (shouldNotShowSuggestions(value)) {
|
|
727
|
+
setSuggestionsVisible(false);
|
|
728
|
+
} else {
|
|
729
|
+
suggestionList.setFilterText(value);
|
|
730
|
+
setSuggestionsVisible((value == null ? void 0 : value.length) > 3);
|
|
731
|
+
}
|
|
732
|
+
},
|
|
733
|
+
[onChange, suggestionList]
|
|
734
|
+
),
|
|
735
|
+
inputDebounceDelay,
|
|
736
|
+
{ maxWait: 2e3 }
|
|
737
|
+
);
|
|
738
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
739
|
+
/* @__PURE__ */ jsx(
|
|
740
|
+
$440f4836bcb56932$export$b94867ecbd698f21,
|
|
741
|
+
{
|
|
742
|
+
className: "es-uic-w-full es-uic-space-y-1",
|
|
743
|
+
type: "url",
|
|
744
|
+
value: inputValue,
|
|
745
|
+
onChange: (value) => {
|
|
746
|
+
setInputValue(value);
|
|
747
|
+
debounced(value);
|
|
748
|
+
},
|
|
749
|
+
isDisabled: disabled,
|
|
750
|
+
children: /* @__PURE__ */ jsx(
|
|
751
|
+
BaseControl,
|
|
752
|
+
{
|
|
753
|
+
as: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
754
|
+
icon,
|
|
755
|
+
label,
|
|
756
|
+
subtitle,
|
|
757
|
+
actions,
|
|
758
|
+
labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
759
|
+
help,
|
|
760
|
+
children: /* @__PURE__ */ jsxs(
|
|
761
|
+
$a049562f99e7db0e$export$eb2fcfdbd7ba97d4,
|
|
762
|
+
{
|
|
763
|
+
className: "es-uic-relative",
|
|
764
|
+
ref: triggerRef,
|
|
765
|
+
children: [
|
|
766
|
+
/* @__PURE__ */ jsx(
|
|
767
|
+
$3985021b0ad6602f$export$f5b8910cec6cf069,
|
|
768
|
+
{
|
|
769
|
+
placeholder,
|
|
770
|
+
ref: inputRef,
|
|
771
|
+
className: classnames(
|
|
772
|
+
"es-uic-min-h-10 es-uic-w-full es-uic-rounded-md es-uic-border es-uic-border-gray-300 es-uic-py-2 es-uic-pl-2 es-uic-pr-1 es-uic-text-sm es-uic-shadow-sm es-uic-transition selection:es-uic-bg-teal-500/20 selection:es-uic-text-teal-950",
|
|
773
|
+
"focus:es-uic-outline-none focus-visible:es-uic-outline-none focus-visible:es-uic-ring focus-visible:es-uic-ring-teal-500 focus-visible:es-uic-ring-opacity-50",
|
|
774
|
+
(inputValue == null ? void 0 : inputValue.length) > 0 && "es-uic-pr-8",
|
|
775
|
+
className
|
|
776
|
+
),
|
|
777
|
+
onFocus: (e) => {
|
|
778
|
+
onChange({ url: inputValue, isAnchor: inputValue == null ? void 0 : inputValue.includes("#") });
|
|
779
|
+
if (props.onFocus) {
|
|
780
|
+
props.onFocus(e);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
),
|
|
785
|
+
/* @__PURE__ */ jsx(
|
|
786
|
+
AnimatedVisibility,
|
|
787
|
+
{
|
|
788
|
+
visible: (inputValue == null ? void 0 : inputValue.length) > 0,
|
|
789
|
+
className: "es-uic-absolute es-uic-inset-y-1 es-uic-right-1",
|
|
790
|
+
transition: "scaleFade",
|
|
791
|
+
children: /* @__PURE__ */ jsx($d2b4bc8c273e7be6$export$353f5b6fc5456de1, { children: /* @__PURE__ */ jsx(Tooltip, { text: __("Clear", "eightshift-ui-components"), children: /* @__PURE__ */ jsx(
|
|
792
|
+
"div",
|
|
793
|
+
{
|
|
794
|
+
className: classnames(
|
|
795
|
+
"es-uic-flex es-uic-size-8 es-uic-items-center es-uic-justify-center es-uic-rounded es-uic-bg-white/85 es-uic-text-gray-600 es-uic-backdrop-blur es-uic-transition",
|
|
796
|
+
"hover:es-uic-bg-red-50 hover:es-uic-text-red-500",
|
|
797
|
+
"[&>svg]:es-uic-size-6"
|
|
798
|
+
),
|
|
799
|
+
children: removeIcon
|
|
800
|
+
}
|
|
801
|
+
) }) })
|
|
802
|
+
}
|
|
803
|
+
)
|
|
804
|
+
]
|
|
805
|
+
}
|
|
806
|
+
)
|
|
807
|
+
}
|
|
808
|
+
)
|
|
809
|
+
}
|
|
810
|
+
),
|
|
811
|
+
/* @__PURE__ */ jsxs(
|
|
812
|
+
Popover,
|
|
813
|
+
{
|
|
814
|
+
"aria-label": __("URL suggestions", "eightshift-ui-components"),
|
|
815
|
+
shouldFlip: false,
|
|
816
|
+
triggerRef,
|
|
817
|
+
isOpen: suggestionsVisible,
|
|
818
|
+
onOpenChange: (value) => {
|
|
819
|
+
setSuggestionsVisible(value);
|
|
820
|
+
debounced.cancel();
|
|
821
|
+
},
|
|
822
|
+
placement: "bottom",
|
|
823
|
+
className: "!es-uic-p-0",
|
|
824
|
+
style: {
|
|
825
|
+
width: `${(_a = triggerRef.current) == null ? void 0 : _a.offsetWidth}px`
|
|
826
|
+
},
|
|
827
|
+
children: [
|
|
828
|
+
suggestionList.isLoading && /* @__PURE__ */ jsx(
|
|
829
|
+
RichLabel,
|
|
830
|
+
{
|
|
831
|
+
icon: icons.progressbarIntermittent,
|
|
832
|
+
label: __("Loading suggestions...", "eightshift-ui-components"),
|
|
833
|
+
subtitle: __("Please wait", "eightshift-ui-components"),
|
|
834
|
+
className: "es-uic-min-h-14 es-uic-p-2"
|
|
835
|
+
}
|
|
836
|
+
),
|
|
837
|
+
!suggestionList.isLoading && suggestionList.items.length === 0 && /* @__PURE__ */ jsx(
|
|
838
|
+
RichLabel,
|
|
839
|
+
{
|
|
840
|
+
icon: icons.searchEmpty,
|
|
841
|
+
label: __("No suggestions found", "eightshift-ui-components"),
|
|
842
|
+
subtitle: __("Try a different search term.", "eightshift-ui-components"),
|
|
843
|
+
className: "es-uic-min-h-14 es-uic-p-2"
|
|
844
|
+
}
|
|
845
|
+
),
|
|
846
|
+
!suggestionList.isLoading && suggestionList.items.length > 0 && /* @__PURE__ */ jsx(
|
|
847
|
+
$13c3c67164f4d5be$export$4c260019440d418f,
|
|
848
|
+
{
|
|
849
|
+
orientation: "vertical",
|
|
850
|
+
className: "es-uic-flex es-uic-min-h-10 es-uic-flex-col es-uic-space-y-1 es-uic-p-2",
|
|
851
|
+
children: suggestionList.items.map((item, index) => {
|
|
852
|
+
const {
|
|
853
|
+
label: title,
|
|
854
|
+
value: url2,
|
|
855
|
+
metadata: { subtype }
|
|
856
|
+
} = item;
|
|
857
|
+
let typeIcon = icons.file;
|
|
858
|
+
if (subtype.toLowerCase() === "url") {
|
|
859
|
+
typeIcon = icons.externalLink;
|
|
860
|
+
} else if (subtype.toLowerCase() === "attachment") {
|
|
861
|
+
typeIcon = icons.file;
|
|
862
|
+
} else if (subtype.toLowerCase() === "category") {
|
|
863
|
+
typeIcon = icons.layoutAlt;
|
|
864
|
+
} else if (subtype.toLowerCase() === "internal") {
|
|
865
|
+
typeIcon = icons.anchor;
|
|
866
|
+
} else if (subtype.toLowerCase() === "eightshift-forms") {
|
|
867
|
+
typeIcon = icons.formAlt;
|
|
868
|
+
}
|
|
869
|
+
if (suggestionTypeIconOverride) {
|
|
870
|
+
const overrideIcon = suggestionTypeIconOverride(subtype);
|
|
871
|
+
if (overrideIcon) {
|
|
872
|
+
typeIcon = overrideIcon;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
return /* @__PURE__ */ jsx(
|
|
876
|
+
Button,
|
|
877
|
+
{
|
|
878
|
+
textValue: label,
|
|
879
|
+
size: "large",
|
|
880
|
+
type: "ghost",
|
|
881
|
+
className: classnames(
|
|
882
|
+
"es-uic-w-full es-uic-text-start",
|
|
883
|
+
"es-uic-grid es-uic-grid-cols-[auto,_minmax(0,_1fr)] es-uic-grid-rows-2 es-uic-items-center es-uic-justify-items-start es-uic-gap-x-2 es-uic-gap-y-0",
|
|
884
|
+
"[&>svg]:es-uic-row-span-2 [&>svg]:es-uic-shrink-0",
|
|
885
|
+
"[&>span:last-child]:es-uic-self-start [&>span]:es-uic-w-full [&>span]:es-uic-self-end [&>span]:es-uic-truncate"
|
|
886
|
+
),
|
|
887
|
+
onPress: () => {
|
|
888
|
+
setInputValue(url2);
|
|
889
|
+
debounced(url2);
|
|
890
|
+
setSuggestionsVisible(false);
|
|
891
|
+
},
|
|
892
|
+
icon: typeIcon,
|
|
893
|
+
autoFocus: index === 0,
|
|
894
|
+
children: /* @__PURE__ */ jsx(
|
|
895
|
+
RichLabel,
|
|
896
|
+
{
|
|
897
|
+
label: title,
|
|
898
|
+
subtitle: url2 == null ? void 0 : url2.replace(location.origin, "").replace(/\/$/, ""),
|
|
899
|
+
contentsOnly: true
|
|
900
|
+
}
|
|
901
|
+
)
|
|
902
|
+
},
|
|
903
|
+
url2
|
|
904
|
+
);
|
|
905
|
+
})
|
|
906
|
+
}
|
|
907
|
+
),
|
|
908
|
+
/* @__PURE__ */ jsx(
|
|
909
|
+
Spacer,
|
|
910
|
+
{
|
|
911
|
+
size: "px",
|
|
912
|
+
border: true
|
|
913
|
+
}
|
|
914
|
+
),
|
|
915
|
+
/* @__PURE__ */ jsxs("div", { className: "es-uic-grid es-uic-select-none es-uic-grid-cols-[auto,_1fr] es-uic-items-center es-uic-gap-x-1.5 es-uic-gap-y-1 es-uic-p-2 es-uic-text-sm es-uic-text-gray-500", children: [
|
|
916
|
+
/* @__PURE__ */ jsxs("div", { className: "es-uic-flex es-uic-gap-0.5 es-uic-justify-self-center", children: [
|
|
917
|
+
/* @__PURE__ */ jsx("kbd", { className: "es-uic-flex es-uic-size-5 es-uic-items-center es-uic-justify-center es-uic-rounded es-uic-border es-uic-p-0.5 es-uic-font-sans es-uic-text-xs es-uic-text-gray-400", children: "↑" }),
|
|
918
|
+
/* @__PURE__ */ jsx("kbd", { className: "es-uic-flex es-uic-size-5 es-uic-items-center es-uic-justify-center es-uic-rounded es-uic-border es-uic-p-0.5 es-uic-font-sans es-uic-text-xs es-uic-text-gray-400", children: "↓" })
|
|
919
|
+
] }),
|
|
920
|
+
__("Navigate", "eightshift-ui-components"),
|
|
921
|
+
/* @__PURE__ */ jsxs("div", { className: "es-uic-flex es-uic-gap-0.5 es-uic-justify-self-center", children: [
|
|
922
|
+
/* @__PURE__ */ jsx("kbd", { className: "es-uic-flex es-uic-size-5 es-uic-items-center es-uic-justify-center es-uic-justify-self-center es-uic-rounded es-uic-border es-uic-p-0.5 es-uic-font-sans es-uic-text-xs es-uic-text-gray-400", children: "↵" }),
|
|
923
|
+
/* @__PURE__ */ jsx("kbd", { className: "es-uic-flex es-uic-size-5 es-uic-items-center es-uic-justify-center es-uic-justify-self-center es-uic-rounded es-uic-border es-uic-p-0.5 es-uic-font-sans es-uic-text-xs es-uic-text-gray-400", children: "␣" })
|
|
924
|
+
] }),
|
|
925
|
+
__("Select an item", "eightshift-ui-components"),
|
|
926
|
+
/* @__PURE__ */ jsx("kbd", { className: "es-uic-flex es-uic-h-5 es-uic-min-w-5 es-uic-items-center es-uic-justify-center es-uic-justify-self-center es-uic-rounded es-uic-border es-uic-p-0.5 es-uic-font-sans es-uic-text-xs es-uic-text-gray-400", children: "Esc" }),
|
|
927
|
+
" ",
|
|
928
|
+
__("Close suggestion panel", "eightshift-ui-components")
|
|
929
|
+
] })
|
|
930
|
+
]
|
|
931
|
+
}
|
|
932
|
+
)
|
|
933
|
+
] });
|
|
934
|
+
};
|
|
935
|
+
export {
|
|
936
|
+
LinkInput
|
|
937
|
+
};
|