@g4rcez/components 0.2.1 → 0.2.3
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/index.css +1 -1
- package/dist/index.js +44 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11768 -10950
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +43 -43
- package/dist/index.umd.js.map +1 -1
- package/dist/preset/preset.tailwind.js +14 -14
- package/dist/preset/src/styles/common.d.ts +4 -0
- package/dist/preset/src/styles/common.d.ts.map +1 -1
- package/dist/preset/src/styles/common.js +10 -0
- package/dist/preset/src/styles/dark.d.ts.map +1 -1
- package/dist/preset/src/styles/dark.js +2 -1
- package/dist/preset/src/styles/design-tokens.d.ts +8 -7
- package/dist/preset/src/styles/design-tokens.d.ts.map +1 -1
- package/dist/preset/src/styles/design-tokens.js +16 -12
- package/dist/preset/src/styles/light.d.ts.map +1 -1
- package/dist/preset/src/styles/light.js +6 -5
- package/dist/preset/src/styles/theme.types.d.ts +10 -1
- package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
- package/dist/preset.tailwind.js +14 -14
- package/dist/src/components/core/render-on-view.d.ts.map +1 -1
- package/dist/src/components/core/render-on-view.js +1 -0
- package/dist/src/components/display/card.d.ts +9 -1
- package/dist/src/components/display/card.d.ts.map +1 -1
- package/dist/src/components/display/card.js +7 -1
- package/dist/src/components/display/list.js +1 -1
- package/dist/src/components/floating/dropdown.js +2 -2
- package/dist/src/components/floating/expand.d.ts +2 -0
- package/dist/src/components/floating/expand.d.ts.map +1 -1
- package/dist/src/components/floating/expand.js +12 -5
- package/dist/src/components/floating/menu.js +2 -2
- package/dist/src/components/floating/modal.js +1 -1
- package/dist/src/components/floating/tooltip.d.ts +1 -1
- package/dist/src/components/floating/tooltip.d.ts.map +1 -1
- package/dist/src/components/floating/tooltip.js +5 -4
- package/dist/src/components/form/autocomplete.d.ts.map +1 -1
- package/dist/src/components/form/autocomplete.js +26 -21
- package/dist/src/components/form/checkbox.d.ts +1 -0
- package/dist/src/components/form/checkbox.d.ts.map +1 -1
- package/dist/src/components/form/checkbox.js +4 -1
- package/dist/src/components/form/date-picker.d.ts.map +1 -1
- package/dist/src/components/form/date-picker.js +1 -0
- package/dist/src/components/form/free-text.d.ts.map +1 -1
- package/dist/src/components/form/free-text.js +2 -2
- package/dist/src/components/form/input-field.d.ts +1 -0
- package/dist/src/components/form/input-field.d.ts.map +1 -1
- package/dist/src/components/form/input-field.js +2 -2
- package/dist/src/components/form/input.d.ts.map +1 -1
- package/dist/src/components/form/input.js +3 -1
- package/dist/src/components/form/multi-select.d.ts.map +1 -1
- package/dist/src/components/form/multi-select.js +25 -21
- package/dist/src/components/form/select.d.ts.map +1 -1
- package/dist/src/components/form/select.js +2 -2
- package/dist/src/components/form/slider.d.ts +7 -0
- package/dist/src/components/form/slider.d.ts.map +1 -0
- package/dist/src/components/form/slider.js +35 -0
- package/dist/src/components/form/switch.d.ts +1 -0
- package/dist/src/components/form/switch.d.ts.map +1 -1
- package/dist/src/components/form/switch.js +7 -6
- package/dist/src/components/form/transfer-list.d.ts.map +1 -1
- package/dist/src/components/form/transfer-list.js +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/table/filter.d.ts.map +1 -1
- package/dist/src/components/table/filter.js +1 -1
- package/dist/src/components/table/index.d.ts.map +1 -1
- package/dist/src/components/table/index.js +17 -10
- package/dist/src/components/table/table-lib.d.ts +3 -2
- package/dist/src/components/table/table-lib.d.ts.map +1 -1
- package/dist/src/components/table/table-lib.js +16 -0
- package/dist/src/components/table/thead.d.ts.map +1 -1
- package/dist/src/components/table/thead.js +26 -6
- package/dist/src/config/context.d.ts.map +1 -1
- package/dist/src/config/context.js +1 -0
- package/dist/src/config/default-tweaks.d.ts +5 -0
- package/dist/src/config/default-tweaks.d.ts.map +1 -1
- package/dist/src/config/default-tweaks.js +2 -3
- package/dist/src/hooks/use-is-coarse-device.d.ts +2 -0
- package/dist/src/hooks/use-is-coarse-device.d.ts.map +1 -0
- package/dist/src/hooks/use-is-coarse-device.js +12 -0
- package/dist/src/hooks/use-remove-scroll.d.ts.map +1 -1
- package/dist/src/hooks/use-remove-scroll.js +6 -2
- package/dist/src/hooks/use-swipe.d.ts +1 -1
- package/dist/src/hooks/use-swipe.d.ts.map +1 -1
- package/dist/src/lib/dict.d.ts +1 -1
- package/dist/src/lib/dict.d.ts.map +1 -1
- package/dist/src/lib/dict.js +1 -1
- package/dist/src/lib/fns.d.ts +1 -0
- package/dist/src/lib/fns.d.ts.map +1 -1
- package/dist/src/lib/fns.js +4 -0
- package/dist/src/styles/common.d.ts +4 -0
- package/dist/src/styles/common.d.ts.map +1 -1
- package/dist/src/styles/common.js +10 -0
- package/dist/src/styles/dark.d.ts.map +1 -1
- package/dist/src/styles/dark.js +2 -1
- package/dist/src/styles/design-tokens.d.ts +8 -7
- package/dist/src/styles/design-tokens.d.ts.map +1 -1
- package/dist/src/styles/design-tokens.js +13 -10
- package/dist/src/styles/light.d.ts.map +1 -1
- package/dist/src/styles/light.js +6 -5
- package/dist/src/styles/theme.types.d.ts +10 -1
- package/dist/src/styles/theme.types.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -7,6 +7,7 @@ import { AnimatePresence, motion } from "motion/react";
|
|
|
7
7
|
import { forwardRef, Fragment, useEffect, useRef, useState } from "react";
|
|
8
8
|
import { flushSync } from "react-dom";
|
|
9
9
|
import { Virtuoso } from "react-virtuoso";
|
|
10
|
+
import { Is } from "sidekicker";
|
|
10
11
|
import { useTranslations } from "../../hooks/use-translations";
|
|
11
12
|
import { css, dispatchInput, initializeInputDataset } from "../../lib/dom";
|
|
12
13
|
import { safeRegex } from "../../lib/fns";
|
|
@@ -29,7 +30,7 @@ const Item = forwardRef(function VirtualItem({ item, context, ...props }, ref) {
|
|
|
29
30
|
const components = { List, Item };
|
|
30
31
|
const DEFAULT_SIZE = 320;
|
|
31
32
|
const MIN_SIZE = 40;
|
|
32
|
-
export const Autocomplete = forwardRef(({
|
|
33
|
+
export const Autocomplete = forwardRef(({ left, error, right, loading, options, container, rightLabel, interactive, emptyMessage, optionalText, labelClassName, feedback = null, hideLeft = false, required = false, dynamicOption = false, ...props }, externalRef) => {
|
|
33
34
|
const fieldset = useRef(null);
|
|
34
35
|
const virtuoso = useRef(null);
|
|
35
36
|
const defaults = props.value ?? props.defaultValue ?? "";
|
|
@@ -77,7 +78,7 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
|
|
|
77
78
|
if (ul.current === null)
|
|
78
79
|
return;
|
|
79
80
|
let size = 0;
|
|
80
|
-
const items = Array.from(ul.current.querySelectorAll("li")).slice(0, Math.min(
|
|
81
|
+
const items = Array.from(ul.current.querySelectorAll("li")).slice(0, Math.min(displayList.length, 10));
|
|
81
82
|
items.forEach((x) => {
|
|
82
83
|
const rect = x.getBoundingClientRect();
|
|
83
84
|
size += rect.height;
|
|
@@ -97,7 +98,7 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
|
|
|
97
98
|
padding: 10,
|
|
98
99
|
elementContext: "reference",
|
|
99
100
|
apply(a) {
|
|
100
|
-
const w = fieldset.current
|
|
101
|
+
const w = fieldset.current.getBoundingClientRect().width;
|
|
101
102
|
const ul = a.elements.floating.querySelector("ul");
|
|
102
103
|
const fullSize = ul?.getBoundingClientRect().height || 0;
|
|
103
104
|
const maxH = Math.min(fullSize < MIN_SIZE ? DEFAULT_SIZE : fullSize, DEFAULT_SIZE);
|
|
@@ -131,7 +132,7 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
|
|
|
131
132
|
focusItemOnOpen: "auto",
|
|
132
133
|
openOnArrowKeyDown: true,
|
|
133
134
|
scrollItemIntoView: true,
|
|
134
|
-
onNavigate: (n) => setIndex((prev) => n ?? prev)
|
|
135
|
+
// onNavigate: (n) => setIndex((prev) => n ?? prev)
|
|
135
136
|
}),
|
|
136
137
|
]);
|
|
137
138
|
useEffect(() => {
|
|
@@ -170,6 +171,7 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
|
|
|
170
171
|
refs.reference.current?.focus();
|
|
171
172
|
};
|
|
172
173
|
const onFocus = () => {
|
|
174
|
+
setIndex((prev) => (prev === null ? 0 : prev));
|
|
173
175
|
setOpen(true);
|
|
174
176
|
setShadow("");
|
|
175
177
|
};
|
|
@@ -182,7 +184,8 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
|
|
|
182
184
|
setClosed();
|
|
183
185
|
};
|
|
184
186
|
const id = props.id || props.name;
|
|
185
|
-
|
|
187
|
+
const isEmpty = displayList.length === 0;
|
|
188
|
+
return (_jsxs(InputField, { ...props, left: left, error: error, ref: fieldset, form: props.form, loading: loading, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, rightLabel: rightLabel, interactive: interactive, id: props.name || props.id, optionalText: optionalText, componentName: "autocomplete", labelClassName: labelClassName, placeholder: props.placeholder, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [right, _jsxs("button", { type: "button", className: "p-2 transition-colors link:text-primary md:p-1", onClick: onCaretDownClick, children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }), value ? (_jsx("button", { type: "button", onClick: onClose, className: "p-2 transition-colors link:text-danger md:p-1", children: _jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) })) : null] }), children: [_jsx("input", { "data-shadow": "true", ...getReferenceProps({
|
|
186
189
|
...props,
|
|
187
190
|
onChange,
|
|
188
191
|
onFocus,
|
|
@@ -192,44 +195,46 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
|
|
|
192
195
|
id: `${id}-shadow`,
|
|
193
196
|
onClick: (e) => e.currentTarget.focus(),
|
|
194
197
|
onKeyDown(event) {
|
|
198
|
+
if (event.key === "Escape") {
|
|
199
|
+
event.currentTarget.blur();
|
|
200
|
+
return setClosed();
|
|
201
|
+
}
|
|
202
|
+
if (!open)
|
|
203
|
+
return;
|
|
195
204
|
if (event.key === "ArrowDown") {
|
|
196
|
-
let next = index + 1;
|
|
197
|
-
if (next >
|
|
205
|
+
let next = Is.number(index) ? index + 1 : 0;
|
|
206
|
+
if (next > displayList.length - 1)
|
|
198
207
|
next = 0;
|
|
199
208
|
virtuoso.current?.scrollIntoView({ index: next });
|
|
200
209
|
return setIndex(next);
|
|
201
210
|
}
|
|
202
211
|
if (event.key === "ArrowUp") {
|
|
203
|
-
let next = index - 1;
|
|
212
|
+
let next = Is.number(index) ? index - 1 : displayList.length - 1;
|
|
204
213
|
if (next < 0)
|
|
205
|
-
next =
|
|
214
|
+
next = displayList.length - 1;
|
|
206
215
|
virtuoso.current?.scrollIntoView({ index: next });
|
|
207
216
|
return setIndex(next);
|
|
208
217
|
}
|
|
209
|
-
if (event.key === "Escape") {
|
|
210
|
-
event.currentTarget.blur();
|
|
211
|
-
return setClosed();
|
|
212
|
-
}
|
|
213
218
|
if (event.key === "Enter") {
|
|
214
|
-
if (index !== null &&
|
|
219
|
+
if (index !== null && displayList[index]) {
|
|
215
220
|
event.preventDefault();
|
|
216
|
-
return onSelect(
|
|
221
|
+
return onSelect(displayList[index], index);
|
|
217
222
|
}
|
|
218
|
-
if (
|
|
223
|
+
if (displayList.length === 1) {
|
|
219
224
|
event.preventDefault();
|
|
220
|
-
return onSelect(
|
|
225
|
+
return onSelect(displayList[0], 0);
|
|
221
226
|
}
|
|
222
227
|
}
|
|
223
228
|
},
|
|
224
|
-
}), "data-value": value, "data-error": !!error, "data-name": id, "data-target": id, required: required, value: open ? shadow : label || value, "aria-autocomplete": "list", autoComplete: "off", className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "group-focus-within:border-primary group-hover:border-primary", props.className) }), _jsx("input", { id: id, name: id, type: "hidden", "data-origin": id, ref: externalRef, required: required, defaultValue: props.value || value || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs(
|
|
229
|
+
}), "data-value": value, "data-error": !!error, "data-name": id, "data-target": id, required: required, value: open ? shadow : label || value, "aria-autocomplete": "list", autoComplete: "off", className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "group-focus-within:border-primary group-hover:border-primary", props.className) }), _jsx("input", { id: id, name: id, type: "hidden", "data-origin": id, ref: externalRef, required: required, defaultValue: props.value || value || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs(motion.ul, { ...getFloatingProps({
|
|
225
230
|
ref: refs.setFloating,
|
|
226
231
|
style: {
|
|
227
232
|
...transitions.styles,
|
|
228
|
-
position: strategy,
|
|
229
|
-
left: (x ?? 0) + (!!value ? 36 : 25),
|
|
230
233
|
top: y ?? 0,
|
|
234
|
+
position: strategy,
|
|
235
|
+
left: (x ?? 0) + (value ? 36 : 25),
|
|
231
236
|
},
|
|
232
|
-
}), "data-floating": "true", className: "isolate z-floating m-0 origin-[top_center] list-none overscroll-contain rounded-b-lg rounded-t-lg border border-floating-border bg-floating-background p-0 text-foreground shadow-floating", children: [
|
|
237
|
+
}), initial: false, "data-floating": "true", animate: { height: isEmpty ? "auto" : h }, className: "isolate z-floating m-0 origin-[top_center] list-none overscroll-contain rounded-b-lg rounded-t-lg border border-floating-border bg-floating-background p-0 text-foreground shadow-floating", children: [isEmpty ? (_jsx("li", { role: "option", className: "w-full border-b border-tooltip-border last:border-transparent", children: _jsx("span", { className: "flex w-full justify-between p-2 text-left text-disabled", children: emptyMessage || translation.autocompleteEmpty }) })) : null, _jsx(Virtuoso, { ref: virtuoso, hidden: isEmpty, data: displayList, style: { height: h }, components: components, className: "rounded-lg border-floating-border bg-floating-background p-0 text-foreground", itemContent: (i, option) => {
|
|
233
238
|
const Label = option.Render ?? Frag;
|
|
234
239
|
const active = value === option.value || value === option.label;
|
|
235
240
|
const selected = index === i;
|
|
@@ -3,6 +3,7 @@ import { Override } from "../../types";
|
|
|
3
3
|
export type CheckboxProps = Override<React.PropsWithChildren<React.ComponentProps<"input">>, {
|
|
4
4
|
error?: string;
|
|
5
5
|
asTask?: boolean;
|
|
6
|
+
loading?: boolean;
|
|
6
7
|
container?: string;
|
|
7
8
|
labelClassName?: string;
|
|
8
9
|
size?: "medium" | "large";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../../src/components/form/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAChC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EACtD;IACI,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC7B,CACJ,CAAC;AAEF,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../../src/components/form/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAChC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EACtD;IACI,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC7B,CACJ,CAAC;AAEF,eAAO,MAAM,QAAQ,qGAiCpB,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { css } from "../../lib/dom";
|
|
4
|
-
export const Checkbox = forwardRef(({ children, asTask = false, labelClassName, error, className = "", size, container, ...props }, ref) =>
|
|
4
|
+
export const Checkbox = forwardRef(({ children, asTask = false, labelClassName, loading, error, className = "", size, container, ...props }, ref) => {
|
|
5
|
+
const d = props.disabled || loading;
|
|
6
|
+
return (_jsxs("label", { "aria-disabled": d, "data-disabled": d, "data-task": asTask, "data-component": "checkbox", className: css("group flex w-fit flex-wrap items-center font-normal data-[disabled=true]:cursor-not-allowed", asTask ? "group-checkbox-checked:line-through" : "", container), children: [_jsx("input", { ...props, ref: ref, disabled: d, type: "checkbox", "data-task": asTask, className: css("form-checkbox mr-2 inline-block size-4 appearance-none rounded border-card-border bg-origin-border text-primary focus:ring-primary disabled:opacity-70 group-aria-disabled:cursor-not-allowed", className) }), children, _jsx("span", { "data-name": "checkbox-label", className: css("min-w-full flex-1 text-xs text-danger empty:mt-0 empty:hidden", labelClassName), children: error })] }));
|
|
7
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAI9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,EAAE,UAAU,CAAC,CAAC;AAmCpF,eAAO,MAAM,UAAU,uGA4GtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"free-text.d.ts","sourceRoot":"","sources":["../../../../src/components/form/free-text.tsx"],"names":[],"mappings":"AAEA,OAAO,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;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AgB,GAAG,mBAAmB,EAAE,KAAK,SAAS,GAAG,EACxH,SAAS,OAAO,GAAG,UAAU,GAAG,OAAO,SAAS,EAChD,aAAa,OAAO,GAAG,UAAU,EACjC,cAAc,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,EACrC,WAAW,CAAC,EAAE,EAAE,IAAI,KAAK,MAAM,IAAI,4CAuGtC,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { forwardRef, useEffect, useRef } from "react";
|
|
|
4
4
|
import { css, initializeInputDataset, mergeRefs } from "../../lib/dom";
|
|
5
5
|
import { InputField } from "./input-field";
|
|
6
6
|
export const createFreeText = (Element, elementName, defaultProps, register) => {
|
|
7
|
-
const FreeText = forwardRef(({ info, left, next, error, right, container, rightLabel, interactive, optionalText, type = "text", labelClassName, feedback = null, hideLeft = false, ...props }, ref) => {
|
|
7
|
+
const FreeText = forwardRef(({ info, left, next, error, right, container, rightLabel, interactive, optionalText, type = "text", labelClassName, feedback = null, hideLeft = false, loading, ...props }, ref) => {
|
|
8
8
|
const Render = Element;
|
|
9
9
|
const id = props.id ?? props.name;
|
|
10
10
|
const inputRef = useRef(null);
|
|
@@ -34,7 +34,7 @@ export const createFreeText = (Element, elementName, defaultProps, register) =>
|
|
|
34
34
|
input.removeEventListener("keydown", goNextInputImpl);
|
|
35
35
|
};
|
|
36
36
|
}, []);
|
|
37
|
-
return (_jsx(InputField, { ...defaultProps, info: info, left: left, error: error, right: right, form: props.form, name: props.name, feedback: feedback, hideLeft: hideLeft, title: props.title, container: container, rightLabel: rightLabel, disabled: props.disabled, interactive: interactive, required: props.required, componentName: elementName, id: props.name || props.id, optionalText: optionalText, labelClassName: labelClassName, placeholder: props.placeholder, children: _jsx(Render, { ...defaultProps, ...props, id: id, name: id, type: type, "data-next": next, "aria-busy": props.disabled, "aria-disabled": props.disabled, "aria-readonly": props.readOnly, ref: mergeRefs(ref, inputRef), className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "resize-y group-focus-within:border-primary group-hover:border-primary", "disabled:cursor-not-allowed disabled:text-disabled", props.className) }) }));
|
|
37
|
+
return (_jsx(InputField, { ...defaultProps, info: info, left: left, error: error, right: right, loading: loading, form: props.form, name: props.name, feedback: feedback, hideLeft: hideLeft, title: props.title, container: css(container, defaultProps.container), rightLabel: rightLabel, disabled: props.disabled, interactive: interactive, required: props.required, componentName: elementName, id: props.name || props.id, optionalText: optionalText, labelClassName: labelClassName, placeholder: props.placeholder, children: _jsx(Render, { ...defaultProps, ...props, id: id, name: id, type: type, "data-next": next, "aria-busy": props.disabled, "aria-disabled": props.disabled, "aria-readonly": props.readOnly, ref: mergeRefs(ref, inputRef), className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "resize-y group-focus-within:border-primary group-hover:border-primary", "disabled:cursor-not-allowed disabled:text-disabled", props.className) }) }));
|
|
38
38
|
});
|
|
39
39
|
return FreeText;
|
|
40
40
|
};
|
|
@@ -11,6 +11,7 @@ export type FeedbackProps = React.PropsWithChildren<Partial<{
|
|
|
11
11
|
}>>;
|
|
12
12
|
export declare const InputFeedback: ({ reportStatus, hideLeft, className, info, children, title }: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export type InputFieldProps<T extends "input" | "select" | "textarea"> = PolymorphicProps<Partial<Override<FeedbackProps, {
|
|
14
|
+
loading: boolean;
|
|
14
15
|
componentName: string;
|
|
15
16
|
info: Label;
|
|
16
17
|
labelClassName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-field.d.ts","sourceRoot":"","sources":["../../../../src/components/form/input-field.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAwB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AAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB,CACJ,CACJ,EACD,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,SAAS,OAAO,GAAG,QAAQ,GAAG,UAAU,EAAE,KAAK,EAAE,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,YA6EpH,CAAC"}
|
|
@@ -6,12 +6,12 @@ import { useTranslations } from "../../hooks/use-translations";
|
|
|
6
6
|
import { useTweaks } from "../../hooks/use-tweaks";
|
|
7
7
|
import { css } from "../../lib/dom";
|
|
8
8
|
import { Tooltip } from "../floating/tooltip";
|
|
9
|
-
export const InputFeedback = ({ reportStatus, hideLeft = false, className, info, children, title }) => (_jsxs("
|
|
9
|
+
export const InputFeedback = ({ reportStatus, hideLeft = false, className, info, children, title }) => (_jsxs("span", { className: css("w-full justify-between", hideLeft && children === null ? "hidden" : "flex", className), children: [hideLeft ? null : (_jsxs("span", { className: "flex items-center gap-1 transition-colors group-focus-within:text-primary group-hover:text-primary group-disabled:text-disabled group-error:text-danger", children: [title, reportStatus || info ? (_jsxs("span", { className: "flex items-center justify-center gap-1", children: [info ? (_jsx(Tooltip, { as: "button", type: "button", "aria-description": info, title: _jsxs("span", { className: "cursor-help", children: [_jsx("span", { className: "sr-only", children: info }), _jsx(InfoIcon, { className: "aspect-square size-3", "aria-hidden": "true", size: 16, strokeWidth: 1, absoluteStrokeWidth: true })] }), children: _jsx("div", { className: "w-full max-w-48 whitespace-break-spaces break-words", children: info }) })) : null, reportStatus ? (_jsxs("span", { className: "flex h-3 min-w-6 items-center", children: [_jsx(CheckCircle, { className: "hidden aspect-square size-3 opacity-0 transition-opacity group-assert:block group-assert:text-success group-assert:opacity-100", "aria-hidden": "true", size: 16, strokeWidth: 1, absoluteStrokeWidth: true }), _jsx(XCircle, { className: "hidden aspect-square size-3 opacity-0 transition-opacity group-error:block group-error:opacity-100", "aria-hidden": "true", size: 16, strokeWidth: 1, absoluteStrokeWidth: true })] })) : null] })) : null] })), children] }));
|
|
10
10
|
export const InputField = forwardRef(({ optionalText: _optionalText, left, rightLabel, container, feedback, interactive, right, info, children, error, form, id, labelClassName = "", name, title, componentName, placeholder, hideLeft = false, required, disabled, reportStatus, }, ref) => {
|
|
11
11
|
const tweaks = useTweaks();
|
|
12
12
|
const reportStatusDefault = reportStatus !== undefined ? reportStatus : tweaks.input.iconFeedback;
|
|
13
13
|
const ID = id ?? name;
|
|
14
14
|
const translation = useTranslations();
|
|
15
15
|
const optionalText = _optionalText ?? translation.inputOptionalLabel;
|
|
16
|
-
return (_jsxs("fieldset", { ref: ref, form: form, disabled: disabled, "data-error": !!error, "aria-disabled": disabled, "data-component": componentName, "data-interactive": !!interactive, className: css("group
|
|
16
|
+
return (_jsxs("fieldset", { ref: ref, form: form, disabled: disabled, "data-error": !!error, "aria-disabled": disabled, "data-component": componentName, "data-interactive": !!interactive, className: css("group flex min-h-0 max-w-full min-w-0 flex-col items-start", container), children: [_jsxs("label", { form: form, htmlFor: ID, className: "text-field-label max-w-full w-full relative inline-flex cursor-text flex-row flex-wrap justify-between gap-1 text-sm transition-colors empty:hidden group-disabled:cursor-not-allowed group-error:text-danger", children: [_jsx(InputFeedback, { info: info, hideLeft: hideLeft, reportStatus: reportStatusDefault, title: title, placeholder: placeholder, children: optionalText || rightLabel ? (_jsxs(Fragment, { children: [!required ? (_jsx("span", { "aria-disabled": disabled, className: "text-opacity-70 aria-disabled:text-disabled", children: optionalText })) : null, rightLabel ? _jsx(Fragment, { children: rightLabel }) : null] })) : null }), _jsxs("div", { className: `group relative flex w-full flex-row flex-nowrap items-center gap-x-2 gap-y-1 rounded-md border border-input-border bg-transparent transition-colors group-hover:border-primary group-disabled:border-disabled group-error:border-danger ${labelClassName}`, children: [left ? _jsx("span", { className: "flex flex-nowrap gap-1 whitespace-nowrap pl-2", children: left }) : null, children, right ? _jsx("span", { className: "flex flex-nowrap gap-2 whitespace-nowrap pr-2", children: right }) : null] })] }), _jsx("p", { className: "mt-input-gap hidden whitespace-pre-wrap text-wrap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):invalid[data-initialized=true]]:flex group-error:flex group-error:text-danger", children: error }), _jsx("p", { className: "mt-input-gap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):valid[data-initialized=true]]:block group-assert:block group-error:hidden", children: feedback })] }));
|
|
17
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../src/components/form/input.tsx"],"names":[],"mappings":"AACA,OAAkB,EACd,QAAQ,EACR,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,OAAO,EACP,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAkB,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5D,mBAAmB,gBAAgB,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG,aAAa,CAClC,OAAO,EACL,CAAC;IACG,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACvC,GAAG,kBAAkB,CAAC,GACvB,CAAC;IACG,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,GAAG,iBAAiB,CAAC,GACtB,CAAC;IACG,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC9F,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,GAAG,YAAY,CAAC,CACtB,CAAC;AAEF,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../src/components/form/input.tsx"],"names":[],"mappings":"AACA,OAAkB,EACd,QAAQ,EACR,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,OAAO,EACP,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAkB,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5D,mBAAmB,gBAAgB,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG,aAAa,CAClC,OAAO,EACL,CAAC;IACG,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACvC,GAAG,kBAAkB,CAAC,GACvB,CAAC;IACG,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,GAAG,iBAAiB,CAAC,GACtB,CAAC;IACG,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC9F,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,GAAG,YAAY,CAAC,CACtB,CAAC;AAEF,eAAO,MAAM,KAAK,oEAEhB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-select.d.ts","sourceRoot":"","sources":["../../../../src/components/form/multi-select.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAA6F,MAAM,OAAO,CAAC;AAOlH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,M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C;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACjD,CACJ,CAAC;AA0DF,eAAO,MAAM,WAAW,wGAkYvB,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { autoUpdate, FloatingFocusManager, FloatingPortal, offset, size, useDismiss, useFloating, useInteractions, useListNavigation, useRole, useTransitionStyles, } from "@floating-ui/react";
|
|
4
4
|
import Fuzzy from "fuzzy-search";
|
|
5
|
-
import { ChevronDown } from "lucide-react";
|
|
5
|
+
import { ChevronDown, XIcon } from "lucide-react";
|
|
6
6
|
import { AnimatePresence, motion } from "motion/react";
|
|
7
7
|
import React, { forwardRef, Fragment, useEffect, useMemo, useRef, useState } from "react";
|
|
8
8
|
import { flushSync } from "react-dom";
|
|
@@ -93,6 +93,8 @@ export const MultiSelect = forwardRef(({ left, error, right, options, container,
|
|
|
93
93
|
setValue(new Dict(props.value.map((x) => [x, map.get(x)])));
|
|
94
94
|
}
|
|
95
95
|
}, [props.value, map]);
|
|
96
|
+
const displayList = list.filter((x) => x.hidden !== true);
|
|
97
|
+
const isEmpty = displayList.length === 0;
|
|
96
98
|
const { x, y, strategy, refs, context } = useFloating({
|
|
97
99
|
open,
|
|
98
100
|
transform: true,
|
|
@@ -113,8 +115,8 @@ export const MultiSelect = forwardRef(({ left, error, right, options, container,
|
|
|
113
115
|
Object.assign(a.elements.floating.style, {
|
|
114
116
|
width: `${w}px`,
|
|
115
117
|
maxWidth: `${w}px`,
|
|
116
|
-
maxHeight: `${maxH}px`,
|
|
117
|
-
height: `${maxH}px`,
|
|
118
|
+
maxHeight: isEmpty ? "auto" : `${maxH}px`,
|
|
119
|
+
height: isEmpty ? "auto" : `${maxH}px`,
|
|
118
120
|
});
|
|
119
121
|
},
|
|
120
122
|
}),
|
|
@@ -187,26 +189,28 @@ export const MultiSelect = forwardRef(({ left, error, right, options, container,
|
|
|
187
189
|
onChangeOptions?.([]);
|
|
188
190
|
};
|
|
189
191
|
const id = props.id || props.name;
|
|
190
|
-
const tags = value.map((x) => (_jsx(Tag, { size: "small",
|
|
191
|
-
|
|
192
|
+
const tags = value.map((x, i) => (_jsx(Tag, { size: "small", icon: _jsx("button", { type: "button", className: "text-current hover:text-danger focus:text-danger", onClick: (e) => {
|
|
193
|
+
e.stopPropagation();
|
|
194
|
+
onSelect(x, i);
|
|
195
|
+
}, children: _jsx(XIcon, { size: 14 }) }), children: x.label ?? x.value }, `MultiSelect-${x.value}-x`)));
|
|
192
196
|
return (_jsxs(InputField, { ...props, left: left, error: error, ref: fieldset, form: props.form, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, rightLabel: rightLabel, interactive: interactive, id: props.name || props.id, optionalText: optionalText, componentName: "autocomplete", labelClassName: labelClassName, placeholder: props.placeholder, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [right, _jsxs("button", { type: "button", className: "transition-colors link:text-primary", onClick: onCaretDownClick, children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }), value ? (_jsx("button", { type: "button", onClick: onClose, className: "transition-colors link:text-danger", children: _jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) })) : null] }), children: [_jsx("button", { ...getReferenceProps({
|
|
193
197
|
...props,
|
|
194
198
|
onFocus,
|
|
195
199
|
id: `${id}-shadow`,
|
|
196
200
|
name: `${id}-shadow`,
|
|
197
201
|
ref: refs.setReference,
|
|
198
|
-
}), type: "button", "data-name": id, "data-target": id, "data-shadow": "true", "data-error": !!error, "aria-autocomplete": "list", "data-value": deriveValue.join(","), value: open ? shadow : label || value, className: css("input placeholder-input-mask group h-input-height w-full", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "group-focus-within:border-primary group-hover:border-primary", "flex flex-row items-center gap-2 whitespace-nowrap text-left", "truncate overflow-ellipsis", props.className), children: _jsx(OverflowControl, { label: selectedLabel, children: tags }) }), _jsx("input", { id: id, name: id, type: "hidden", "data-origin": id, ref: externalRef, required: required, defaultValue: props.value || deriveValue || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs("div", { ...getFloatingProps({
|
|
202
|
+
}), type: "button", "data-name": id, "data-target": id, "data-shadow": "true", "data-error": !!error, "aria-autocomplete": "list", "data-value": deriveValue.join(","), value: open ? shadow : label || value, className: css("input placeholder-input-mask group h-input-height w-full", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "group-focus-within:border-primary group-hover:border-primary", "flex flex-row items-center gap-2 whitespace-nowrap text-left", "max-w-full overflow-x-auto truncate overflow-ellipsis", props.className), children: _jsx(OverflowControl, { label: selectedLabel, children: tags }) }), _jsx("input", { id: id, name: id, type: "hidden", "data-origin": id, ref: externalRef, required: required, defaultValue: props.value || deriveValue || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { modal: true, guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs("div", { ...getFloatingProps({
|
|
199
203
|
ref: refs.setFloating,
|
|
200
204
|
style: {
|
|
201
205
|
...transitions.styles,
|
|
202
|
-
position: strategy,
|
|
203
|
-
left: (x ?? 0) + (!!value ? 26 : 18),
|
|
204
206
|
top: y ?? 0,
|
|
207
|
+
position: strategy,
|
|
208
|
+
left: (x ?? 0) + (value ? 26 : 18),
|
|
205
209
|
},
|
|
206
210
|
}), "data-floating": "true", className: "isolate z-floating m-0 w-full origin-[top_center] list-none overscroll-contain rounded-b-lg rounded-t-lg border border-floating-border bg-floating-background p-0 text-foreground shadow-floating", children: [_jsx("input", { autoFocus: true, value: shadow, onChange: onChange, title: props.title, placeholder: translation.multiSelectInnerPlaceholder, onKeyDown: (event) => {
|
|
207
211
|
if (event.key === "ArrowDown") {
|
|
208
212
|
let next = index + 1;
|
|
209
|
-
if (next >
|
|
213
|
+
if (next > displayList.length - 1)
|
|
210
214
|
next = 0;
|
|
211
215
|
virtuoso.current?.scrollIntoView({ index: next });
|
|
212
216
|
return setIndex(next);
|
|
@@ -214,7 +218,7 @@ export const MultiSelect = forwardRef(({ left, error, right, options, container,
|
|
|
214
218
|
if (event.key === "ArrowUp") {
|
|
215
219
|
let next = index - 1;
|
|
216
220
|
if (next < 0)
|
|
217
|
-
next =
|
|
221
|
+
next = displayList.length - 1;
|
|
218
222
|
virtuoso.current?.scrollIntoView({ index: next });
|
|
219
223
|
return setIndex(next);
|
|
220
224
|
}
|
|
@@ -223,21 +227,21 @@ export const MultiSelect = forwardRef(({ left, error, right, options, container,
|
|
|
223
227
|
return setOpen(false);
|
|
224
228
|
}
|
|
225
229
|
if (event.key === "Enter") {
|
|
226
|
-
if (index !== null &&
|
|
230
|
+
if (index !== null && displayList[index]) {
|
|
227
231
|
event.preventDefault();
|
|
228
|
-
return onSelect(
|
|
232
|
+
return onSelect(displayList[index], index);
|
|
229
233
|
}
|
|
230
|
-
if (
|
|
234
|
+
if (displayList.length === 1) {
|
|
231
235
|
event.preventDefault();
|
|
232
|
-
return onSelect(
|
|
236
|
+
return onSelect(displayList[0], 0);
|
|
233
237
|
}
|
|
234
238
|
}
|
|
235
|
-
}, className: "input placeholder-input-mask group mb-1 h-10 w-full flex-1 border-b border-input-border bg-transparent px-input-x py-input-y outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary" }),
|
|
239
|
+
}, className: "input placeholder-input-mask group mb-1 h-10 w-full flex-1 border-b border-input-border bg-transparent px-input-x py-input-y outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary" }), isEmpty ? (_jsx("li", { role: "option", className: "w-full border-b border-tooltip-border last:border-transparent", children: _jsx("span", { className: "flex w-full justify-between p-2 text-left text-disabled", children: emptyMessage || translation.autocompleteEmpty }) })) : null, isEmpty ? null : (_jsx(Virtuoso, { ref: virtuoso, hidden: isEmpty, data: displayList, components: components, style: { height: isEmpty ? "0" : value.size === 0 ? h - 49 : h - 86 }, className: "border-floating-border bg-floating-background p-0 text-foreground", itemContent: (i, option) => {
|
|
236
240
|
const Label = option.Render ?? Frag;
|
|
237
241
|
const active = value.has(option.value) || value.has(option.label ?? "");
|
|
238
242
|
const selected = index === i;
|
|
239
243
|
const children = option.label ?? option.value;
|
|
240
|
-
return (
|
|
244
|
+
return (_jsxs("button", { "data-value": option.value, ...getItemProps({
|
|
241
245
|
ref: (node) => void (listRef.current[i] = node),
|
|
242
246
|
role: "option",
|
|
243
247
|
type: "button",
|
|
@@ -246,9 +250,9 @@ export const MultiSelect = forwardRef(({ left, error, right, options, container,
|
|
|
246
250
|
"aria-selected": active,
|
|
247
251
|
"aria-busy": option.disabled,
|
|
248
252
|
onClick: () => onSelect(option, i),
|
|
249
|
-
}), className: `w-full cursor-pointer p-2 text-left hover:bg-floating-hover focus:bg-floating-hover ${active || selected ? "bg-floating-hover text-floating-foreground" : ""}`, children: _jsx(Checkbox, { onChange: noop, checked: active, "aria-checked": active, onClick: (e) => {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
} }), value.size === 0 ? null : (_jsx("div", { className: "sticky bottom-0 flex w-full flex-nowrap items-center gap-2 overflow-x-auto rounded-b-lg bg-floating-background p-2", children: tags }))] }) })) : null })] }));
|
|
253
|
+
}), className: `flex w-full max-w-full cursor-pointer items-center justify-start p-2 text-left hover:bg-floating-hover focus:bg-floating-hover ${active || selected ? "bg-floating-hover text-floating-foreground" : ""}`, children: [_jsx(Checkbox, { onChange: noop, checked: active, "aria-checked": active, onClick: (e) => {
|
|
254
|
+
e.stopPropagation();
|
|
255
|
+
onSelect(option, i);
|
|
256
|
+
} }), _jsx(Label, { ...props, label: option.label, value: option.value, children: children })] }));
|
|
257
|
+
} })), value.size === 0 ? null : (_jsx("div", { className: "sticky bottom-0 flex w-full flex-nowrap items-center gap-2 overflow-x-auto rounded-b-lg bg-floating-background p-2", children: tags }))] }) })) : null })] }));
|
|
254
258
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../src/components/form/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6D,MAAM,OAAO,CAAC;AAGlF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5D,MAAM,MAAM,WAAW,GAAG,QAAQ,CAC9B,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAC9B;IACI,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,CAChD,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAC9B,eAAe,CAAC,QAAQ,CAAC,EACzB;IACI,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B,CACJ,CAAC;AAEF,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../src/components/form/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6D,MAAM,OAAO,CAAC;AAGlF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5D,MAAM,MAAM,WAAW,GAAG,QAAQ,CAC9B,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAC9B;IACI,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,CAChD,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAC9B,eAAe,CAAC,QAAQ,CAAC,EACzB;IACI,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B,CACJ,CAAC;AAEF,eAAO,MAAM,MAAM,oGA2GlB,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
|
|
|
6
6
|
import { useTranslations } from "../../hooks/use-translations";
|
|
7
7
|
import { css, initializeInputDataset, mergeRefs } from "../../lib/dom";
|
|
8
8
|
import { InputField } from "./input-field";
|
|
9
|
-
export const Select = forwardRef(({ required = true, options, info, selectContainer = "", feedback = null, labelClassName, interactive, rightLabel, optionalText, container, hideLeft = false, right, left, error, ...props }, ref) => {
|
|
9
|
+
export const Select = forwardRef(({ required = true, options, info, selectContainer = "", feedback = null, labelClassName, interactive, rightLabel, loading, optionalText, container, hideLeft = false, right, left, error, ...props }, ref) => {
|
|
10
10
|
const translation = useTranslations();
|
|
11
11
|
const inputRef = useRef(null);
|
|
12
12
|
const id = props.id ?? props.name;
|
|
@@ -27,5 +27,5 @@ export const Select = forwardRef(({ required = true, options, info, selectContai
|
|
|
27
27
|
};
|
|
28
28
|
}, []);
|
|
29
29
|
const onClickLabel = () => inputRef.current?.focus();
|
|
30
|
-
return (_jsx(InputField, { info: info, left: left, error: error, form: props.form, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, componentName: "select", rightLabel: rightLabel, interactive: interactive, id: props.name || props.id, optionalText: optionalText, labelClassName: labelClassName, placeholder: props.placeholder, right:
|
|
30
|
+
return (_jsx(InputField, { info: info, left: left, error: error, form: props.form, loading: loading, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, componentName: "select", rightLabel: rightLabel, interactive: interactive, id: props.name || props.id, optionalText: optionalText, labelClassName: labelClassName, placeholder: props.placeholder, right: _jsxs("label", { htmlFor: id, children: [right, _jsxs("button", { onClick: onClickLabel, type: "button", className: "mt-2 transition-colors hover:text-primary", children: [_jsx(ChevronDownIcon, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] })] }), children: _jsxs("select", { ...props, id: id, name: id, value: props.value, required: required, ref: mergeRefs(ref, inputRef), "data-selected": !!props.value || false, defaultValue: props.value ? undefined : "", title: typeof props.title === "string" ? props.title : undefined, className: css("input select group h-10 w-full flex-1 appearance-none rounded-md", "bg-transparent px-2 py-1 text-foreground placeholder-input-placeholder", "outline-none transition-colors group-error:text-danger group-error:placeholder-input-mask-error", "data-[selected=false]:text-input-placeholder", props.className), children: [_jsx("option", { value: "", disabled: true, hidden: true, children: props.placeholder }), options.map((option) => (_createElement("option", { ...option, value: option.value, children: option.label ?? option.value, key: `${id}-select-option-${option.value}` })))] }) }));
|
|
31
31
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SliderProps as RadixSliderProps } from "@radix-ui/react-slider";
|
|
2
|
+
type SliderProps = RadixSliderProps & {
|
|
3
|
+
tooltip?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const Slider: (props: SliderProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=slider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../../src/components/form/slider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAO9E,KAAK,WAAW,GAAG,gBAAgB,GAAG;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAmCF,eAAO,MAAM,MAAM,GAAI,OAAO,WAAW,4CAoBxC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as RadixSlider from "@radix-ui/react-slider";
|
|
4
|
+
import { Is } from "sidekicker";
|
|
5
|
+
import { css } from "../../lib/dom";
|
|
6
|
+
import { Tooltip } from "../floating/tooltip";
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
import { uuid } from "../../lib/fns";
|
|
9
|
+
const Thumb = (props) => {
|
|
10
|
+
const [float, setFloat] = useState(null);
|
|
11
|
+
const ref = useRef(null);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const html = ref.current;
|
|
14
|
+
if (html === null)
|
|
15
|
+
return;
|
|
16
|
+
const initialValue = Number(html.getAttribute("aria-valuenow"));
|
|
17
|
+
if (Is.number(initialValue)) {
|
|
18
|
+
setFloat(initialValue);
|
|
19
|
+
}
|
|
20
|
+
const observer = new MutationObserver((changes) => {
|
|
21
|
+
const span = changes[0].target;
|
|
22
|
+
const value = Number(span.getAttribute("aria-valuenow"));
|
|
23
|
+
setFloat(Is.number(value) ? value : null);
|
|
24
|
+
});
|
|
25
|
+
observer.observe(html, { attributeFilter: ["aria-valuenow"] });
|
|
26
|
+
return () => observer.disconnect();
|
|
27
|
+
}, []);
|
|
28
|
+
return (_jsx(Tooltip, { title: "", ref: ref, as: RadixSlider.Thumb, enabled: props.tooltip, className: "block size-5 cursor-grab rounded-full border-2 border-card-border bg-card-background shadow active:cursor-grabbing", children: float }));
|
|
29
|
+
};
|
|
30
|
+
export const Slider = (props) => {
|
|
31
|
+
const { tooltip, className, defaultValue, value, ...restProps } = props;
|
|
32
|
+
const id = useRef(uuid());
|
|
33
|
+
const array = defaultValue || value || [];
|
|
34
|
+
return (_jsxs(RadixSlider.Root, { ...restProps, defaultValue: defaultValue, value: value, className: css("relative flex h-5 w-full touch-none select-none items-center", className), children: [_jsx(RadixSlider.Track, { className: "relative h-2 grow rounded-full bg-background", children: _jsx(RadixSlider.Range, { className: "absolute h-full rounded-full bg-primary" }) }), array.map((_, i) => (_jsx(Thumb, { tooltip: tooltip ?? false }, `${id.current}-${i}`)))] }));
|
|
35
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../../src/components/form/switch.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8E,MAAM,OAAO,CAAC;AAInG,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../../src/components/form/switch.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8E,MAAM,OAAO,CAAC;AAInG,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,MAAM,mGAqEjB,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef, useEffect, useId, useImperativeHandle, useRef, useState } from "react";
|
|
4
4
|
import { useStableRef } from "../../hooks/use-stable-ref";
|
|
5
5
|
import { css } from "../../lib/dom";
|
|
6
|
-
export const Switch = forwardRef(({ children, container, error, ...props }, ref) => {
|
|
6
|
+
export const Switch = forwardRef(({ children, loading, container, error, ...props }, ref) => {
|
|
7
7
|
const id = useId();
|
|
8
8
|
const [innerChecked, setInnerChecked] = useState(props.checked ?? false);
|
|
9
9
|
const checked = innerChecked;
|
|
@@ -14,11 +14,12 @@ export const Switch = forwardRef(({ children, container, error, ...props }, ref)
|
|
|
14
14
|
if (innerRef.current !== null) {
|
|
15
15
|
if (stableOnChange.current) {
|
|
16
16
|
const onChange = (e) => {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (stableOnChange.current)
|
|
18
|
+
stableOnChange.current(e);
|
|
19
19
|
};
|
|
20
|
-
innerRef.current
|
|
21
|
-
|
|
20
|
+
const ref = innerRef.current;
|
|
21
|
+
ref.addEventListener("change", onChange);
|
|
22
|
+
return () => ref?.removeEventListener("change", onChange);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
}, []);
|
|
@@ -31,5 +32,5 @@ export const Switch = forwardRef(({ children, container, error, ...props }, ref)
|
|
|
31
32
|
innerRef.current.dispatchEvent(new Event("change", { bubbles: true }));
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
|
-
return (_jsxs("fieldset", { className: css("flex flex-col flex-wrap justify-center", container), "data-component": "switch", children: [_jsxs("span", { className: "flex flex-row flex-wrap items-center", children: [_jsx("input", { ...props,
|
|
35
|
+
return (_jsxs("fieldset", { className: css("flex flex-col flex-wrap justify-center", container), "data-component": "switch", disabled: props.disabled || loading, children: [_jsxs("span", { className: "flex flex-row flex-wrap items-center", children: [_jsx("input", { ...props, hidden: true, ref: innerRef, type: "checkbox", checked: checked, id: props.id || id, "data-trigger": "change", "data-checked": checked, disabled: props.disabled || loading, onChange: (e) => setInnerChecked(e.target.checked) }), _jsx("button", { type: "button", role: "switch", onClick: onCheck, "aria-checked": checked, "data-checked": checked, "aria-labelledby": `${id}-label`, disabled: props.disabled || loading, className: "relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-300 ease-in-out focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 data-[checked=false]:bg-input-switch-bg data-[checked=true]:bg-primary", children: _jsx("span", { "aria-hidden": "true", "data-checked": checked, className: "inline-block aspect-square size-5 transform rounded-full shadow ring-0 transition duration-300 ease-in-out data-[checked=false]:translate-x-0 data-[checked=true]:translate-x-5 data-[checked=false]:bg-disabled data-[checked=true]:bg-input-switch" }) }), _jsx("label", { htmlFor: props.id || id, className: "ml-3 inline-block text-sm", id: `${id}-label`, children: _jsx("span", { className: "font-medium text-foreground", children: children }) })] }), _jsx("span", { className: "mt-1 flex-1 whitespace-nowrap text-xs text-danger empty:mt-0 empty:hidden", children: error })] }));
|
|
35
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer-list.d.ts","sourceRoot":"","sources":["../../../../src/components/form/transfer-list.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transfer-list.d.ts","sourceRoot":"","sources":["../../../../src/components/form/transfer-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAG5D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK7C,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IAC/B,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC,CAAC;IACnB,SAAS,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;IACzB,SAAS,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;CAC5B,CAAC;AAWF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,OAAO,iBAAiB,CAAC,CAAC,CAAC,4CAgC1F,CAAC"}
|
|
@@ -26,6 +26,7 @@ export * from "./form/input-field";
|
|
|
26
26
|
export * from "./form/multi-select";
|
|
27
27
|
export * from "./form/radiobox";
|
|
28
28
|
export * from "./form/select";
|
|
29
|
+
export * from "./form/slider";
|
|
29
30
|
export * from "./form/switch";
|
|
30
31
|
export * from "./form/task-list";
|
|
31
32
|
export * from "./form/textarea";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,c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B,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC7H,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -26,6 +26,7 @@ export * from "./form/input-field";
|
|
|
26
26
|
export * from "./form/multi-select";
|
|
27
27
|
export * from "./form/radiobox";
|
|
28
28
|
export * from "./form/select";
|
|
29
|
+
export * from "./form/slider";
|
|
29
30
|
export * from "./form/switch";
|
|
30
31
|
export * from "./form/task-list";
|
|
31
32
|
export * from "./form/textarea";
|