wimui 0.6.0 → 0.7.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/components/_internal/FeedbackIcon.cjs +1 -1
- package/dist/components/_internal/FeedbackIcon.js +18 -23
- package/dist/components/_internal/FieldLabelContent.cjs +1 -1
- package/dist/components/_internal/FieldLabelContent.js +1 -0
- package/dist/components/data-display/Card/Card.cjs +1 -1
- package/dist/components/data-display/Card/Card.js +30 -25
- package/dist/components/data-display/Card/styled-values.cjs +2 -0
- package/dist/components/data-display/Card/styled-values.d.ts +18 -0
- package/dist/components/data-display/Card/styled-values.js +21 -0
- package/dist/components/feedback/Alert/Alert.cjs +1 -1
- package/dist/components/feedback/Alert/Alert.d.ts +11 -4
- package/dist/components/feedback/Alert/Alert.js +1 -1
- package/dist/components/feedback/Result/Result.cjs +1 -1
- package/dist/components/feedback/Result/Result.js +39 -37
- package/dist/components/form/Dropzone/Dropzone.cjs +1 -1
- package/dist/components/form/Dropzone/Dropzone.d.ts +10 -1
- package/dist/components/form/Dropzone/Dropzone.js +40 -40
- package/dist/components/form/Fieldset/Fieldset.cjs +1 -1
- package/dist/components/form/Fieldset/Fieldset.d.ts +9 -2
- package/dist/components/form/Fieldset/Fieldset.js +1 -1
- package/dist/components/form/Fieldset/fieldset.module.cjs +1 -1
- package/dist/components/form/Fieldset/fieldset.module.js +4 -3
- package/dist/components/form/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/form/FileUpload/FileUpload.d.ts +10 -1
- package/dist/components/form/FileUpload/FileUpload.js +49 -45
- package/dist/components/form/Input/Input.cjs +1 -1
- package/dist/components/form/Input/Input.d.ts +6 -0
- package/dist/components/form/Input/Input.js +65 -63
- package/dist/components/form/InputBase/InputBase.cjs +1 -1
- package/dist/components/form/InputBase/InputBase.d.ts +9 -1
- package/dist/components/form/InputBase/InputBase.js +31 -25
- package/dist/components/form/InputBase/input-base.module.cjs +1 -1
- package/dist/components/form/InputBase/input-base.module.js +9 -7
- package/dist/components/form/OtpInput/OtpInput.cjs +1 -1
- package/dist/components/form/OtpInput/OtpInput.d.ts +16 -2
- package/dist/components/form/OtpInput/OtpInput.js +53 -54
- package/dist/components/form/SegmentedControl/segmented-control.module.cjs +1 -1
- package/dist/components/form/SegmentedControl/segmented-control.module.js +1 -1
- package/dist/components/media/Icon/Icon.cjs +1 -1
- package/dist/components/media/Icon/Icon.d.ts +9 -4
- package/dist/components/media/Icon/Icon.js +27 -11
- package/dist/components/media/Icon/icon.module.cjs +1 -1
- package/dist/components/media/Icon/icon.module.js +10 -10
- package/dist/components/media/Image/Image.cjs +1 -1
- package/dist/components/media/Image/Image.js +1 -1
- package/dist/components/typography/Code/code.module.cjs +1 -1
- package/dist/components/typography/Code/code.module.js +1 -1
- package/dist/components/typography/Text/Text.cjs +1 -1
- package/dist/components/typography/Text/Text.d.ts +24 -0
- package/dist/components/typography/Text/Text.js +10 -10
- package/dist/components/typography/Text/text.module.cjs +1 -1
- package/dist/components/typography/Text/text.module.js +12 -10
- package/dist/llms-full.txt +68 -6
- package/dist/llms.txt +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/warn-unstyled-value.cjs +2 -0
- package/dist/utilities/warn-unstyled-value.d.ts +17 -0
- package/dist/utilities/warn-unstyled-value.js +4 -0
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +1 -1
|
@@ -1,62 +1,66 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useWimTranslation as e } from "../../../i18n/useWimTranslation.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import r from "
|
|
6
|
-
import i
|
|
7
|
-
import s from "
|
|
8
|
-
import
|
|
3
|
+
import { VisuallyHidden as t } from "../../layout/VisuallyHidden/VisuallyHidden.js";
|
|
4
|
+
import { Button as n } from "../Button/Button.js";
|
|
5
|
+
import { FieldTemplate as r } from "../FieldTemplate/FieldTemplate.js";
|
|
6
|
+
import i from "./file-upload.module.js";
|
|
7
|
+
import a, { useRef as o, useState as s } from "react";
|
|
8
|
+
import c from "classnames";
|
|
9
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/form/FileUpload/FileUpload.tsx
|
|
10
|
-
var
|
|
11
|
-
let { t:
|
|
12
|
-
|
|
13
|
-
},
|
|
11
|
+
var d = ({ label: d, buttonLabel: f, noFileLabel: p, accept: m, multiple: h = !1, disabled: g = !1, value: _, onChange: v, className: y, iconName: b, iconPosition: x, size: S = "md", error: C, required: w, layout: T = "vertical" }) => {
|
|
12
|
+
let { t: E } = e("form"), D = `wim-fileupload-${a.useId()}`, O = d ? `${D}-label` : void 0, k = C ? `${D}-error` : void 0, A = w ? `${D}-required` : void 0, j = [k, A].filter(Boolean).join(" ") || void 0, M = o(null), [N, P] = s(null), F = () => {
|
|
13
|
+
M.current?.click();
|
|
14
|
+
}, I = (e) => {
|
|
14
15
|
let t = e.target.files;
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
return /* @__PURE__ */
|
|
18
|
-
label:
|
|
19
|
-
error:
|
|
20
|
-
required:
|
|
21
|
-
layout:
|
|
22
|
-
labelId:
|
|
23
|
-
errorId:
|
|
24
|
-
className:
|
|
25
|
-
children: /* @__PURE__ */
|
|
26
|
-
className:
|
|
16
|
+
P(t), v && v(t);
|
|
17
|
+
}, L = _ === void 0 ? N ? Array.from(N).map((e) => e.name) : [] : _, R = L.length > 0 ? L.join(", ") : p ?? E("fileupload.no_file");
|
|
18
|
+
return /* @__PURE__ */ l(r, {
|
|
19
|
+
label: d,
|
|
20
|
+
error: C,
|
|
21
|
+
required: w,
|
|
22
|
+
layout: T,
|
|
23
|
+
labelId: O,
|
|
24
|
+
errorId: k,
|
|
25
|
+
className: c("wim-file-upload", i.root, i[S], y),
|
|
26
|
+
children: /* @__PURE__ */ u("div", {
|
|
27
|
+
className: i.controls,
|
|
27
28
|
children: [
|
|
28
|
-
/* @__PURE__ */
|
|
29
|
+
/* @__PURE__ */ l("input", {
|
|
29
30
|
type: "file",
|
|
30
|
-
ref:
|
|
31
|
-
accept:
|
|
32
|
-
multiple:
|
|
33
|
-
disabled:
|
|
34
|
-
onChange:
|
|
35
|
-
className:
|
|
31
|
+
ref: M,
|
|
32
|
+
accept: m,
|
|
33
|
+
multiple: h,
|
|
34
|
+
disabled: g,
|
|
35
|
+
onChange: I,
|
|
36
|
+
className: i.input,
|
|
36
37
|
"aria-hidden": "true",
|
|
37
38
|
tabIndex: -1
|
|
38
39
|
}),
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
onClick:
|
|
41
|
-
disabled:
|
|
40
|
+
/* @__PURE__ */ l(n, {
|
|
41
|
+
onClick: F,
|
|
42
|
+
disabled: g,
|
|
42
43
|
variant: "outline",
|
|
43
|
-
icon:
|
|
44
|
-
iconPosition:
|
|
45
|
-
size:
|
|
46
|
-
"aria-labelledby":
|
|
47
|
-
"aria-describedby":
|
|
48
|
-
"aria-
|
|
49
|
-
|
|
50
|
-
children: d ?? w("fileupload.button")
|
|
44
|
+
icon: b,
|
|
45
|
+
iconPosition: x,
|
|
46
|
+
size: S,
|
|
47
|
+
"aria-labelledby": O,
|
|
48
|
+
"aria-describedby": j,
|
|
49
|
+
"aria-invalid": C ? !0 : void 0,
|
|
50
|
+
children: f ?? E("fileupload.button")
|
|
51
51
|
}),
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
|
|
52
|
+
w && /* @__PURE__ */ l(t, {
|
|
53
|
+
id: A,
|
|
54
|
+
children: E("form.required")
|
|
55
|
+
}),
|
|
56
|
+
/* @__PURE__ */ l("span", {
|
|
57
|
+
className: c(i.fileNames, i[S], g && i.disabled),
|
|
58
|
+
"aria-disabled": g || void 0,
|
|
59
|
+
children: R
|
|
56
60
|
})
|
|
57
61
|
]
|
|
58
62
|
})
|
|
59
63
|
});
|
|
60
64
|
};
|
|
61
65
|
//#endregion
|
|
62
|
-
export {
|
|
66
|
+
export { d as FileUpload };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),ee=require("../../../hooks/useMergedRef.cjs"),te=require("../InputBase/InputBase.cjs"),ne=require("../FieldTemplate/FieldTemplate.cjs"),r=require("./input.module.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("classnames");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s=(0,i.forwardRef)(({intent:e=`default`,variant:s=`outline`,fullWidth:c=!1,className:re,disabled:ie,leftIcon:ae,rightIcon:l,leftIconColor:oe,rightIconColor:se,onLeftIconClick:u,onRightIconClick:d,allowClear:f=!1,showPasswordToggle:p=!0,rightIconClassName:m,rightIconRotated:ce,width:h,value:g,defaultValue:le,onChange:_,type:v,label:y,error:b,required:x,layout:S,id:C,inputClassName:w,showPasswordAriaLabel:T,hidePasswordAriaLabel:E,rightIconAriaLabel:D,suffix:O,styles:k,asChild:A=!1,children:j,...M},N)=>{let{t:P}=n.useWimTranslation(`common`),F=T??P(`a11y.show_password`),I=E??P(`a11y.hide_password`),L=D??P(`a11y.right_icon_action`),[R,z]=(0,i.useState)(le??``),[B,V]=(0,i.useState)(!1),H=(0,i.useRef)(null),U=ee.useMergedRef(N,H),W=g!==void 0,G=W?g:R,K=ie,ue=e=>{W||z(e.target.value),_?.(e)},de=()=>{let e=H.current;if(!e)return;let t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set;t?(t.call(e,``),e.dispatchEvent(new Event(`input`,{bubbles:!0}))):(W||z(``),_&&(e.value=``,_({target:e,currentTarget:e}))),W||z(``)},q=()=>{V(e=>!e)},fe=v===`password`&&p,J=[];fe&&J.push({name:B?`EyeOffIcon`:`EyeIcon`,onClick:e=>q(),ariaLabel:B?I:F}),l&&(J.some(e=>e.name===l)||J.push({name:l,onClick:d,color:se,ariaLabel:L,className:m,rotated:ce}));let pe=v===`password`&&B?`text`:v,Y=b?`danger`:e,me=(0,i.useId)(),X=C||`wim-input-${me}`,Z=b?`${X}-error`:void 0,Q=O!=null&&O!==``?`${X}-suffix`:void 0,he=[Z,Q].filter(Boolean).join(` `)||void 0,$=y?`${X}-label`:void 0;return(0,o.jsx)(ne.FieldTemplate,{label:y,error:b,required:x,layout:S,labelId:$,htmlFor:X,errorId:Z,className:re,children:(0,o.jsx)(te.InputBase,{intent:Y,variant:s,fullWidth:c,width:h,disabled:K,leftIcon:ae,leftIconColor:oe,onLeftIconClick:u,rightIcons:J,suffix:O,suffixId:Q,allowClear:f,hasValue:!!G,onClear:de,styles:k,children:(0,o.jsx)(A?t.Root:`input`,{id:X,ref:U,className:(0,a.default)(`wim-input`,r.default.root,r.default[Y],K&&r.default.disabled,r.default[s],w),disabled:K,value:G,onChange:ue,type:pe,"aria-invalid":Y===`danger`,"aria-describedby":he,"aria-labelledby":y?$:void 0,"aria-required":x,...M,children:A?(0,o.jsx)(t.Slottable,{children:j}):null})})})});s.displayName=`Input`,exports.Input=s,exports.default=s;
|
|
@@ -47,6 +47,12 @@ export interface InputProps extends Omit<React.ComponentPropsWithoutRef<"input">
|
|
|
47
47
|
hidePasswordAriaLabel?: string;
|
|
48
48
|
/** Aria label for the right icon button */
|
|
49
49
|
rightIconAriaLabel?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Static text shown after the field, inside the same shell — a unit such as
|
|
52
|
+
* `kg`, `%` or `円`. It is announced with the field via `aria-describedby`,
|
|
53
|
+
* so the unit does not have to be repeated in the label.
|
|
54
|
+
*/
|
|
55
|
+
suffix?: React.ReactNode;
|
|
50
56
|
/** Custom styles for internal parts */
|
|
51
57
|
styles?: React.ComponentProps<typeof InputBase>["styles"];
|
|
52
58
|
/** Whether to render as a child element. */
|
|
@@ -1,78 +1,80 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Root as e, Slottable as t } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
|
|
3
|
-
import { useWimTranslation as
|
|
4
|
-
import { useMergedRef as
|
|
5
|
-
import { InputBase as
|
|
6
|
-
import { FieldTemplate as
|
|
7
|
-
import
|
|
8
|
-
import { forwardRef as
|
|
3
|
+
import { useWimTranslation as n } from "../../../i18n/useWimTranslation.js";
|
|
4
|
+
import { useMergedRef as r } from "../../../hooks/useMergedRef.js";
|
|
5
|
+
import { InputBase as i } from "../InputBase/InputBase.js";
|
|
6
|
+
import { FieldTemplate as a } from "../FieldTemplate/FieldTemplate.js";
|
|
7
|
+
import o from "./input.module.js";
|
|
8
|
+
import { forwardRef as s, useId as ee, useRef as c, useState as l } from "react";
|
|
9
9
|
import u from "classnames";
|
|
10
10
|
import { jsx as d } from "react/jsx-runtime";
|
|
11
11
|
//#region src/components/form/Input/Input.tsx
|
|
12
|
-
var f =
|
|
13
|
-
let { t:
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
let e =
|
|
12
|
+
var f = s(({ intent: s = "default", variant: f = "outline", fullWidth: p = !1, className: m, disabled: h, leftIcon: g, rightIcon: _, leftIconColor: te, rightIconColor: ne, onLeftIconClick: re, onRightIconClick: ie, allowClear: ae = !1, showPasswordToggle: oe = !0, rightIconClassName: se, rightIconRotated: ce, width: le, value: v, defaultValue: ue, onChange: y, type: b, label: x, error: S, required: C, layout: w, id: T, inputClassName: E, showPasswordAriaLabel: D, hidePasswordAriaLabel: O, rightIconAriaLabel: k, suffix: A, styles: j, asChild: M = !1, children: N, ...P }, F) => {
|
|
13
|
+
let { t: I } = n("common"), L = D ?? I("a11y.show_password"), R = O ?? I("a11y.hide_password"), de = k ?? I("a11y.right_icon_action"), [z, B] = l(ue ?? ""), [V, H] = l(!1), U = c(null), fe = r(F, U), W = v !== void 0, G = W ? v : z, K = h, pe = (e) => {
|
|
14
|
+
W || B(e.target.value), y?.(e);
|
|
15
|
+
}, me = () => {
|
|
16
|
+
let e = U.current;
|
|
17
17
|
if (!e) return;
|
|
18
18
|
let t = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")?.set;
|
|
19
|
-
t ? (t.call(e, ""), e.dispatchEvent(new Event("input", { bubbles: !0 }))) : (
|
|
19
|
+
t ? (t.call(e, ""), e.dispatchEvent(new Event("input", { bubbles: !0 }))) : (W || B(""), y && (e.value = "", y({
|
|
20
20
|
target: e,
|
|
21
21
|
currentTarget: e
|
|
22
|
-
}))),
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
name:
|
|
28
|
-
onClick: (e) =>
|
|
29
|
-
ariaLabel:
|
|
30
|
-
}),
|
|
31
|
-
name:
|
|
32
|
-
onClick:
|
|
33
|
-
color:
|
|
34
|
-
ariaLabel:
|
|
35
|
-
className:
|
|
36
|
-
rotated:
|
|
22
|
+
}))), W || B("");
|
|
23
|
+
}, he = () => {
|
|
24
|
+
H((e) => !e);
|
|
25
|
+
}, ge = b === "password" && oe, q = [];
|
|
26
|
+
ge && q.push({
|
|
27
|
+
name: V ? "EyeOffIcon" : "EyeIcon",
|
|
28
|
+
onClick: (e) => he(),
|
|
29
|
+
ariaLabel: V ? R : L
|
|
30
|
+
}), _ && (q.some((e) => e.name === _) || q.push({
|
|
31
|
+
name: _,
|
|
32
|
+
onClick: ie,
|
|
33
|
+
color: ne,
|
|
34
|
+
ariaLabel: de,
|
|
35
|
+
className: se,
|
|
36
|
+
rotated: ce
|
|
37
37
|
}));
|
|
38
|
-
let
|
|
39
|
-
return /* @__PURE__ */ d(
|
|
40
|
-
label:
|
|
41
|
-
error:
|
|
42
|
-
required:
|
|
43
|
-
layout:
|
|
38
|
+
let _e = b === "password" && V ? "text" : b, J = S ? "danger" : s, Y = ee(), X = T || `wim-input-${Y}`, Z = S ? `${X}-error` : void 0, Q = A != null && A !== "" ? `${X}-suffix` : void 0, ve = [Z, Q].filter(Boolean).join(" ") || void 0, $ = x ? `${X}-label` : void 0;
|
|
39
|
+
return /* @__PURE__ */ d(a, {
|
|
40
|
+
label: x,
|
|
41
|
+
error: S,
|
|
42
|
+
required: C,
|
|
43
|
+
layout: w,
|
|
44
44
|
labelId: $,
|
|
45
|
-
htmlFor:
|
|
46
|
-
errorId:
|
|
47
|
-
className:
|
|
48
|
-
children: /* @__PURE__ */ d(
|
|
49
|
-
intent:
|
|
45
|
+
htmlFor: X,
|
|
46
|
+
errorId: Z,
|
|
47
|
+
className: m,
|
|
48
|
+
children: /* @__PURE__ */ d(i, {
|
|
49
|
+
intent: J,
|
|
50
50
|
variant: f,
|
|
51
|
-
fullWidth:
|
|
52
|
-
width:
|
|
53
|
-
disabled:
|
|
54
|
-
leftIcon:
|
|
55
|
-
leftIconColor:
|
|
56
|
-
onLeftIconClick:
|
|
57
|
-
rightIcons:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"aria-
|
|
73
|
-
"aria-
|
|
74
|
-
|
|
75
|
-
|
|
51
|
+
fullWidth: p,
|
|
52
|
+
width: le,
|
|
53
|
+
disabled: K,
|
|
54
|
+
leftIcon: g,
|
|
55
|
+
leftIconColor: te,
|
|
56
|
+
onLeftIconClick: re,
|
|
57
|
+
rightIcons: q,
|
|
58
|
+
suffix: A,
|
|
59
|
+
suffixId: Q,
|
|
60
|
+
allowClear: ae,
|
|
61
|
+
hasValue: !!G,
|
|
62
|
+
onClear: me,
|
|
63
|
+
styles: j,
|
|
64
|
+
children: /* @__PURE__ */ d(M ? e : "input", {
|
|
65
|
+
id: X,
|
|
66
|
+
ref: fe,
|
|
67
|
+
className: u("wim-input", o.root, o[J], K && o.disabled, o[f], E),
|
|
68
|
+
disabled: K,
|
|
69
|
+
value: G,
|
|
70
|
+
onChange: pe,
|
|
71
|
+
type: _e,
|
|
72
|
+
"aria-invalid": J === "danger",
|
|
73
|
+
"aria-describedby": ve,
|
|
74
|
+
"aria-labelledby": x ? $ : void 0,
|
|
75
|
+
"aria-required": C,
|
|
76
|
+
...P,
|
|
77
|
+
children: M ? /* @__PURE__ */ d(t, { children: N }) : null
|
|
76
78
|
})
|
|
77
79
|
})
|
|
78
80
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../media/Icon/Icon.cjs"),r=require("./input-base.module.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("classnames");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s=({children:e,intent:s=`default`,variant:c=`outline`,fullWidth:l=!1,width:u,className:d,disabled:f,leftIcon:p,leftIconColor:m,onLeftIconClick:h,leftIconAriaLabel:g,rightIcons:_=[],
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../media/Icon/Icon.cjs"),r=require("./input-base.module.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("classnames");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s=({children:e,intent:s=`default`,variant:c=`outline`,fullWidth:l=!1,width:u,className:d,disabled:f,leftIcon:p,leftIconColor:m,onLeftIconClick:h,leftIconAriaLabel:g,rightIcons:_=[],suffix:v,suffixId:y,allowClear:b,hasValue:x,onClear:S,clearAriaLabel:C,styles:w})=>{let{t:T}=t.useWimTranslation(`common`),E=g??T(`a11y.left_icon_action`),D=C??T(`a11y.clear_input`),O=typeof u==`string`&&[`xs`,`sm`,`md`,`lg`,`xl`].includes(u),k=i.default.Children.map(e,e=>i.default.isValidElement(e)?i.default.cloneElement(e,{disabled:f?!0:e.props.disabled,className:(0,a.default)(e.props.className,r.default.inner,w?.inner)}):e),A=u!==void 0&&!O&&!l,j=O&&!l?u:void 0,M=e=>f?`disabled`:e||(s===`danger`?`danger`:s===`warning`?`warning`:s===`success`?`success`:`secondary`),N=[..._];b&&x&&!f&&N.push({name:`CloseIcon`,onClick:e=>{e.stopPropagation(),S?.()},ariaLabel:D});let P=j?r.default[`width${j.charAt(0).toUpperCase()}${j.slice(1)}`]:void 0;return(0,o.jsxs)(`div`,{className:(0,a.default)(`wim-input-base`,r.default.root,s&&r.default[s],f&&r.default.disabled,r.default[c],l&&r.default.fullWidth,A&&r.default.hasCustomWidth,P,p&&r.default.hasLeftIcon,(N.length>0||b)&&r.default.hasRightIcon,(N.length>=2||_.length>=1&&b)&&r.default.hasMultipleRightIcons,d,w?.root),style:A?{"--wim-input-width":typeof u==`number`?`${u}px`:u}:void 0,children:[p&&(0,o.jsx)(`div`,{className:(0,a.default)(r.default.icon,r.default.left,h&&r.default.clickable,w?.icon),children:h?(0,o.jsx)(`button`,{type:`button`,onClick:h,className:(0,a.default)(r.default.iconButton,w?.iconButton),"aria-label":E,children:(0,o.jsx)(n.Icon,{name:p,size:`md`,color:M(m)})}):(0,o.jsx)(n.Icon,{name:p,size:`md`,color:M(m)})}),k,v!=null&&v!==``&&(0,o.jsx)(`span`,{id:y,className:(0,a.default)(r.default.suffix,N.length>0&&r.default.suffixClearsIcons),"data-testid":`input-suffix`,children:v}),N.length>0&&(0,o.jsx)(`div`,{className:(0,a.default)(r.default.icons,r.default.right,w?.icons),children:N.map((e,t)=>(0,o.jsx)(`div`,{className:(0,a.default)(r.default.iconItem,e.onClick&&r.default.clickable,e.rotated&&r.default.rotated,e.className,w?.iconItem),children:e.onClick?(0,o.jsx)(`button`,{type:`button`,onClick:e.onClick,className:(0,a.default)(r.default.iconButton,w?.iconButton),"aria-label":e.ariaLabel??T(`a11y.right_icon_action`),children:(0,o.jsx)(n.Icon,{name:e.name,size:`md`,color:M(e.color)})}):(0,o.jsx)(n.Icon,{name:e.name,size:`md`,color:M(e.color)})},`${e.name}-${t}`))})]})};exports.InputBase=s;
|
|
@@ -35,6 +35,14 @@ export type InputBaseProps = {
|
|
|
35
35
|
leftIconAriaLabel?: string;
|
|
36
36
|
/** Icons to display on the right side */
|
|
37
37
|
rightIcons?: InputBaseIcon[];
|
|
38
|
+
/**
|
|
39
|
+
* Static text shown after the control, inside the same shell — a unit such
|
|
40
|
+
* as `kg`, `%` or `円`. It sits in the flex flow, so the control shrinks to
|
|
41
|
+
* make room rather than running underneath it.
|
|
42
|
+
*/
|
|
43
|
+
suffix?: React.ReactNode;
|
|
44
|
+
/** `id` for the suffix, so the control can point `aria-describedby` at it */
|
|
45
|
+
suffixId?: string;
|
|
38
46
|
/** Whether to show a clear button when value is present */
|
|
39
47
|
allowClear?: boolean;
|
|
40
48
|
/** Whether the field currently has a value (controls clear button visibility) */
|
|
@@ -57,4 +65,4 @@ export type InputBaseProps = {
|
|
|
57
65
|
* フォーム入力コンポーネント(Input, SearchInput, Select等)の外殻となる共用語コンポーネント。
|
|
58
66
|
* prefix/suffix(アイコン)や clearable(クリアボタン)の配置とレイアウトを統一します。
|
|
59
67
|
*/
|
|
60
|
-
export declare const InputBase: ({ children, intent, variant, fullWidth, width, className, disabled: isDisabled, leftIcon, leftIconColor, onLeftIconClick, leftIconAriaLabel, rightIcons, allowClear, hasValue, onClear, clearAriaLabel, styles: stylesProp, }: InputBaseProps) => React.JSX.Element;
|
|
68
|
+
export declare const InputBase: ({ children, intent, variant, fullWidth, width, className, disabled: isDisabled, leftIcon, leftIconColor, onLeftIconClick, leftIconAriaLabel, rightIcons, suffix, suffixId, allowClear, hasValue, onClear, clearAriaLabel, styles: stylesProp, }: InputBaseProps) => React.JSX.Element;
|
|
@@ -6,66 +6,72 @@ import r from "react";
|
|
|
6
6
|
import i from "classnames";
|
|
7
7
|
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
8
8
|
//#region src/components/form/InputBase/InputBase.tsx
|
|
9
|
-
var s = ({ children: s, intent: c = "default", variant: l = "outline", fullWidth: u = !1, width: d, className: f, disabled: p, leftIcon: m, leftIconColor: h, onLeftIconClick: g, leftIconAriaLabel: _, rightIcons: v = [],
|
|
10
|
-
let { t:
|
|
9
|
+
var s = ({ children: s, intent: c = "default", variant: l = "outline", fullWidth: u = !1, width: d, className: f, disabled: p, leftIcon: m, leftIconColor: h, onLeftIconClick: g, leftIconAriaLabel: _, rightIcons: v = [], suffix: y, suffixId: b, allowClear: x, hasValue: S, onClear: C, clearAriaLabel: w, styles: T }) => {
|
|
10
|
+
let { t: E } = e("common"), D = _ ?? E("a11y.left_icon_action"), O = w ?? E("a11y.clear_input"), k = typeof d == "string" && [
|
|
11
11
|
"xs",
|
|
12
12
|
"sm",
|
|
13
13
|
"md",
|
|
14
14
|
"lg",
|
|
15
15
|
"xl"
|
|
16
|
-
].includes(d),
|
|
16
|
+
].includes(d), A = r.Children.map(s, (e) => r.isValidElement(e) ? r.cloneElement(e, {
|
|
17
17
|
disabled: p ? !0 : e.props.disabled,
|
|
18
|
-
className: i(e.props.className, n.inner,
|
|
19
|
-
}) : e),
|
|
20
|
-
|
|
18
|
+
className: i(e.props.className, n.inner, T?.inner)
|
|
19
|
+
}) : e), j = d !== void 0 && !k && !u, M = k && !u ? d : void 0, N = (e) => p ? "disabled" : e || (c === "danger" ? "danger" : c === "warning" ? "warning" : c === "success" ? "success" : "secondary"), P = [...v];
|
|
20
|
+
x && S && !p && P.push({
|
|
21
21
|
name: "CloseIcon",
|
|
22
22
|
onClick: (e) => {
|
|
23
|
-
e.stopPropagation(),
|
|
23
|
+
e.stopPropagation(), C?.();
|
|
24
24
|
},
|
|
25
|
-
ariaLabel:
|
|
25
|
+
ariaLabel: O
|
|
26
26
|
});
|
|
27
|
-
let
|
|
27
|
+
let F = M ? n[`width${M.charAt(0).toUpperCase()}${M.slice(1)}`] : void 0;
|
|
28
28
|
return /* @__PURE__ */ o("div", {
|
|
29
|
-
className: i("wim-input-base", n.root, c && n[c], p && n.disabled, n[l], u && n.fullWidth,
|
|
30
|
-
style:
|
|
29
|
+
className: i("wim-input-base", n.root, c && n[c], p && n.disabled, n[l], u && n.fullWidth, j && n.hasCustomWidth, F, m && n.hasLeftIcon, (P.length > 0 || x) && n.hasRightIcon, (P.length >= 2 || v.length >= 1 && x) && n.hasMultipleRightIcons, f, T?.root),
|
|
30
|
+
style: j ? { "--wim-input-width": typeof d == "number" ? `${d}px` : d } : void 0,
|
|
31
31
|
children: [
|
|
32
32
|
m && /* @__PURE__ */ a("div", {
|
|
33
|
-
className: i(n.icon, n.left, g && n.clickable,
|
|
33
|
+
className: i(n.icon, n.left, g && n.clickable, T?.icon),
|
|
34
34
|
children: g ? /* @__PURE__ */ a("button", {
|
|
35
35
|
type: "button",
|
|
36
36
|
onClick: g,
|
|
37
|
-
className: i(n.iconButton,
|
|
38
|
-
"aria-label":
|
|
37
|
+
className: i(n.iconButton, T?.iconButton),
|
|
38
|
+
"aria-label": D,
|
|
39
39
|
children: /* @__PURE__ */ a(t, {
|
|
40
40
|
name: m,
|
|
41
41
|
size: "md",
|
|
42
|
-
color:
|
|
42
|
+
color: N(h)
|
|
43
43
|
})
|
|
44
44
|
}) : /* @__PURE__ */ a(t, {
|
|
45
45
|
name: m,
|
|
46
46
|
size: "md",
|
|
47
|
-
color:
|
|
47
|
+
color: N(h)
|
|
48
48
|
})
|
|
49
49
|
}),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
A,
|
|
51
|
+
y != null && y !== "" && /* @__PURE__ */ a("span", {
|
|
52
|
+
id: b,
|
|
53
|
+
className: i(n.suffix, P.length > 0 && n.suffixClearsIcons),
|
|
54
|
+
"data-testid": "input-suffix",
|
|
55
|
+
children: y
|
|
56
|
+
}),
|
|
57
|
+
P.length > 0 && /* @__PURE__ */ a("div", {
|
|
58
|
+
className: i(n.icons, n.right, T?.icons),
|
|
59
|
+
children: P.map((e, r) => /* @__PURE__ */ a("div", {
|
|
60
|
+
className: i(n.iconItem, e.onClick && n.clickable, e.rotated && n.rotated, e.className, T?.iconItem),
|
|
55
61
|
children: e.onClick ? /* @__PURE__ */ a("button", {
|
|
56
62
|
type: "button",
|
|
57
63
|
onClick: e.onClick,
|
|
58
|
-
className: i(n.iconButton,
|
|
59
|
-
"aria-label": e.ariaLabel ??
|
|
64
|
+
className: i(n.iconButton, T?.iconButton),
|
|
65
|
+
"aria-label": e.ariaLabel ?? E("a11y.right_icon_action"),
|
|
60
66
|
children: /* @__PURE__ */ a(t, {
|
|
61
67
|
name: e.name,
|
|
62
68
|
size: "md",
|
|
63
|
-
color:
|
|
69
|
+
color: N(e.color)
|
|
64
70
|
})
|
|
65
71
|
}) : /* @__PURE__ */ a(t, {
|
|
66
72
|
name: e.name,
|
|
67
73
|
size: "md",
|
|
68
|
-
color:
|
|
74
|
+
color: N(e.color)
|
|
69
75
|
})
|
|
70
76
|
}, `${e.name}-${r}`))
|
|
71
77
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_mrju8_16`,t=`_ghost_mrju8_32`,n=`_disabled_mrju8_36`,r=`_icon_mrju8_45`,i=`_iconItem_mrju8_45`,a=`_danger_mrju8_7`,o=`_warning_mrju8_61`,s=`_success_mrju8_64`,c=`_hasLeftIcon_mrju8_83`,l=`_hasRightIcon_mrju8_86`,u=`_hasMultipleRightIcons_mrju8_89`,d=`_widthXs_mrju8_92`,f=`_widthSm_mrju8_95`,p=`_widthMd_mrju8_98`,m=`_widthLg_mrju8_101`,h=`_widthXl_mrju8_104`,g=`_hasCustomWidth_mrju8_107`,_=`_fullWidth_mrju8_112`,v=`_clickable_mrju8_128`,y=`_left_mrju8_131`,b=`_suffix_mrju8_134`,x=`_suffixClearsIcons_mrju8_142`,S=`_icons_mrju8_145`,C=`_right_mrju8_156`,w=`_rotated_mrju8_168`,T=`_iconButton_mrju8_171`,E=`_inner_mrju8_189`,D={root:e,ghost:t,disabled:n,icon:r,iconItem:i,danger:a,warning:o,success:s,hasLeftIcon:c,hasRightIcon:l,hasMultipleRightIcons:u,widthXs:d,widthSm:f,widthMd:p,widthLg:m,widthXl:h,hasCustomWidth:g,fullWidth:_,clickable:v,left:y,suffix:b,suffixClearsIcons:x,icons:S,right:C,rotated:w,iconButton:T,inner:E};exports.clickable=v,exports.danger=a,exports.default=D,exports.disabled=n,exports.fullWidth=_,exports.ghost=t,exports.hasCustomWidth=g,exports.hasLeftIcon=c,exports.hasMultipleRightIcons=u,exports.hasRightIcon=l,exports.icon=r,exports.iconButton=T,exports.iconItem=i,exports.icons=S,exports.inner=E,exports.left=y,exports.right=C,exports.root=e,exports.rotated=w,exports.success=s,exports.suffix=b,exports.suffixClearsIcons=x,exports.warning=o,exports.widthLg=m,exports.widthMd=p,exports.widthSm=f,exports.widthXl=h,exports.widthXs=d;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/InputBase/input-base.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_mrju8_16", t = "_ghost_mrju8_32", n = "_disabled_mrju8_36", r = "_icon_mrju8_45", i = "_iconItem_mrju8_45", a = "_danger_mrju8_7", o = "_warning_mrju8_61", s = "_success_mrju8_64", c = "_hasLeftIcon_mrju8_83", l = "_hasRightIcon_mrju8_86", u = "_hasMultipleRightIcons_mrju8_89", d = "_widthXs_mrju8_92", f = "_widthSm_mrju8_95", p = "_widthMd_mrju8_98", m = "_widthLg_mrju8_101", h = "_widthXl_mrju8_104", g = "_hasCustomWidth_mrju8_107", _ = "_fullWidth_mrju8_112", v = "_clickable_mrju8_128", y = "_left_mrju8_131", b = "_suffix_mrju8_134", x = "_suffixClearsIcons_mrju8_142", S = "_icons_mrju8_145", C = "_right_mrju8_156", w = "_rotated_mrju8_168", T = "_iconButton_mrju8_171", E = "_inner_mrju8_189", D = {
|
|
4
4
|
root: e,
|
|
5
5
|
ghost: t,
|
|
6
6
|
disabled: n,
|
|
@@ -21,11 +21,13 @@ var e = "_root_m3clw_16", t = "_ghost_m3clw_32", n = "_disabled_m3clw_36", r = "
|
|
|
21
21
|
fullWidth: _,
|
|
22
22
|
clickable: v,
|
|
23
23
|
left: y,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
suffix: b,
|
|
25
|
+
suffixClearsIcons: x,
|
|
26
|
+
icons: S,
|
|
27
|
+
right: C,
|
|
28
|
+
rotated: w,
|
|
29
|
+
iconButton: T,
|
|
30
|
+
inner: E
|
|
29
31
|
};
|
|
30
32
|
//#endregion
|
|
31
|
-
export { v as clickable, a as danger,
|
|
33
|
+
export { v as clickable, a as danger, D as default, n as disabled, _ as fullWidth, t as ghost, g as hasCustomWidth, c as hasLeftIcon, u as hasMultipleRightIcons, l as hasRightIcon, r as icon, T as iconButton, i as iconItem, S as icons, E as inner, y as left, C as right, e as root, w as rotated, s as success, b as suffix, x as suffixClearsIcons, o as warning, m as widthLg, p as widthMd, f as widthSm, h as widthXl, d as widthXs };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../FieldTemplate/FieldTemplate.cjs"),r=require("./otp-input.module.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("classnames");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s=(0,i.forwardRef)(({length:e=6,value:
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../FieldTemplate/FieldTemplate.cjs"),r=require("./otp-input.module.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("classnames");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s=(e,t)=>{let n=e.split(``).slice(0,t);return Array(t).fill(``).map((e,t)=>n[t]??``)},c=(0,i.forwardRef)(({length:e=6,value:c=``,onChange:l,disabled:u=!1,error:d,required:f,label:p,layout:m,className:h,labels:g={},asChild:_=!1,fullWidth:v=!1,children:y,...b},x)=>{let{digitAriaLabel:S=e=>`Digit ${e}`}=g,[C,w]=(0,i.useState)(()=>s(c,e)),[T,E]=(0,i.useState)(c),D=(0,i.useRef)([]),O=`wim-otp-input-${(0,i.useId)()}`,k=p?`${O}-label`:void 0,A=d?`${O}-error`:void 0;c!==T&&(E(c),w(s(c,e)));let j=e=>{let t=e.join(``);l&&l(t)},M=(t,n)=>{let r=t.target.value.slice(-1),i=[...C];i[n]=r,w(i),j(i),r&&n<e-1&&D.current[n+1]?.focus()},N=(t,n)=>{if(t.key===`Backspace`){if(!C[n]&&n>0){let e=[...C];e[n-1]=``,w(e),j(e),D.current[n-1]?.focus()}else if(C[n]){let e=[...C];e[n]=``,w(e),j(e)}}else t.key===`ArrowLeft`&&n>0?(t.preventDefault(),D.current[n-1]?.focus()):t.key===`ArrowRight`&&n<e-1&&(t.preventDefault(),D.current[n+1]?.focus())},P=t=>{t.preventDefault();let n=t.clipboardData.getData(`text`).slice(0,e).split(``),r=[...C];n.forEach((t,n)=>{n<e&&(r[n]=t)}),w(r),j(r);let i=Math.min(n.length,e-1);D.current[i]?.focus()},F=_?t.Root:`div`;return(0,o.jsx)(n.FieldTemplate,{label:p,error:d,required:f,layout:m,labelId:k,htmlFor:O,errorId:A,className:(0,a.default)(h,v&&r.default.fullWidth),children:(0,o.jsxs)(F,{className:(0,a.default)(`wim-otp-input`,r.default.root,v&&r.default.fullWidth),ref:x,...b,children:[(0,o.jsx)(t.Slottable,{children:(0,o.jsx)(`div`,{className:(0,a.default)(r.default.container,u&&r.default.disabled),role:`group`,"aria-labelledby":k,"data-testid":`otp-input-container`,"data-disabled":u,children:Array.from({length:e}).map((e,t)=>(0,o.jsx)(`input`,{id:t===0?O:void 0,ref:e=>{D.current[t]=e},"data-testid":`otp-input`,className:(0,a.default)(r.default.input,d&&r.default.danger,u&&r.default.disabled),type:`text`,maxLength:1,value:C[t],onChange:e=>M(e,t),onKeyDown:e=>N(e,t),onPaste:P,disabled:u,"aria-label":S(t+1),"aria-invalid":d?`true`:`false`,"aria-describedby":A,"aria-required":f?`true`:void 0},t))})}),y]})})});c.displayName=`OtpInput`,exports.OtpInput=c,exports.default=c;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
export type OtpInputLabels = {
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Accessible name for one digit box.
|
|
5
|
+
*
|
|
6
|
+
* `position` is **1-based**: the first box is `1`, and the last is `length`.
|
|
7
|
+
* It is meant to be read aloud ("Digit 3 of 6"), so it counts the way a person
|
|
8
|
+
* would. Treating it as a 0-based index and adding one yields "Digit 2" for the
|
|
9
|
+
* first box.
|
|
10
|
+
*
|
|
11
|
+
* @param position 1-based position of the box, from `1` to `length`
|
|
12
|
+
* @default (position) => `Digit ${position}`
|
|
13
|
+
*/
|
|
14
|
+
digitAriaLabel?: (position: number) => string;
|
|
4
15
|
};
|
|
5
16
|
export interface OtpInputProps extends Omit<React.ComponentPropsWithoutRef<"div">, "onChange" | "value" | "defaultValue"> {
|
|
6
17
|
/** Number of digits */
|
|
@@ -19,7 +30,10 @@ export interface OtpInputProps extends Omit<React.ComponentPropsWithoutRef<"div"
|
|
|
19
30
|
label?: React.ReactNode;
|
|
20
31
|
/** Layout direction of label and field */
|
|
21
32
|
layout?: "vertical" | "horizontal";
|
|
22
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Labels for internationalization. `digitAriaLabel(position)` names one digit
|
|
35
|
+
* box and receives a **1-based** position — the first box is `1`, not `0`.
|
|
36
|
+
*/
|
|
23
37
|
labels?: OtpInputLabels;
|
|
24
38
|
/** Whether to render as a child element. */
|
|
25
39
|
asChild?: boolean;
|