@godxjp/ui 13.2.1 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/index.js +4 -4
- package/dist/{checkbox-DKaBna6z.d.ts → checkbox-YzUqZTuZ.d.ts} +1 -1
- package/dist/{chunk-HBOL5LSC.js → chunk-2XH6QAOC.js} +1 -1
- package/dist/{chunk-FJBVDJGL.js → chunk-36ORTEGC.js} +1 -1
- package/dist/{chunk-SISAM4JZ.js → chunk-3JIPRB2T.js} +1 -1
- package/dist/{chunk-QD3YG56T.js → chunk-46UVXYPU.js} +1 -1
- package/dist/{chunk-H2TX3OPW.js → chunk-6EBULOWM.js} +1 -1
- package/dist/{chunk-XY2QN4VR.js → chunk-BIC6D4EL.js} +2 -2
- package/dist/{chunk-XGXI52Z7.js → chunk-BTTKHJMC.js} +1 -1
- package/dist/{chunk-E6J7ZTDM.js → chunk-CA247VOA.js} +25 -3
- package/dist/{chunk-NXF64JCT.js → chunk-CLEBTIY3.js} +2 -2
- package/dist/{chunk-ZFBIKJSJ.js → chunk-E2CTBKYL.js} +1 -1
- package/dist/{chunk-GDHDJAVB.js → chunk-HOQSAUHZ.js} +1 -1
- package/dist/{chunk-MQ5F4T5A.js → chunk-IHNZCBES.js} +4 -4
- package/dist/{chunk-Z37463ZK.js → chunk-IRPZJKLU.js} +19 -3
- package/dist/{chunk-JEIUEOTJ.js → chunk-ITOHGSPS.js} +12 -0
- package/dist/chunk-IYSGELQC.js +467 -0
- package/dist/{chunk-SVJK3LBZ.js → chunk-JCDLEXBB.js} +2 -2
- package/dist/{chunk-LEVFHRHU.js → chunk-LCKET5WL.js} +3 -3
- package/dist/{chunk-C6OEAQTO.js → chunk-LIOHE3RU.js} +1 -1
- package/dist/{chunk-74OPJG3N.js → chunk-PXOPMYPJ.js} +4 -4
- package/dist/{chunk-ZKUB7DHO.js → chunk-QEHMSZBQ.js} +3 -3
- package/dist/{chunk-UVJE3FYT.js → chunk-QHS4U3SS.js} +3 -3
- package/dist/{chunk-DEUHS5A2.js → chunk-QRCLMU35.js} +1 -1
- package/dist/{chunk-JW34DXZ3.js → chunk-QVLCFPKF.js} +3 -3
- package/dist/{chunk-33AJDSML.js → chunk-RR2SSSQS.js} +2 -2
- package/dist/{chunk-LF7XRNCF.js → chunk-UVMHSC5Q.js} +4 -4
- package/dist/{chunk-4GZQHBHV.js → chunk-WW47N4ID.js} +2 -2
- package/dist/{chunk-5NIGHXT5.js → chunk-YY5PUFBL.js} +4 -4
- package/dist/components/admin/index.d.ts +9 -9
- package/dist/components/admin/index.js +22 -22
- package/dist/components/data-display/badge.d.ts +1 -1
- package/dist/components/data-display/badge.js +3 -3
- package/dist/components/data-display/card.d.ts +2 -2
- package/dist/components/data-display/carousel.js +3 -3
- package/dist/components/data-display/index.d.ts +4 -4
- package/dist/components/data-display/index.js +7 -7
- package/dist/components/data-entry/calendar.d.ts +3 -3
- package/dist/components/data-entry/calendar.js +2 -2
- package/dist/components/data-entry/cascader.d.ts +3 -3
- package/dist/components/data-entry/cascader.js +4 -4
- package/dist/components/data-entry/checkbox.d.ts +4 -4
- package/dist/components/data-entry/color-picker.d.ts +3 -3
- package/dist/components/data-entry/color-picker.js +3 -3
- package/dist/components/data-entry/date-picker.d.ts +3 -3
- package/dist/components/data-entry/date-picker.js +5 -5
- package/dist/components/data-entry/date-range-picker.d.ts +3 -3
- package/dist/components/data-entry/date-range-picker.js +5 -5
- package/dist/components/data-entry/index.d.ts +23 -12
- package/dist/components/data-entry/index.js +18 -18
- package/dist/components/data-entry/radio.d.ts +3 -3
- package/dist/components/data-entry/select.d.ts +3 -3
- package/dist/components/data-entry/select.js +4 -4
- package/dist/components/data-entry/slider.d.ts +3 -3
- package/dist/components/data-entry/switch.d.ts +3 -3
- package/dist/components/data-entry/time-input.js +2 -2
- package/dist/components/data-entry/time-picker.d.ts +3 -3
- package/dist/components/data-entry/time-picker.js +4 -4
- package/dist/components/data-entry/transfer.d.ts +4 -4
- package/dist/components/data-entry/transfer.js +5 -5
- package/dist/components/data-entry/tree-select.d.ts +3 -3
- package/dist/components/data-entry/tree-select.js +4 -4
- package/dist/components/data-entry/upload.d.ts +4 -4
- package/dist/components/data-entry/upload.js +6 -6
- package/dist/components/data-grid/index.js +5 -5
- package/dist/components/feedback/alert.d.ts +3 -3
- package/dist/components/feedback/alert.js +5 -5
- package/dist/components/feedback/dialog.d.ts +2 -2
- package/dist/components/feedback/dialog.js +4 -4
- package/dist/components/feedback/index.d.ts +2 -2
- package/dist/components/feedback/index.js +6 -6
- package/dist/components/feedback/sheet.d.ts +1 -1
- package/dist/components/general/button.d.ts +5 -3
- package/dist/components/general/button.js +1 -1
- package/dist/components/general/index.d.ts +3 -3
- package/dist/components/general/index.js +1 -1
- package/dist/components/layout/index.js +4 -4
- package/dist/components/navigation/index.d.ts +4 -4
- package/dist/components/navigation/index.js +7 -7
- package/dist/components/navigation/pagination.d.ts +3 -3
- package/dist/components/navigation/pagination.js +5 -5
- package/dist/components/navigation/steps.d.ts +4 -4
- package/dist/components/navigation/steps.js +3 -3
- package/dist/components/query/index.d.ts +3 -3
- package/dist/components/query/index.js +5 -5
- package/dist/components/ui/index.d.ts +7 -7
- package/dist/components/ui/index.js +21 -21
- package/dist/{data-display.prop-BCC2zOTq.d.ts → data-display.prop-CT0nVMdp.d.ts} +2 -2
- package/dist/{data-entry.prop-BGlwRXlJ.d.ts → data-entry.prop-DA61KfFl.d.ts} +39 -3
- package/dist/{data-table-B6HC3EFK.d.ts → data-table-DRr70ULe.d.ts} +3 -3
- package/dist/{data.prop-H9nROsUg.d.ts → data.prop-D0UEEczj.d.ts} +1 -1
- package/dist/{feedback.prop-sEx89LTF.d.ts → feedback.prop-CHlHDYZK.d.ts} +1 -1
- package/dist/{filter-bar-DPMQmIpX.d.ts → filter-bar-DoDtwYrr.d.ts} +1 -1
- package/dist/{general.prop-4ERae5Sj.d.ts → general.prop-CBQ_KVtR.d.ts} +11 -4
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.js +2 -2
- package/dist/index.d.ts +9 -9
- package/dist/index.js +29 -29
- package/dist/{interaction.prop-B44hePpl.d.ts → interaction.prop-DD46aTro.d.ts} +4 -3
- package/dist/lib/datetime/index.js +1 -1
- package/dist/{navigation.prop-DMbjEig7.d.ts → navigation.prop-FCsOVGrP.d.ts} +1 -1
- package/dist/props/components/index.d.ts +8 -8
- package/dist/props/index.d.ts +8 -8
- package/dist/props/index.js +2 -2
- package/dist/props/registry.d.ts +8 -3
- package/dist/props/registry.js +1 -1
- package/dist/props/vocabulary/index.d.ts +2 -2
- package/dist/{query.prop-cp6fEgOD.d.ts → query.prop-CsRuaXNb.d.ts} +1 -1
- package/dist/{search-input-CxGW8_7q.d.ts → search-input-BNOUeTiM.d.ts} +1 -1
- package/dist/styles/control.css +64 -0
- package/dist/styles/text-layout.css +12 -3
- package/dist/tokens/foundation.css +4 -3
- package/package.json +1 -1
- package/dist/chunk-ZPHIXXTK.js +0 -257
package/dist/styles/control.css
CHANGED
|
@@ -768,3 +768,67 @@
|
|
|
768
768
|
font-size: var(--font-size-sm);
|
|
769
769
|
color: inherit;
|
|
770
770
|
}
|
|
771
|
+
|
|
772
|
+
/* NumberInput — spinbutton: composed Input + leading/trailing affix + stepper Buttons.
|
|
773
|
+
`data-size` remaps the --control-height tier so the inner .ui-control field tracks it. */
|
|
774
|
+
.ui-number-input {
|
|
775
|
+
position: relative;
|
|
776
|
+
display: inline-flex;
|
|
777
|
+
align-items: stretch;
|
|
778
|
+
inline-size: 100%;
|
|
779
|
+
}
|
|
780
|
+
.ui-number-input[data-size="xs"] {
|
|
781
|
+
--control-height: var(--control-height-xs);
|
|
782
|
+
}
|
|
783
|
+
.ui-number-input[data-size="sm"] {
|
|
784
|
+
--control-height: var(--control-height-sm);
|
|
785
|
+
}
|
|
786
|
+
.ui-number-input[data-size="lg"] {
|
|
787
|
+
--control-height: var(--control-height-lg);
|
|
788
|
+
}
|
|
789
|
+
/* Reserve room on the trailing edge for the stacked steppers (logical inline-end). */
|
|
790
|
+
.ui-number-input-field {
|
|
791
|
+
inline-size: 100%;
|
|
792
|
+
text-align: end;
|
|
793
|
+
padding-inline-end: calc(var(--control-height) + var(--space-2));
|
|
794
|
+
}
|
|
795
|
+
/* A leading/trailing decorative affix (¥, %) — overlays inside the field. */
|
|
796
|
+
.ui-number-input-affix {
|
|
797
|
+
position: absolute;
|
|
798
|
+
inset-block: 0;
|
|
799
|
+
display: inline-flex;
|
|
800
|
+
align-items: center;
|
|
801
|
+
color: hsl(var(--muted-foreground));
|
|
802
|
+
font-size: var(--font-size-sm);
|
|
803
|
+
pointer-events: none;
|
|
804
|
+
}
|
|
805
|
+
.ui-number-input-affix:first-of-type {
|
|
806
|
+
inset-inline-start: var(--control-padding-x);
|
|
807
|
+
}
|
|
808
|
+
/* With a leading affix, pad the field's inline-start so digits don't sit under it. */
|
|
809
|
+
.ui-number-input:has(.ui-number-input-affix:first-of-type) .ui-number-input-field {
|
|
810
|
+
padding-inline-start: calc(var(--control-padding-x) + 1.25rem);
|
|
811
|
+
}
|
|
812
|
+
.ui-number-input-affix:last-of-type {
|
|
813
|
+
inset-inline-end: calc(var(--control-height) + var(--space-2));
|
|
814
|
+
}
|
|
815
|
+
.ui-number-input-steppers {
|
|
816
|
+
position: absolute;
|
|
817
|
+
inset-inline-end: var(--space-1);
|
|
818
|
+
inset-block: 0;
|
|
819
|
+
display: inline-flex;
|
|
820
|
+
flex-direction: column;
|
|
821
|
+
justify-content: center;
|
|
822
|
+
gap: 0.0625rem;
|
|
823
|
+
pointer-events: none;
|
|
824
|
+
}
|
|
825
|
+
.ui-number-input-step {
|
|
826
|
+
pointer-events: auto;
|
|
827
|
+
block-size: calc(var(--control-height) / 2 - 0.1875rem);
|
|
828
|
+
min-block-size: 0;
|
|
829
|
+
inline-size: 1.5rem;
|
|
830
|
+
}
|
|
831
|
+
.ui-number-input-step svg {
|
|
832
|
+
inline-size: 0.75rem;
|
|
833
|
+
block-size: 0.75rem;
|
|
834
|
+
}
|
|
@@ -29,16 +29,25 @@
|
|
|
29
29
|
[data-slot="text"][data-size="xl"] {
|
|
30
30
|
font-size: var(--font-size-xl);
|
|
31
31
|
}
|
|
32
|
+
[data-slot="text"][data-size="2xl"] {
|
|
33
|
+
font-size: var(--font-size-2xl);
|
|
34
|
+
}
|
|
32
35
|
|
|
33
|
-
/* Weight —
|
|
36
|
+
/* Weight — the dxs-kintai canon (400 body · 500 heading/label · 700 emphasis). No 600. */
|
|
34
37
|
[data-slot="text"][data-weight="regular"] {
|
|
35
38
|
font-weight: var(--font-weight-normal);
|
|
36
39
|
}
|
|
37
40
|
[data-slot="text"][data-weight="medium"] {
|
|
38
41
|
font-weight: var(--font-weight-medium);
|
|
39
42
|
}
|
|
40
|
-
[data-slot="text"][data-weight="
|
|
41
|
-
font-weight: var(--font-weight-
|
|
43
|
+
[data-slot="text"][data-weight="bold"] {
|
|
44
|
+
font-weight: var(--font-weight-bold);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* code / kbd render monospace by default (the natural expectation for `as="code"`). */
|
|
48
|
+
code[data-slot="text"],
|
|
49
|
+
kbd[data-slot="text"] {
|
|
50
|
+
font-family: var(--font-family-mono, ui-monospace, "SFMono-Regular", monospace);
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
/* Tone + Heading tone — semantic foreground tokens. */
|
|
@@ -130,10 +130,11 @@
|
|
|
130
130
|
|
|
131
131
|
--font-weight-normal: 400;
|
|
132
132
|
--font-weight-medium: 500;
|
|
133
|
-
/* dxs-kintai uses three weights only
|
|
134
|
-
* (ambiguous between 500 and 700) — the legacy "semibold" token collapses to
|
|
135
|
-
*
|
|
133
|
+
/* dxs-kintai uses three weights only: 400 body · 500 heading/label · 700 emphasis. 600 is
|
|
134
|
+
* forbidden (ambiguous between 500 and 700) — the legacy "semibold" token collapses to medium
|
|
135
|
+
* so any remaining reference renders at 500. `bold` is the 700 emphasis weight. */
|
|
136
136
|
--font-weight-semibold: 500;
|
|
137
|
+
--font-weight-bold: 700;
|
|
137
138
|
--line-height-tight: 1.25;
|
|
138
139
|
--line-height-normal: 1.5;
|
|
139
140
|
--line-height-body: 1.7;
|
package/package.json
CHANGED
package/dist/chunk-ZPHIXXTK.js
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { Input } from './chunk-BNXPDUO4.js';
|
|
2
|
-
import { useTranslation } from './chunk-H2TX3OPW.js';
|
|
3
|
-
import { cn } from './chunk-U7N2A7A3.js';
|
|
4
|
-
import * as React2 from 'react';
|
|
5
|
-
import { EyeOff, Eye, Minus, Star, X } from 'lucide-react';
|
|
6
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
|
-
import { OTPInput, OTPInputContext } from 'input-otp';
|
|
8
|
-
|
|
9
|
-
var PasswordInput = React2.forwardRef(
|
|
10
|
-
({ className, ...props }, ref) => {
|
|
11
|
-
const { t } = useTranslation();
|
|
12
|
-
const [visible, setVisible] = React2.useState(false);
|
|
13
|
-
return /* @__PURE__ */ jsxs("div", { className: "ui-password-input", "data-slot": "password-input", children: [
|
|
14
|
-
/* @__PURE__ */ jsx(
|
|
15
|
-
Input,
|
|
16
|
-
{
|
|
17
|
-
ref,
|
|
18
|
-
type: visible ? "text" : "password",
|
|
19
|
-
className: cn("ui-password-input-field", className),
|
|
20
|
-
...props
|
|
21
|
-
}
|
|
22
|
-
),
|
|
23
|
-
/* @__PURE__ */ jsx(
|
|
24
|
-
"button",
|
|
25
|
-
{
|
|
26
|
-
type: "button",
|
|
27
|
-
className: "ui-password-input-toggle",
|
|
28
|
-
onClick: () => setVisible((v) => !v),
|
|
29
|
-
"aria-label": visible ? t("ui.passwordInput.hide") : t("ui.passwordInput.show"),
|
|
30
|
-
"aria-pressed": visible,
|
|
31
|
-
children: visible ? /* @__PURE__ */ jsx(EyeOff, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(Eye, { "aria-hidden": "true" })
|
|
32
|
-
}
|
|
33
|
-
)
|
|
34
|
-
] });
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
PasswordInput.displayName = "PasswordInput";
|
|
38
|
-
var InputOTP = React2.forwardRef(({ className, containerClassName, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
39
|
-
OTPInput,
|
|
40
|
-
{
|
|
41
|
-
ref,
|
|
42
|
-
"data-slot": "input-otp",
|
|
43
|
-
containerClassName: cn("ui-otp-container", containerClassName),
|
|
44
|
-
className: cn("ui-otp-input", className),
|
|
45
|
-
...props
|
|
46
|
-
}
|
|
47
|
-
));
|
|
48
|
-
InputOTP.displayName = "InputOTP";
|
|
49
|
-
var InputOTPGroup = React2.forwardRef(
|
|
50
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
51
|
-
"div",
|
|
52
|
-
{
|
|
53
|
-
ref,
|
|
54
|
-
"data-slot": "input-otp-group",
|
|
55
|
-
className: cn("ui-otp-group", className),
|
|
56
|
-
...props
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
);
|
|
60
|
-
InputOTPGroup.displayName = "InputOTPGroup";
|
|
61
|
-
var InputOTPSlot = React2.forwardRef(({ index, className, ...props }, ref) => {
|
|
62
|
-
const context = React2.useContext(OTPInputContext);
|
|
63
|
-
const slot = context.slots[index] ?? { char: null, hasFakeCaret: false, isActive: false };
|
|
64
|
-
return /* @__PURE__ */ jsxs(
|
|
65
|
-
"div",
|
|
66
|
-
{
|
|
67
|
-
ref,
|
|
68
|
-
"data-slot": "input-otp-slot",
|
|
69
|
-
"data-active": slot.isActive || void 0,
|
|
70
|
-
className: cn("ui-otp-slot", className),
|
|
71
|
-
...props,
|
|
72
|
-
children: [
|
|
73
|
-
slot.char,
|
|
74
|
-
slot.hasFakeCaret ? /* @__PURE__ */ jsx("div", { className: "ui-otp-caret-wrapper", "aria-hidden": "true", children: /* @__PURE__ */ jsx("div", { className: "ui-otp-caret" }) }) : null
|
|
75
|
-
]
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
InputOTPSlot.displayName = "InputOTPSlot";
|
|
80
|
-
var InputOTPSeparator = React2.forwardRef(({ ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, "data-slot": "input-otp-separator", role: "separator", ...props, children: /* @__PURE__ */ jsx(Minus, { className: "ui-otp-separator-icon", "aria-hidden": "true" }) }));
|
|
81
|
-
InputOTPSeparator.displayName = "InputOTPSeparator";
|
|
82
|
-
var Rating = React2.forwardRef(
|
|
83
|
-
({
|
|
84
|
-
value,
|
|
85
|
-
defaultValue = 0,
|
|
86
|
-
onValueChange,
|
|
87
|
-
max = 5,
|
|
88
|
-
readOnly,
|
|
89
|
-
disabled,
|
|
90
|
-
name,
|
|
91
|
-
className,
|
|
92
|
-
...rest
|
|
93
|
-
}, ref) => {
|
|
94
|
-
const { t } = useTranslation();
|
|
95
|
-
const [internal, setInternal] = React2.useState(defaultValue);
|
|
96
|
-
const current = value ?? internal;
|
|
97
|
-
const [hover, setHover] = React2.useState(null);
|
|
98
|
-
const display = hover ?? current;
|
|
99
|
-
const interactive = !readOnly && !disabled;
|
|
100
|
-
const select = (next) => {
|
|
101
|
-
if (!interactive) return;
|
|
102
|
-
if (value === void 0) setInternal(next);
|
|
103
|
-
onValueChange?.(next);
|
|
104
|
-
};
|
|
105
|
-
const focusableStar = current > 0 ? current : 1;
|
|
106
|
-
const onKeyDown = (e, star) => {
|
|
107
|
-
if (!interactive) return;
|
|
108
|
-
let next = null;
|
|
109
|
-
switch (e.key) {
|
|
110
|
-
case "ArrowRight":
|
|
111
|
-
case "ArrowUp":
|
|
112
|
-
next = Math.min(max, star + 1);
|
|
113
|
-
break;
|
|
114
|
-
case "ArrowLeft":
|
|
115
|
-
case "ArrowDown":
|
|
116
|
-
next = Math.max(1, star - 1);
|
|
117
|
-
break;
|
|
118
|
-
case "Home":
|
|
119
|
-
next = 1;
|
|
120
|
-
break;
|
|
121
|
-
case "End":
|
|
122
|
-
next = max;
|
|
123
|
-
break;
|
|
124
|
-
default:
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
e.preventDefault();
|
|
128
|
-
select(next);
|
|
129
|
-
};
|
|
130
|
-
return /* @__PURE__ */ jsxs(
|
|
131
|
-
"div",
|
|
132
|
-
{
|
|
133
|
-
ref,
|
|
134
|
-
role: "radiogroup",
|
|
135
|
-
"data-slot": "rating",
|
|
136
|
-
className: cn("ui-rating", className),
|
|
137
|
-
"aria-label": rest["aria-label"] ?? t("ui.rating.ariaLabel"),
|
|
138
|
-
children: [
|
|
139
|
-
Array.from({ length: max }, (_, i) => i + 1).map((star) => /* @__PURE__ */ jsx(
|
|
140
|
-
"button",
|
|
141
|
-
{
|
|
142
|
-
type: "button",
|
|
143
|
-
role: "radio",
|
|
144
|
-
"aria-checked": current === star,
|
|
145
|
-
"aria-label": t("ui.rating.starLabel", { star, max }),
|
|
146
|
-
disabled: disabled || readOnly,
|
|
147
|
-
tabIndex: interactive && star === focusableStar ? 0 : -1,
|
|
148
|
-
className: cn("ui-rating-star", star <= display && "ui-rating-star-filled"),
|
|
149
|
-
onMouseEnter: () => interactive && setHover(star),
|
|
150
|
-
onMouseLeave: () => setHover(null),
|
|
151
|
-
onClick: () => select(star),
|
|
152
|
-
onKeyDown: (e) => onKeyDown(e, star),
|
|
153
|
-
children: /* @__PURE__ */ jsx(Star, { "aria-hidden": "true" })
|
|
154
|
-
},
|
|
155
|
-
star
|
|
156
|
-
)),
|
|
157
|
-
name ? /* @__PURE__ */ jsx("input", { type: "hidden", name, value: current }) : null
|
|
158
|
-
]
|
|
159
|
-
}
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
);
|
|
163
|
-
Rating.displayName = "Rating";
|
|
164
|
-
var TagInput = React2.forwardRef(
|
|
165
|
-
({
|
|
166
|
-
value,
|
|
167
|
-
defaultValue = [],
|
|
168
|
-
onValueChange,
|
|
169
|
-
placeholder,
|
|
170
|
-
disabled,
|
|
171
|
-
name,
|
|
172
|
-
className,
|
|
173
|
-
id,
|
|
174
|
-
"aria-label": ariaLabel
|
|
175
|
-
}, ref) => {
|
|
176
|
-
const { t } = useTranslation();
|
|
177
|
-
const [internal, setInternal] = React2.useState(defaultValue);
|
|
178
|
-
const tags = value ?? internal;
|
|
179
|
-
const [draft, setDraft] = React2.useState("");
|
|
180
|
-
const commit = (next) => {
|
|
181
|
-
if (value === void 0) setInternal(next);
|
|
182
|
-
onValueChange?.(next);
|
|
183
|
-
};
|
|
184
|
-
const add = (raw) => {
|
|
185
|
-
const tag = raw.trim();
|
|
186
|
-
if (!tag || tags.includes(tag)) return;
|
|
187
|
-
commit([...tags, tag]);
|
|
188
|
-
};
|
|
189
|
-
const removeAt = (i) => commit(tags.filter((_, idx) => idx !== i));
|
|
190
|
-
const onKeyDown = (e) => {
|
|
191
|
-
if (e.key === "Enter" || e.key === ",") {
|
|
192
|
-
e.preventDefault();
|
|
193
|
-
add(draft);
|
|
194
|
-
setDraft("");
|
|
195
|
-
} else if (e.key === "Backspace" && draft === "" && tags.length > 0) {
|
|
196
|
-
removeAt(tags.length - 1);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
return /* @__PURE__ */ jsxs(
|
|
200
|
-
"div",
|
|
201
|
-
{
|
|
202
|
-
"data-slot": "tag-input",
|
|
203
|
-
className: cn("ui-tag-input", disabled && "ui-tag-input-disabled", className),
|
|
204
|
-
children: [
|
|
205
|
-
tags.length > 0 ? /* @__PURE__ */ jsx("ul", { role: "list", className: "ui-tag-input-list", "data-slot": "tag-input-list", children: tags.map((tag, i) => /* @__PURE__ */ jsxs(
|
|
206
|
-
"li",
|
|
207
|
-
{
|
|
208
|
-
role: "listitem",
|
|
209
|
-
className: "ui-tag-input-chip",
|
|
210
|
-
"data-slot": "tag-input-chip",
|
|
211
|
-
children: [
|
|
212
|
-
tag,
|
|
213
|
-
!disabled ? /* @__PURE__ */ jsx(
|
|
214
|
-
"button",
|
|
215
|
-
{
|
|
216
|
-
type: "button",
|
|
217
|
-
className: "ui-tag-input-remove",
|
|
218
|
-
"aria-label": t("ui.tagInput.removeTag", { tag }),
|
|
219
|
-
onClick: () => removeAt(i),
|
|
220
|
-
children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true" })
|
|
221
|
-
}
|
|
222
|
-
) : null
|
|
223
|
-
]
|
|
224
|
-
},
|
|
225
|
-
tag
|
|
226
|
-
)) }) : null,
|
|
227
|
-
/* @__PURE__ */ jsx(
|
|
228
|
-
"input",
|
|
229
|
-
{
|
|
230
|
-
ref,
|
|
231
|
-
id,
|
|
232
|
-
type: "text",
|
|
233
|
-
className: "ui-tag-input-field",
|
|
234
|
-
value: draft,
|
|
235
|
-
placeholder: tags.length === 0 ? placeholder : void 0,
|
|
236
|
-
disabled,
|
|
237
|
-
"aria-label": ariaLabel ?? t("ui.tagInput.inputLabel"),
|
|
238
|
-
onChange: (e) => setDraft(e.target.value),
|
|
239
|
-
onKeyDown,
|
|
240
|
-
onBlur: () => {
|
|
241
|
-
if (draft.trim()) {
|
|
242
|
-
add(draft);
|
|
243
|
-
setDraft("");
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
),
|
|
248
|
-
/* @__PURE__ */ jsx("span", { "aria-live": "polite", className: "sr-only", "data-slot": "tag-input-status", children: t("ui.tagInput.tagCount", { count: tags.length }) }),
|
|
249
|
-
name ? /* @__PURE__ */ jsx("input", { type: "hidden", name, value: tags.join(",") }) : null
|
|
250
|
-
]
|
|
251
|
-
}
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
);
|
|
255
|
-
TagInput.displayName = "TagInput";
|
|
256
|
-
|
|
257
|
-
export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, PasswordInput, Rating, TagInput };
|