ixia-ui-react 1.8.0 → 2.1.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/README.md +24 -1
- package/dist/accordion/index.d.ts +41 -0
- package/dist/accordion/index.js +142 -0
- package/dist/accordion/index.js.map +1 -0
- package/dist/alert/index.d.ts +22 -0
- package/dist/alert/index.js +1 -0
- package/dist/alert-Dcu9R8CY.js +73 -0
- package/dist/alert-Dcu9R8CY.js.map +1 -0
- package/dist/alert-dialog/index.d.ts +39 -0
- package/dist/alert-dialog/index.js +134 -0
- package/dist/alert-dialog/index.js.map +1 -0
- package/dist/autocomplete/index.d.ts +2 -0
- package/dist/autocomplete/index.js +1 -0
- package/dist/autocomplete-BfpWVO1l.js +169 -0
- package/dist/autocomplete-BfpWVO1l.js.map +1 -0
- package/dist/avatar/index.d.ts +2 -0
- package/dist/avatar/index.js +1 -0
- package/dist/avatar-Bp4gZh21.js +93 -0
- package/dist/avatar-Bp4gZh21.js.map +1 -0
- package/dist/badge/index.d.ts +2 -0
- package/dist/badge/index.js +1 -0
- package/dist/badge-Cl-9WTW-.js +160 -0
- package/dist/badge-Cl-9WTW-.js.map +1 -0
- package/dist/bento-box/index.d.ts +30 -0
- package/dist/bento-box/index.js +103 -0
- package/dist/bento-box/index.js.map +1 -0
- package/dist/breadcrumb/index.d.ts +18 -0
- package/dist/breadcrumb/index.js +58 -0
- package/dist/breadcrumb/index.js.map +1 -0
- package/dist/button/index.d.ts +3 -0
- package/dist/button/index.js +1 -0
- package/dist/button-DXQvyQyj.js +309 -0
- package/dist/button-DXQvyQyj.js.map +1 -0
- package/dist/button-group/index.d.ts +2 -0
- package/dist/button-group/index.js +1 -0
- package/dist/button-group-BiSk3iIf.js +269 -0
- package/dist/button-group-BiSk3iIf.js.map +1 -0
- package/dist/button-group-context-CScS9Ntz.js +7 -0
- package/dist/button-group-context-CScS9Ntz.js.map +1 -0
- package/dist/button.types-BFKrBCGd.d.ts +10 -0
- package/dist/calendar/index.d.ts +63 -0
- package/dist/calendar/index.js +292 -0
- package/dist/calendar/index.js.map +1 -0
- package/dist/chart/index.d.ts +87 -0
- package/dist/chart/index.js +262 -0
- package/dist/chart/index.js.map +1 -0
- package/dist/checkbox/index.d.ts +2 -0
- package/dist/checkbox/index.js +1 -0
- package/dist/checkbox-BuUZ1Lly.js +54 -0
- package/dist/checkbox-BuUZ1Lly.js.map +1 -0
- package/dist/checkbox-group/index.d.ts +6 -0
- package/dist/checkbox-group/index.js +17 -0
- package/dist/checkbox-group/index.js.map +1 -0
- package/dist/cn-BDi0DfT5.js +29 -0
- package/dist/cn-BDi0DfT5.js.map +1 -0
- package/dist/code-block/index.d.ts +53 -0
- package/dist/code-block/index.js +193 -0
- package/dist/code-block/index.js.map +1 -0
- package/dist/collapsible/index.d.ts +2 -0
- package/dist/collapsible/index.js +1 -0
- package/dist/collapsible-C3OPWY9l.js +44 -0
- package/dist/collapsible-C3OPWY9l.js.map +1 -0
- package/dist/color-channel-slider/index.d.ts +2 -0
- package/dist/color-channel-slider/index.js +1 -0
- package/dist/color-channel-slider-h8mUPJ35.js +70 -0
- package/dist/color-channel-slider-h8mUPJ35.js.map +1 -0
- package/dist/color-picker/index.d.ts +137 -0
- package/dist/color-picker/index.js +621 -0
- package/dist/color-picker/index.js.map +1 -0
- package/dist/combobox/index.d.ts +64 -0
- package/dist/combobox/index.js +289 -0
- package/dist/combobox/index.js.map +1 -0
- package/dist/context-menu/index.d.ts +49 -0
- package/dist/context-menu/index.js +166 -0
- package/dist/context-menu/index.js.map +1 -0
- package/dist/copy-button/index.d.ts +2 -0
- package/dist/copy-button/index.js +1 -0
- package/dist/copy-button-BAG-P44v.js +28 -0
- package/dist/copy-button-BAG-P44v.js.map +1 -0
- package/dist/dialog/index.d.ts +36 -0
- package/dist/dialog/index.js +119 -0
- package/dist/dialog/index.js.map +1 -0
- package/dist/drawer/index.d.ts +31 -0
- package/dist/drawer/index.js +95 -0
- package/dist/drawer/index.js.map +1 -0
- package/dist/dropzone/index.d.ts +70 -0
- package/dist/dropzone/index.js +479 -0
- package/dist/dropzone/index.js.map +1 -0
- package/dist/field/index.d.ts +2 -0
- package/dist/field/index.js +1 -0
- package/dist/field-DkMfrmdj.js +254 -0
- package/dist/field-DkMfrmdj.js.map +1 -0
- package/dist/form/index.d.ts +220 -0
- package/dist/form/index.js +3 -0
- package/dist/form-V2VqHn0D.js +192 -0
- package/dist/form-V2VqHn0D.js.map +1 -0
- package/dist/has-single-element-child-DLGI0Dh2.js +12 -0
- package/dist/has-single-element-child-DLGI0Dh2.js.map +1 -0
- package/dist/hooks/index.d.ts +26 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks-DUm-q_ig.js +68 -0
- package/dist/hooks-DUm-q_ig.js.map +1 -0
- package/dist/icon/index.d.ts +2 -0
- package/dist/icon/index.js +1 -0
- package/dist/icon-D3JWfCa2.js +85 -0
- package/dist/icon-D3JWfCa2.js.map +1 -0
- package/dist/icon-container/index.d.ts +10 -0
- package/dist/icon-container/index.js +64 -0
- package/dist/icon-container/index.js.map +1 -0
- package/dist/index-0ZQzIKoE.d.ts +11 -0
- package/dist/index-B0Qz4Egw.d.ts +33 -0
- package/dist/index-BJVMIPq4.d.ts +54 -0
- package/dist/index-BsV-u_jc.d.ts +4 -0
- package/dist/index-BygR7cUT.d.ts +22 -0
- package/dist/index-BzTOLSgZ.d.ts +9 -0
- package/dist/index-C15xiG9O.d.ts +14 -0
- package/dist/index-C2zco6-C.d.ts +15 -0
- package/dist/index-CIDOd4Z8.d.ts +56 -0
- package/dist/index-CQti9gFb.d.ts +49 -0
- package/dist/index-CiE-Rqit.d.ts +70 -0
- package/dist/index-CpNMNewO.d.ts +11 -0
- package/dist/index-D1kkOg9k.d.ts +14 -0
- package/dist/index-DLfdAked.d.ts +34 -0
- package/dist/index-DMaW_XF1.d.ts +24 -0
- package/dist/index-DVMheqs_.d.ts +9 -0
- package/dist/index-DXDObRKO.d.ts +14 -0
- package/dist/index-Db_QGr6S.d.ts +5 -0
- package/dist/index-DdFxZ3Xr.d.ts +22 -0
- package/dist/index-DyQYoAUf.d.ts +29 -0
- package/dist/index-PuhTRMce.d.ts +11 -0
- package/dist/index-Wb_tILYa.d.ts +24 -0
- package/dist/index-uaJUy56Z.d.ts +4 -0
- package/dist/index-x4f8gnaI.d.ts +15 -0
- package/dist/input/index.d.ts +3 -0
- package/dist/input/index.js +1 -0
- package/dist/input-Czt30vp7.js +179 -0
- package/dist/input-Czt30vp7.js.map +1 -0
- package/dist/input-group/index.d.ts +2 -0
- package/dist/input-group/index.js +1 -0
- package/dist/input-group-CgdazGrY.js +111 -0
- package/dist/input-group-CgdazGrY.js.map +1 -0
- package/dist/input-otp/index.d.ts +13 -0
- package/dist/input-otp/index.js +44 -0
- package/dist/input-otp/index.js.map +1 -0
- package/dist/input.types-816rEVWU.d.ts +20 -0
- package/dist/input.types-D0gyoaQv.js +48 -0
- package/dist/input.types-D0gyoaQv.js.map +1 -0
- package/dist/kbd/index.d.ts +9 -0
- package/dist/kbd/index.js +25 -0
- package/dist/kbd/index.js.map +1 -0
- package/dist/label/index.d.ts +8 -0
- package/dist/label/index.js +1 -0
- package/dist/label-BgpayDvN.js +27 -0
- package/dist/label-BgpayDvN.js.map +1 -0
- package/dist/layer-tree/index.d.ts +728 -0
- package/dist/layer-tree/index.js +685 -0
- package/dist/layer-tree/index.js.map +1 -0
- package/dist/map/google/index.d.ts +143 -0
- package/dist/map/google/index.js +445 -0
- package/dist/map/google/index.js.map +1 -0
- package/dist/map/index.d.ts +94 -0
- package/dist/map/index.js +208 -0
- package/dist/map/index.js.map +1 -0
- package/dist/map.context-Dw1D7E8m.js +11 -0
- package/dist/map.context-Dw1D7E8m.js.map +1 -0
- package/dist/menu/index.d.ts +2 -0
- package/dist/menu/index.js +1 -0
- package/dist/menu-sf13cnGp.js +173 -0
- package/dist/menu-sf13cnGp.js.map +1 -0
- package/dist/menu-tone-DWBEHoX2.js +22 -0
- package/dist/menu-tone-DWBEHoX2.js.map +1 -0
- package/dist/meter/index.d.ts +2 -0
- package/dist/meter/index.js +1 -0
- package/dist/meter-HD5taq57.js +116 -0
- package/dist/meter-HD5taq57.js.map +1 -0
- package/dist/nav-bar/index.d.ts +25 -0
- package/dist/nav-bar/index.js +133 -0
- package/dist/nav-bar/index.js.map +1 -0
- package/dist/navigation-menu/index.d.ts +43 -0
- package/dist/navigation-menu/index.js +176 -0
- package/dist/navigation-menu/index.js.map +1 -0
- package/dist/number-field/index.d.ts +14 -0
- package/dist/number-field/index.js +116 -0
- package/dist/number-field/index.js.map +1 -0
- package/dist/popover/index.d.ts +2 -0
- package/dist/popover/index.js +1 -0
- package/dist/popover-0WDxRi-s.js +114 -0
- package/dist/popover-0WDxRi-s.js.map +1 -0
- package/dist/preview-card/index.d.ts +13 -0
- package/dist/preview-card/index.js +35 -0
- package/dist/preview-card/index.js.map +1 -0
- package/dist/profile/index.d.ts +21 -0
- package/dist/profile/index.js +52 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/progress/index.d.ts +23 -0
- package/dist/progress/index.js +97 -0
- package/dist/progress/index.js.map +1 -0
- package/dist/radar-ping/index.d.ts +11 -0
- package/dist/radar-ping/index.js +49 -0
- package/dist/radar-ping/index.js.map +1 -0
- package/dist/radio-group/index.d.ts +2 -0
- package/dist/radio-group/index.js +1 -0
- package/dist/radio-group-Dj43u35Z.js +47 -0
- package/dist/radio-group-Dj43u35Z.js.map +1 -0
- package/dist/resizeable/index.d.ts +11 -0
- package/dist/resizeable/index.js +31 -0
- package/dist/resizeable/index.js.map +1 -0
- package/dist/scroll-area/index.d.ts +11 -0
- package/dist/scroll-area/index.js +51 -0
- package/dist/scroll-area/index.js.map +1 -0
- package/dist/select/index.d.ts +2 -0
- package/dist/select/index.js +1 -0
- package/dist/select-DncJXYim.js +159 -0
- package/dist/select-DncJXYim.js.map +1 -0
- package/dist/separator/index.d.ts +2 -0
- package/dist/separator/index.js +1 -0
- package/dist/separator-DgIQp1cB.js +97 -0
- package/dist/separator-DgIQp1cB.js.map +1 -0
- package/dist/sidebar/index.d.ts +80 -0
- package/dist/sidebar/index.js +334 -0
- package/dist/sidebar/index.js.map +1 -0
- package/dist/site-header/index.d.ts +22 -0
- package/dist/site-header/index.js +55 -0
- package/dist/site-header/index.js.map +1 -0
- package/dist/skeleton/index.d.ts +4 -0
- package/dist/skeleton/index.js +1 -0
- package/dist/skeleton-DSG3FWby.js +13 -0
- package/dist/skeleton-DSG3FWby.js.map +1 -0
- package/dist/slider/index.d.ts +2 -0
- package/dist/slider/index.js +1 -0
- package/dist/slider-D_XlV4OW.js +114 -0
- package/dist/slider-D_XlV4OW.js.map +1 -0
- package/dist/slider-group/index.d.ts +46 -0
- package/dist/slider-group/index.js +198 -0
- package/dist/slider-group/index.js.map +1 -0
- package/dist/styles.css +4 -1
- package/dist/switch/index.d.ts +2 -0
- package/dist/switch/index.js +1 -0
- package/dist/switch-DXHixGHe.js +23 -0
- package/dist/switch-DXHixGHe.js.map +1 -0
- package/dist/table/index.d.ts +920 -0
- package/dist/table/index.js +1544 -0
- package/dist/table/index.js.map +1 -0
- package/dist/tabs/index.d.ts +2 -0
- package/dist/tabs/index.js +1 -0
- package/dist/tabs-DTC7coap.js +270 -0
- package/dist/tabs-DTC7coap.js.map +1 -0
- package/dist/text-area/index.d.ts +2 -0
- package/dist/text-area/index.js +1 -0
- package/dist/text-area-H6HjKnv_.js +50 -0
- package/dist/text-area-H6HjKnv_.js.map +1 -0
- package/dist/toast/index.d.ts +65 -0
- package/dist/toast/index.js +216 -0
- package/dist/toast/index.js.map +1 -0
- package/dist/toggle/index.d.ts +2 -0
- package/dist/toggle/index.js +1 -0
- package/dist/toggle-ZT9thVmz.js +73 -0
- package/dist/toggle-ZT9thVmz.js.map +1 -0
- package/dist/toggle-group/index.d.ts +10 -0
- package/dist/toggle-group/index.js +63 -0
- package/dist/toggle-group/index.js.map +1 -0
- package/dist/toggle-group-context-CBNZEf1I.js +6 -0
- package/dist/toggle-group-context-CBNZEf1I.js.map +1 -0
- package/dist/tooltip/index.d.ts +18 -0
- package/dist/tooltip/index.js +1 -0
- package/dist/tooltip-B6z3tDbW.js +41 -0
- package/dist/tooltip-B6z3tDbW.js.map +1 -0
- package/dist/trim-text-children-CQRFg2fL.js +33 -0
- package/dist/trim-text-children-CQRFg2fL.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils-BI2x7nW5.js +5 -0
- package/dist/utils-BI2x7nW5.js.map +1 -0
- package/package.json +100 -31
- package/dist/index.d.ts +0 -8000
- package/dist/index.js +0 -17274
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { t as cn } from "./cn-BDi0DfT5.js";
|
|
2
|
+
import { n as Icon } from "./icon-D3JWfCa2.js";
|
|
3
|
+
import { t as Button } from "./button-DXQvyQyj.js";
|
|
4
|
+
import { n as inputVariants, t as formatFileSize } from "./input.types-D0gyoaQv.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useRef, useState } from "react";
|
|
7
|
+
import { Input } from "@base-ui/react/input";
|
|
8
|
+
// src/components/input/input.tsx
|
|
9
|
+
const DEFAULT_COLOR = "#000000";
|
|
10
|
+
const EMPTY_FILE_COUNT = 0;
|
|
11
|
+
const SINGLE_FILE_COUNT = 1;
|
|
12
|
+
const defaultFileUploadButtonIcon = /* @__PURE__ */ jsx(Icon, { name: "upload" });
|
|
13
|
+
const defaultFilesSelectedLabel = (count) => `${count} files selected`;
|
|
14
|
+
const defaultMaxFilesErrorLabel = (maxFiles) => {
|
|
15
|
+
if (maxFiles === SINGLE_FILE_COUNT) return `You can select up to ${maxFiles} file.`;
|
|
16
|
+
return `You can select up to ${maxFiles} files.`;
|
|
17
|
+
};
|
|
18
|
+
const defaultMaxFileSizeErrorLabel = (fileName, maxFileSize) => `"${fileName}" exceeds the maximum size of ${maxFileSize}.`;
|
|
19
|
+
function getStringValue(value) {
|
|
20
|
+
if (typeof value === "string") return value;
|
|
21
|
+
}
|
|
22
|
+
function getColorValue(isControlled, controlledValue, uncontrolledValue) {
|
|
23
|
+
if (isControlled) return getStringValue(controlledValue) || DEFAULT_COLOR;
|
|
24
|
+
return uncontrolledValue || DEFAULT_COLOR;
|
|
25
|
+
}
|
|
26
|
+
function getColorInputProps(isControlled, colorValue) {
|
|
27
|
+
if (isControlled) return { value: colorValue };
|
|
28
|
+
return { defaultValue: colorValue };
|
|
29
|
+
}
|
|
30
|
+
function getFileValidationError(files, options) {
|
|
31
|
+
const { maxFiles, maxFileSize, maxFilesErrorLabel, maxFileSizeErrorLabel } = options, oversizedFile = files.find((file) => maxFileSize !== void 0 && file.size > maxFileSize);
|
|
32
|
+
if (maxFiles !== void 0 && files.length > maxFiles) return maxFilesErrorLabel(maxFiles);
|
|
33
|
+
if (oversizedFile && maxFileSize !== void 0) return maxFileSizeErrorLabel(oversizedFile.name, formatFileSize(maxFileSize));
|
|
34
|
+
}
|
|
35
|
+
function getFileStatus(options) {
|
|
36
|
+
const { fileError, selectedFiles, placeholder, filesSelectedLabel } = options;
|
|
37
|
+
if (fileError) return /* @__PURE__ */ jsx("span", {
|
|
38
|
+
className: "style-text-prose-0 text-error-default",
|
|
39
|
+
children: fileError
|
|
40
|
+
});
|
|
41
|
+
if (selectedFiles.length === EMPTY_FILE_COUNT) return /* @__PURE__ */ jsx("span", {
|
|
42
|
+
className: "style-text-prose-0 text-on-surface-variant",
|
|
43
|
+
children: placeholder
|
|
44
|
+
});
|
|
45
|
+
if (selectedFiles.length === SINGLE_FILE_COUNT) return selectedFiles.at(EMPTY_FILE_COUNT)?.name;
|
|
46
|
+
return filesSelectedLabel(selectedFiles.length);
|
|
47
|
+
}
|
|
48
|
+
function Input$1({ fileUploadButtonIcon = defaultFileUploadButtonIcon, fileUploadButtonLabel, maxFiles, maxFileSize, clearFilesLabel = "Remove files", filesSelectedLabel = defaultFilesSelectedLabel, maxFilesErrorLabel = defaultMaxFilesErrorLabel, maxFileSizeErrorLabel = defaultMaxFileSizeErrorLabel, compact, variant, size, className, ref, ...props }) {
|
|
49
|
+
const inputRef = useRef(null), [uncontrolledColorValue, setUncontrolledColorValue] = useState(getStringValue(props.defaultValue) || getStringValue(props.value) || DEFAULT_COLOR), [selectedFiles, setSelectedFiles] = useState([]), [fileError, setFileError] = useState(void 0);
|
|
50
|
+
if (props.type === "color") {
|
|
51
|
+
const isControlled = props.value !== void 0, colorValue = getColorValue(isControlled, props.value, uncontrolledColorValue), { onChange, defaultValue: _defaultValue, value: _value, ...colorProps } = props, handleColorChange = (event) => {
|
|
52
|
+
if (!isControlled) setUncontrolledColorValue(event.currentTarget.value);
|
|
53
|
+
onChange?.(event);
|
|
54
|
+
}, handleColorRef = (node) => {
|
|
55
|
+
inputRef.current = node;
|
|
56
|
+
if (typeof ref === "function") {
|
|
57
|
+
ref(node);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (ref && typeof ref === "object") Object.assign(ref, { current: node });
|
|
61
|
+
};
|
|
62
|
+
if (compact) return /* @__PURE__ */ jsxs("button", {
|
|
63
|
+
"aria-label": "Open color picker",
|
|
64
|
+
className: cn("relative outline-2 outline-transparent transition-colors focus-within:outline-border hover:cursor-pointer", size === "small" && "size-lg -outline-offset-2", size === "medium" && "size-xl -outline-offset-4", size === "large" && "size-2xl -outline-offset-6", className),
|
|
65
|
+
disabled: props.disabled,
|
|
66
|
+
onClick: () => inputRef.current?.click(),
|
|
67
|
+
type: "button",
|
|
68
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
69
|
+
className: cn("size-full", size === "small" && "rounded-md", size === "medium" && "rounded-lg", size === "large" && "rounded-xl"),
|
|
70
|
+
style: { backgroundColor: colorValue }
|
|
71
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
72
|
+
className: "peer pointer-events-none invisible absolute",
|
|
73
|
+
...getColorInputProps(isControlled, colorValue),
|
|
74
|
+
onChange: handleColorChange,
|
|
75
|
+
ref: handleColorRef,
|
|
76
|
+
type: "color",
|
|
77
|
+
...colorProps
|
|
78
|
+
})]
|
|
79
|
+
});
|
|
80
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
81
|
+
"aria-label": `${colorValue}, open color picker`,
|
|
82
|
+
className: cn("relative flex hover:cursor-pointer", inputVariants({
|
|
83
|
+
size,
|
|
84
|
+
variant
|
|
85
|
+
}), className),
|
|
86
|
+
disabled: props.disabled,
|
|
87
|
+
onClick: () => inputRef.current?.click(),
|
|
88
|
+
type: "button",
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsx("div", {
|
|
91
|
+
className: cn("absolute top-1/2 left-xs aspect-square h-7/12 -translate-y-1/2", size === "small" && "rounded-md", size === "medium" && "rounded-lg", size === "large" && "rounded-xl"),
|
|
92
|
+
style: { backgroundColor: colorValue }
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ jsx(Input, {
|
|
95
|
+
className: "peer pointer-events-none invisible absolute top-lg",
|
|
96
|
+
...getColorInputProps(isControlled, colorValue),
|
|
97
|
+
onChange: handleColorChange,
|
|
98
|
+
ref: handleColorRef,
|
|
99
|
+
type: "color",
|
|
100
|
+
...colorProps
|
|
101
|
+
}),
|
|
102
|
+
/* @__PURE__ */ jsx("p", {
|
|
103
|
+
className: cn("text-left", size === "small" && "pr-2xs pl-lg style-text-default--1", size === "medium" && "pl-lg style-text-default-0", size === "large" && "pl-xl style-text-default-1"),
|
|
104
|
+
children: colorValue
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if (props.type === "file") {
|
|
110
|
+
const { onChange, ...fileProps } = props, clearFiles = () => {
|
|
111
|
+
if (inputRef.current) inputRef.current.value = "";
|
|
112
|
+
setSelectedFiles([]);
|
|
113
|
+
setFileError(void 0);
|
|
114
|
+
}, handleFileChange = (event) => {
|
|
115
|
+
const input = event.currentTarget, files = [...input.files ?? []], validationError = getFileValidationError(files, {
|
|
116
|
+
maxFileSize,
|
|
117
|
+
maxFileSizeErrorLabel,
|
|
118
|
+
maxFiles,
|
|
119
|
+
maxFilesErrorLabel
|
|
120
|
+
});
|
|
121
|
+
if (validationError) {
|
|
122
|
+
setSelectedFiles([]);
|
|
123
|
+
setFileError(validationError);
|
|
124
|
+
input.value = "";
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
setFileError(void 0);
|
|
128
|
+
setSelectedFiles(files);
|
|
129
|
+
onChange?.(event);
|
|
130
|
+
};
|
|
131
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
132
|
+
className: "flex items-center justify-between gap-lg",
|
|
133
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
134
|
+
className: "flex items-center gap-xs",
|
|
135
|
+
children: [
|
|
136
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
137
|
+
variant: "soft",
|
|
138
|
+
tone: "neutral",
|
|
139
|
+
onClick: () => inputRef.current?.click(),
|
|
140
|
+
children: [fileUploadButtonIcon, fileUploadButtonLabel]
|
|
141
|
+
}),
|
|
142
|
+
/* @__PURE__ */ jsx(Input, {
|
|
143
|
+
ref: inputRef,
|
|
144
|
+
...fileProps,
|
|
145
|
+
hidden: true,
|
|
146
|
+
onChange: handleFileChange
|
|
147
|
+
}),
|
|
148
|
+
/* @__PURE__ */ jsx("p", {
|
|
149
|
+
className: "style-text-default-0",
|
|
150
|
+
children: getFileStatus({
|
|
151
|
+
fileError,
|
|
152
|
+
filesSelectedLabel,
|
|
153
|
+
placeholder: props.placeholder,
|
|
154
|
+
selectedFiles
|
|
155
|
+
})
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
159
|
+
"aria-label": clearFilesLabel,
|
|
160
|
+
size: "medium",
|
|
161
|
+
variant: "ghost",
|
|
162
|
+
tone: "error",
|
|
163
|
+
onClick: clearFiles,
|
|
164
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "close" })
|
|
165
|
+
})]
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
169
|
+
className: cn(inputVariants({
|
|
170
|
+
size,
|
|
171
|
+
variant
|
|
172
|
+
}), className),
|
|
173
|
+
ref,
|
|
174
|
+
...props
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
export { Input$1 as t };
|
|
178
|
+
|
|
179
|
+
//# sourceMappingURL=input-Czt30vp7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-Czt30vp7.js","names":["Input","BaseInput"],"sources":["../src/components/input/input.tsx"],"sourcesContent":["import { Input as BaseInput } from '@base-ui/react/input'\nimport { useRef, useState } from 'react'\n\nimport { cn } from '@/utils/cn'\n\nimport { Button } from '../button'\nimport { Icon } from '../icon'\nimport { formatFileSize, inputVariants } from './input.types'\nimport type { InputProps } from './input.types'\n\nconst DEFAULT_COLOR = '#000000',\n EMPTY_FILE_COUNT = 0,\n SINGLE_FILE_COUNT = 1,\n defaultFileUploadButtonIcon = <Icon name=\"upload\" />,\n defaultFilesSelectedLabel = (count: number) => `${count} files selected`,\n defaultMaxFilesErrorLabel = (maxFiles: number) => {\n if (maxFiles === SINGLE_FILE_COUNT) {\n return `You can select up to ${maxFiles} file.`\n }\n return `You can select up to ${maxFiles} files.`\n },\n defaultMaxFileSizeErrorLabel = (fileName: string, maxFileSize: string) =>\n `\"${fileName}\" exceeds the maximum size of ${maxFileSize}.`\n\nfunction getStringValue(value: unknown): string | undefined {\n if (typeof value === 'string') {\n return value\n }\n return undefined\n}\n\nfunction getColorValue(\n isControlled: boolean,\n controlledValue: unknown,\n uncontrolledValue: string,\n): string {\n if (isControlled) {\n return getStringValue(controlledValue) || DEFAULT_COLOR\n }\n return uncontrolledValue || DEFAULT_COLOR\n}\n\nfunction getColorInputProps(isControlled: boolean, colorValue: string) {\n if (isControlled) {\n return { value: colorValue }\n }\n return { defaultValue: colorValue }\n}\n\nfunction getFileValidationError(\n files: File[],\n options: {\n maxFiles: number | undefined\n maxFileSize: number | undefined\n maxFilesErrorLabel: NonNullable<InputProps['maxFilesErrorLabel']>\n maxFileSizeErrorLabel: NonNullable<InputProps['maxFileSizeErrorLabel']>\n },\n): string | undefined {\n const { maxFiles, maxFileSize, maxFilesErrorLabel, maxFileSizeErrorLabel } = options,\n oversizedFile = files.find((file) => maxFileSize !== undefined && file.size > maxFileSize)\n if (maxFiles !== undefined && files.length > maxFiles) {\n return maxFilesErrorLabel(maxFiles)\n }\n\n if (oversizedFile && maxFileSize !== undefined) {\n return maxFileSizeErrorLabel(oversizedFile.name, formatFileSize(maxFileSize))\n }\n return undefined\n}\n\nfunction getFileStatus(options: {\n fileError: string | undefined\n selectedFiles: File[]\n placeholder: InputProps['placeholder']\n filesSelectedLabel: (count: number) => string\n}) {\n const { fileError, selectedFiles, placeholder, filesSelectedLabel } = options\n if (fileError) {\n return <span className=\"style-text-prose-0 text-error-default\">{fileError}</span>\n }\n if (selectedFiles.length === EMPTY_FILE_COUNT) {\n return <span className=\"style-text-prose-0 text-on-surface-variant\">{placeholder}</span>\n }\n if (selectedFiles.length === SINGLE_FILE_COUNT) {\n return selectedFiles.at(EMPTY_FILE_COUNT)?.name\n }\n return filesSelectedLabel(selectedFiles.length)\n}\n\nexport function Input({\n fileUploadButtonIcon = defaultFileUploadButtonIcon,\n fileUploadButtonLabel,\n maxFiles,\n maxFileSize,\n clearFilesLabel = 'Remove files',\n filesSelectedLabel = defaultFilesSelectedLabel,\n maxFilesErrorLabel = defaultMaxFilesErrorLabel,\n maxFileSizeErrorLabel = defaultMaxFileSizeErrorLabel,\n compact,\n variant,\n size,\n className,\n ref,\n ...props\n}: InputProps) {\n const inputRef = useRef<HTMLInputElement>(null),\n [uncontrolledColorValue, setUncontrolledColorValue] = useState<string>(\n getStringValue(props.defaultValue) || getStringValue(props.value) || DEFAULT_COLOR,\n ),\n [selectedFiles, setSelectedFiles] = useState<File[]>([]),\n [fileError, setFileError] = useState<string | undefined>(undefined)\n\n if (props.type === 'color') {\n const isControlled = props.value !== undefined,\n colorValue = getColorValue(isControlled, props.value, uncontrolledColorValue),\n { onChange, defaultValue: _defaultValue, value: _value, ...colorProps } = props,\n handleColorChange: NonNullable<typeof onChange> = (event) => {\n if (!isControlled) {\n setUncontrolledColorValue(event.currentTarget.value)\n }\n\n onChange?.(event)\n },\n handleColorRef = (node: HTMLInputElement | null) => {\n inputRef.current = node\n\n if (typeof ref === 'function') {\n ref(node)\n return\n }\n\n if (ref && typeof ref === 'object') {\n Object.assign(ref, { current: node })\n }\n }\n\n if (compact) {\n return (\n <button\n aria-label=\"Open color picker\"\n className={cn(\n 'relative outline-2 outline-transparent transition-colors focus-within:outline-border hover:cursor-pointer',\n size === 'small' && 'size-lg -outline-offset-2',\n size === 'medium' && 'size-xl -outline-offset-4',\n size === 'large' && 'size-2xl -outline-offset-6',\n className,\n )}\n disabled={props.disabled}\n onClick={() => inputRef.current?.click()}\n type=\"button\"\n >\n <div\n className={cn(\n 'size-full',\n size === 'small' && 'rounded-md',\n size === 'medium' && 'rounded-lg',\n size === 'large' && 'rounded-xl',\n )}\n style={{\n backgroundColor: colorValue,\n }}\n />\n <BaseInput\n className=\"peer pointer-events-none invisible absolute\"\n {...getColorInputProps(isControlled, colorValue)}\n onChange={handleColorChange}\n ref={handleColorRef}\n type=\"color\"\n {...colorProps}\n />\n </button>\n )\n }\n\n return (\n <button\n aria-label={`${colorValue}, open color picker`}\n className={cn(\n 'relative flex hover:cursor-pointer',\n inputVariants({ size, variant }),\n className,\n )}\n disabled={props.disabled}\n onClick={() => inputRef.current?.click()}\n type=\"button\"\n >\n <div\n className={cn(\n 'absolute top-1/2 left-xs aspect-square h-7/12 -translate-y-1/2',\n size === 'small' && 'rounded-md',\n size === 'medium' && 'rounded-lg',\n size === 'large' && 'rounded-xl',\n )}\n style={{\n backgroundColor: colorValue,\n }}\n />\n <BaseInput\n className=\"peer pointer-events-none invisible absolute top-lg\"\n {...getColorInputProps(isControlled, colorValue)}\n onChange={handleColorChange}\n ref={handleColorRef}\n type=\"color\"\n {...colorProps}\n />\n <p\n className={cn(\n 'text-left',\n size === 'small' && 'pr-2xs pl-lg style-text-default--1',\n size === 'medium' && 'pl-lg style-text-default-0',\n size === 'large' && 'pl-xl style-text-default-1',\n )}\n >\n {colorValue}\n </p>\n </button>\n )\n }\n\n if (props.type === 'file') {\n const { onChange, ...fileProps } = props,\n clearFiles = () => {\n if (inputRef.current) {\n inputRef.current.value = ''\n }\n\n setSelectedFiles([])\n setFileError(undefined)\n },\n handleFileChange: NonNullable<typeof onChange> = (event) => {\n const input = event.currentTarget,\n files = [...(input.files ?? [])],\n validationError = getFileValidationError(files, {\n maxFileSize,\n maxFileSizeErrorLabel,\n maxFiles,\n maxFilesErrorLabel,\n })\n if (validationError) {\n setSelectedFiles([])\n setFileError(validationError)\n input.value = ''\n return\n }\n\n setFileError(undefined)\n setSelectedFiles(files)\n onChange?.(event)\n }\n\n return (\n <div className=\"flex items-center justify-between gap-lg\">\n <div className=\"flex items-center gap-xs\">\n <Button variant=\"soft\" tone=\"neutral\" onClick={() => inputRef.current?.click()}>\n {fileUploadButtonIcon}\n {fileUploadButtonLabel}\n </Button>\n <BaseInput ref={inputRef} {...fileProps} hidden onChange={handleFileChange} />\n <p className=\"style-text-default-0\">\n {getFileStatus({\n fileError,\n filesSelectedLabel,\n placeholder: props.placeholder,\n selectedFiles,\n })}\n </p>\n </div>\n <Button\n aria-label={clearFilesLabel}\n size=\"medium\"\n variant=\"ghost\"\n tone=\"error\"\n onClick={clearFiles}\n >\n <Icon name=\"close\" />\n </Button>\n </div>\n )\n }\n\n return (\n <BaseInput className={cn(inputVariants({ size, variant }), className)} ref={ref} {...props} />\n )\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,gBAAgB;AACpB,MAAA,mBAAmB;AACnB,MAAA,oBAAoB;AACpB,MAAA,8BAA8B,oBAAC,MAAD,EAAM,MAAK,SAAU,CAAA;AACnD,MAAA,6BAA6B,UAAkB,GA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AK;MAAU,GAAI;MAAW,QAAA;MAAO,UAAU;KAAmB,CAAA;KAC7E,oBAAC,KAAD;MAAG,WAAU;MACV,UAAA,cAAc;OACb;OACA;OACA,aAAa,MAAM;OACnB;MACF,CAAC;KACA,CAAA;IACA;GACL,CAAA,GAAA,oBAAC,QAAD;IACE,cAAY;IACZ,MAAK;IACL,SAAQ;IACR,MAAK;IACL,SAAS;IAET,UAAA,oBAAC,MAAD,EAAM,MAAK,QAAS,CAAA;GACd,CAAA,CACL;;CAET;CAEA,OACE,oBAACA,OAAD;EAAW,WAAW,GAAG,cAAc;GAAE;GAAM;EAAQ,CAAC,GAAG,SAAS;EAAQ;EAAK,GAAI;CAAQ,CAAA;AAEjG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as InputGroupAddonProps, c as InputGroupSeparatorProps, i as InputGroupAddon, n as InputGroupSeparator, o as InputGroupInputProps, r as InputGroupInput, s as InputGroupProps, t as InputGroup } from "../index-DdFxZ3Xr.js";
|
|
2
|
+
export { InputGroup, InputGroupAddon, type InputGroupAddonProps, InputGroupInput, type InputGroupInputProps, type InputGroupProps, InputGroupSeparator, type InputGroupSeparatorProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as InputGroup, i as InputGroupAddon, r as InputGroupInput, n as InputGroupSeparator } from "../input-group-CgdazGrY.js";
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { t as cn } from "./cn-BDi0DfT5.js";
|
|
2
|
+
import { n as inputVariants } from "./input.types-D0gyoaQv.js";
|
|
3
|
+
import { t as Separator } from "./separator-DgIQp1cB.js";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useRef, useState } from "react";
|
|
7
|
+
import { Input } from "@base-ui/react/input";
|
|
8
|
+
// src/components/input-group/input-group.tsx
|
|
9
|
+
function InputGroup$1({ variant, size, className, ref, ...props }) {
|
|
10
|
+
return /* @__PURE__ */ jsx("div", {
|
|
11
|
+
className: cn(inputVariants({
|
|
12
|
+
size,
|
|
13
|
+
variant
|
|
14
|
+
}), className),
|
|
15
|
+
ref,
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
// src/components/input-group/input-group.types.ts
|
|
20
|
+
const inputGroupAddonVariants = cva("inline-flex items-center gap-2xs text-on-surface-variant not-first:pl-2xs group-aria-invalid:text-error-on-container", {
|
|
21
|
+
defaultVariants: { size: "medium" },
|
|
22
|
+
variants: { size: {
|
|
23
|
+
large: "style-text-default-1 [&>svg]:size-md",
|
|
24
|
+
medium: "style-text-default-0 [&>svg]:size-sm",
|
|
25
|
+
small: "style-text-default--1 [&>svg]:size-xs"
|
|
26
|
+
} }
|
|
27
|
+
});
|
|
28
|
+
// src/components/input-group/input-group-addon.tsx
|
|
29
|
+
function InputGroupAddon({ size, className, ref, ...props }) {
|
|
30
|
+
return /* @__PURE__ */ jsx("div", {
|
|
31
|
+
className: cn(inputGroupAddonVariants({ size }), className),
|
|
32
|
+
ref,
|
|
33
|
+
...props
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// src/components/input-group/input-group-input.tsx
|
|
37
|
+
const DEFAULT_COLOR = "#000000";
|
|
38
|
+
function getStringValue(value) {
|
|
39
|
+
if (typeof value === "string") return value;
|
|
40
|
+
}
|
|
41
|
+
function getColorValue(isControlled, controlledValue, uncontrolledValue) {
|
|
42
|
+
if (isControlled) return getStringValue(controlledValue) || DEFAULT_COLOR;
|
|
43
|
+
return uncontrolledValue || DEFAULT_COLOR;
|
|
44
|
+
}
|
|
45
|
+
function getColorInputProps(isControlled, colorValue) {
|
|
46
|
+
if (isControlled) return { value: colorValue };
|
|
47
|
+
return { defaultValue: colorValue };
|
|
48
|
+
}
|
|
49
|
+
function InputGroupInput({ size = "medium", className, ref, ...props }) {
|
|
50
|
+
const inputRef = useRef(null), [uncontrolledColorValue, setUncontrolledColorValue] = useState(getStringValue(props.defaultValue) || getStringValue(props.value) || DEFAULT_COLOR);
|
|
51
|
+
if (props.type === "color") {
|
|
52
|
+
const isControlled = props.value !== void 0, colorValue = getColorValue(isControlled, props.value, uncontrolledColorValue), { onChange, defaultValue: _defaultValue, value: _value, ...colorProps } = props, handleColorChange = (event) => {
|
|
53
|
+
if (!isControlled) setUncontrolledColorValue(event.currentTarget.value);
|
|
54
|
+
onChange?.(event);
|
|
55
|
+
}, handleColorRef = (node) => {
|
|
56
|
+
inputRef.current = node;
|
|
57
|
+
if (typeof ref === "function") {
|
|
58
|
+
ref(node);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (ref && typeof ref === "object") Object.assign(ref, { current: node });
|
|
62
|
+
};
|
|
63
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
64
|
+
"aria-label": `${colorValue}, open color picker`,
|
|
65
|
+
className: cn("relative flex size-full items-center justify-start hover:cursor-pointer", className),
|
|
66
|
+
disabled: props.disabled,
|
|
67
|
+
onClick: () => inputRef.current?.click(),
|
|
68
|
+
type: "button",
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ jsx("div", {
|
|
71
|
+
className: cn("absolute top-1/2 left-0 aspect-square h-7/12 -translate-y-1/2", size === "small" && "rounded-md", size === "medium" && "rounded-lg", size === "large" && "rounded-xl"),
|
|
72
|
+
style: { backgroundColor: colorValue }
|
|
73
|
+
}),
|
|
74
|
+
/* @__PURE__ */ jsx(Input, {
|
|
75
|
+
className: "peer pointer-events-none invisible absolute top-lg",
|
|
76
|
+
...getColorInputProps(isControlled, colorValue),
|
|
77
|
+
onChange: handleColorChange,
|
|
78
|
+
ref: handleColorRef,
|
|
79
|
+
type: "color",
|
|
80
|
+
...colorProps
|
|
81
|
+
}),
|
|
82
|
+
/* @__PURE__ */ jsx("p", {
|
|
83
|
+
className: cn("text-left", size === "small" && "pr-xs pl-lg style-text-default--1", size === "medium" && "pl-[calc(var(--ixia-spacing-lg)+6px)] style-text-default-0", size === "large" && "pl-2xl style-text-default-1"),
|
|
84
|
+
children: colorValue
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
90
|
+
className: cn("w-full grow text-ellipsis outline-none placeholder:opacity-60 disabled:cursor-not-allowed", className),
|
|
91
|
+
ref,
|
|
92
|
+
...props
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// src/components/input-group/input-group-separator.tsx
|
|
96
|
+
function InputGroupSeparator({ className, ref, ...props }) {
|
|
97
|
+
return /* @__PURE__ */ jsx(Separator, {
|
|
98
|
+
className: cn("h-2/4", className),
|
|
99
|
+
ref,
|
|
100
|
+
...props
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// src/components/input-group/index.ts
|
|
104
|
+
const InputGroup = Object.assign(InputGroup$1, {
|
|
105
|
+
Addon: InputGroupAddon,
|
|
106
|
+
Input: InputGroupInput,
|
|
107
|
+
Separator: InputGroupSeparator
|
|
108
|
+
});
|
|
109
|
+
export { InputGroupAddon as i, InputGroupSeparator as n, InputGroupInput as r, InputGroup as t };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=input-group-CgdazGrY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-group-CgdazGrY.js","names":["InputGroup","BaseInput","InputGroupRoot"],"sources":["../src/components/input-group/input-group.tsx","../src/components/input-group/input-group.types.ts","../src/components/input-group/input-group-addon.tsx","../src/components/input-group/input-group-input.tsx","../src/components/input-group/input-group-separator.tsx","../src/components/input-group/index.ts"],"sourcesContent":["import { cn } from '@/utils/cn'\n\nimport { inputVariants } from '../input/input.types'\nimport type { InputGroupProps } from './input-group.types'\n\nexport function InputGroup({ variant, size, className, ref, ...props }: InputGroupProps) {\n return <div className={cn(inputVariants({ size, variant }), className)} ref={ref} {...props} />\n}\n","import type { Input as BaseInput } from '@base-ui/react/input'\nimport { cva } from 'class-variance-authority'\nimport type { VariantProps } from 'class-variance-authority'\n\nimport type { inputVariants } from '../input/input.types'\nimport type { Separator } from '../separator'\n\nconst inputGroupAddonVariants = cva(\n 'inline-flex items-center gap-2xs text-on-surface-variant not-first:pl-2xs group-aria-invalid:text-error-on-container',\n {\n defaultVariants: {\n size: 'medium',\n },\n variants: {\n size: {\n large: 'style-text-default-1 [&>svg]:size-md',\n medium: 'style-text-default-0 [&>svg]:size-sm',\n small: 'style-text-default--1 [&>svg]:size-xs',\n },\n },\n },\n)\n\ntype InputGroupAddonProps = React.ComponentProps<'div'> &\n VariantProps<typeof inputGroupAddonVariants>\ntype InputGroupInputProps = Omit<React.ComponentProps<typeof BaseInput>, 'size'> &\n VariantProps<typeof inputVariants>\ntype InputGroupProps = React.ComponentProps<'div'> & VariantProps<typeof inputVariants>\ntype InputGroupSeparatorProps = React.ComponentProps<typeof Separator>\n\nexport type {\n InputGroupAddonProps,\n InputGroupInputProps,\n InputGroupProps,\n InputGroupSeparatorProps,\n}\nexport { inputGroupAddonVariants }\n","import { cn } from '@/utils/cn'\n\nimport { inputGroupAddonVariants } from './input-group.types'\nimport type { InputGroupAddonProps } from './input-group.types'\n\nexport function InputGroupAddon({ size, className, ref, ...props }: InputGroupAddonProps) {\n return <div className={cn(inputGroupAddonVariants({ size }), className)} ref={ref} {...props} />\n}\n","import { Input as BaseInput } from '@base-ui/react/input'\nimport { useRef, useState } from 'react'\n\nimport { cn } from '@/utils/cn'\n\nimport type { InputGroupInputProps } from './input-group.types'\n\nconst DEFAULT_COLOR = '#000000'\n\nfunction getStringValue(value: unknown): string | undefined {\n if (typeof value === 'string') {\n return value\n }\n return undefined\n}\n\nfunction getColorValue(\n isControlled: boolean,\n controlledValue: unknown,\n uncontrolledValue: string,\n): string {\n if (isControlled) {\n return getStringValue(controlledValue) || DEFAULT_COLOR\n }\n return uncontrolledValue || DEFAULT_COLOR\n}\n\nfunction getColorInputProps(isControlled: boolean, colorValue: string) {\n if (isControlled) {\n return { value: colorValue }\n }\n return { defaultValue: colorValue }\n}\n\nexport function InputGroupInput({\n size = 'medium',\n className,\n ref,\n ...props\n}: InputGroupInputProps) {\n const inputRef = useRef<HTMLInputElement>(null),\n [uncontrolledColorValue, setUncontrolledColorValue] = useState<string>(\n getStringValue(props.defaultValue) || getStringValue(props.value) || DEFAULT_COLOR,\n )\n\n if (props.type === 'color') {\n const isControlled = props.value !== undefined,\n colorValue = getColorValue(isControlled, props.value, uncontrolledColorValue),\n { onChange, defaultValue: _defaultValue, value: _value, ...colorProps } = props,\n handleColorChange: NonNullable<typeof onChange> = (event) => {\n if (!isControlled) {\n setUncontrolledColorValue(event.currentTarget.value)\n }\n\n onChange?.(event)\n },\n handleColorRef = (node: HTMLInputElement | null) => {\n inputRef.current = node\n\n if (typeof ref === 'function') {\n ref(node)\n return\n }\n\n if (ref && typeof ref === 'object') {\n Object.assign(ref, { current: node })\n }\n }\n\n return (\n <button\n aria-label={`${colorValue}, open color picker`}\n className={cn(\n 'relative flex size-full items-center justify-start hover:cursor-pointer',\n className,\n )}\n disabled={props.disabled}\n onClick={() => inputRef.current?.click()}\n type=\"button\"\n >\n <div\n className={cn(\n 'absolute top-1/2 left-0 aspect-square h-7/12 -translate-y-1/2',\n size === 'small' && 'rounded-md',\n size === 'medium' && 'rounded-lg',\n size === 'large' && 'rounded-xl',\n )}\n style={{\n backgroundColor: colorValue,\n }}\n />\n <BaseInput\n className=\"peer pointer-events-none invisible absolute top-lg\"\n {...getColorInputProps(isControlled, colorValue)}\n onChange={handleColorChange}\n ref={handleColorRef}\n type=\"color\"\n {...colorProps}\n />\n <p\n className={cn(\n 'text-left',\n size === 'small' && 'pr-xs pl-lg style-text-default--1',\n size === 'medium' && 'pl-[calc(var(--ixia-spacing-lg)+6px)] style-text-default-0',\n size === 'large' && 'pl-2xl style-text-default-1',\n )}\n >\n {colorValue}\n </p>\n </button>\n )\n }\n\n return (\n <BaseInput\n className={cn(\n 'w-full grow text-ellipsis outline-none placeholder:opacity-60 disabled:cursor-not-allowed',\n className,\n )}\n ref={ref}\n {...props}\n />\n )\n}\n","import { cn } from '@/utils/cn'\n\nimport { Separator } from '../separator'\nimport type { InputGroupSeparatorProps } from './input-group.types'\n\nexport function InputGroupSeparator({ className, ref, ...props }: InputGroupSeparatorProps) {\n return <Separator className={cn('h-2/4', className)} ref={ref} {...props} />\n}\n","import { InputGroup as InputGroupRoot } from './input-group'\nimport { InputGroupAddon } from './input-group-addon'\nimport { InputGroupInput } from './input-group-input'\nimport { InputGroupSeparator } from './input-group-separator'\n\nconst InputGroup = Object.assign(InputGroupRoot, {\n Addon: InputGroupAddon,\n Input: InputGroupInput,\n Separator: InputGroupSeparator,\n})\n\nexport type {\n InputGroupAddonProps,\n InputGroupInputProps,\n InputGroupProps,\n InputGroupSeparatorProps,\n} from './input-group.types'\nexport { InputGroupAddon } from './input-group-addon'\nexport { InputGroupInput } from './input-group-input'\nexport { InputGroupSeparator } from './input-group-separator'\n\nexport { InputGroup }\n"],"mappings":";;;;;;;;AAKA,SAAgBA,aAAW,EAAE,SAAS,MAAM,WAAW,KAAK,GAAG,SAA0B;CACvF,OAAO,oBAAC,OAAD;EAAK,WAAW,GAAG,cAAc;GAAE;GAAM;EAAQ,CAAC,GAAG,SAAS;EAAQ;EAAK,GAAI;CAAQ,CAAA;AAChG;;ACAA,MAAM,0BAA0B,IAC9B,wHACA;CACE,iBAAiB,EACf,MAAM,SACR;CACA,UAAU,EACR,MAAM;EACJ,OAAO;EACP,QAAQ;EACR,OAAO;CACT,EACF;AACF,CACF;;AChBA,SAAgB,gBAAgB,EAAE,MAAM,WAAW,KAAK,GAAG,SAA+B;CACxF,OAAO,oBAAC,OAAD;EAAK,WAAW,GAAG,wBAAwB,EAAE,KAAK,CAAC,GAAG,SAAS;EAAQ;EAAK,GAAI;CAAQ,CAAA;AACjG;;ACAA,MAAM,gBAAgB;AAEtB,SAAS,eAAe,OAAoC;CAC1D,IAAI,OAAO,UAAU,UACnB,OAAO;AAGX;AAEA,SAAS,cACP,cACA,iBACA,mBACQ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D;KACE,WAAW,GACT,aACA,SAAS,WAAW,qCACpB,SAAS,YAAY,8DACrB,SAAS,WAAW,6BACtB;KAEC,UAAA;IACA,CAAA;GACG;;CAEZ;CAEA,OACE,oBAACA,OAAD;EACE,WAAW,GACT,6FACA,SACF;EACK;EACL,GAAI;CACL,CAAA;AAEL;;ACtHA,SAAgB,oBAAoB,EAAE,WAAW,KAAK,GAAG,SAAmC;CAC1F,OAAO,oBAAC,WAAD;EAAW,WAAW,GAAG,SAAS,SAAS;EAAQ;EAAK,GAAI;CAAQ,CAAA;AAC7E;;ACFA,MAAM,aAAa,OAAO,OAAOC,cAAgB;CAC/C,OAAO;CACP,OAAO;CACP,WAAW;AACb,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OTPField } from "@base-ui/react";
|
|
2
|
+
type InputOTPProps = React.ComponentProps<typeof OTPField.Root>;
|
|
3
|
+
type InputOTPSlotProps = React.ComponentProps<typeof OTPField.Input>;
|
|
4
|
+
type InputOtpSeparatorProps = React.ComponentProps<typeof OTPField.Separator>;
|
|
5
|
+
declare function InputOTP$1({ children, className, id, ref, ...props }: InputOTPProps): import("react").JSX.Element;
|
|
6
|
+
export declare function InputOtpSeparator({ className, children, ref, ...props }: InputOtpSeparatorProps): import("react").JSX.Element;
|
|
7
|
+
export declare function InputOTPSlot({ className, ...props }: InputOTPSlotProps): import("react").JSX.Element;
|
|
8
|
+
declare const InputOTP: typeof InputOTP$1 & {
|
|
9
|
+
Separator: typeof InputOtpSeparator;
|
|
10
|
+
Slot: typeof InputOTPSlot;
|
|
11
|
+
};
|
|
12
|
+
export { InputOTP, type InputOTPProps, type InputOTPSlotProps, type InputOtpSeparatorProps };
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { t as cn } from "../cn-BDi0DfT5.js";
|
|
2
|
+
import { n as Icon } from "../icon-D3JWfCa2.js";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { useId } from "react";
|
|
5
|
+
import { OTPField } from "@base-ui/react";
|
|
6
|
+
// src/components/input-otp/input-otp.tsx
|
|
7
|
+
function InputOTP$1({ children, className, id, ref, ...props }) {
|
|
8
|
+
const generatedId = useId(), fieldId = id ?? generatedId;
|
|
9
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("label", {
|
|
10
|
+
htmlFor: fieldId,
|
|
11
|
+
className: "sr-only",
|
|
12
|
+
children: "One-time password"
|
|
13
|
+
}), /* @__PURE__ */ jsx(OTPField.Root, {
|
|
14
|
+
id: fieldId,
|
|
15
|
+
className: cn("group flex items-center gap-2xs has-disabled:opacity-30", className),
|
|
16
|
+
ref,
|
|
17
|
+
...props,
|
|
18
|
+
children
|
|
19
|
+
})] });
|
|
20
|
+
}
|
|
21
|
+
// src/components/input-otp/input-otp-separator.tsx
|
|
22
|
+
function InputOtpSeparator({ className, children, ref, ...props }) {
|
|
23
|
+
return /* @__PURE__ */ jsx(OTPField.Separator, {
|
|
24
|
+
className: cn("flex items-center justify-center text-on-surface-variant", className),
|
|
25
|
+
ref,
|
|
26
|
+
...props,
|
|
27
|
+
children: children ?? /* @__PURE__ */ jsx(Icon, { name: "minus" })
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// src/components/input-otp/input-otp-slot.tsx
|
|
31
|
+
function InputOTPSlot({ className, ...props }) {
|
|
32
|
+
return /* @__PURE__ */ jsx(OTPField.Input, {
|
|
33
|
+
className: cn("relative h-lg w-md rounded-md bg-surface text-center style-text-default-0 shadow-2xs outline outline-transparent transition-colors hover:outline-border-strong focus:outline-brand-border-strong", className),
|
|
34
|
+
...props
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// src/components/input-otp/index.ts
|
|
38
|
+
const InputOTP = Object.assign(InputOTP$1, {
|
|
39
|
+
Separator: InputOtpSeparator,
|
|
40
|
+
Slot: InputOTPSlot
|
|
41
|
+
});
|
|
42
|
+
export { InputOTP, InputOTPSlot, InputOtpSeparator };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["InputOTP","InputOTPRoot"],"sources":["../../src/components/input-otp/input-otp.tsx","../../src/components/input-otp/input-otp-separator.tsx","../../src/components/input-otp/input-otp-slot.tsx","../../src/components/input-otp/index.ts"],"sourcesContent":["import { OTPField } from '@base-ui/react'\nimport { useId } from 'react'\n\nimport { cn } from '@/utils/cn'\n\nimport type { InputOTPProps } from './input-otp.types'\n\nexport function InputOTP({ children, className, id, ref, ...props }: InputOTPProps) {\n const generatedId = useId(),\n fieldId = id ?? generatedId\n return (\n <>\n <label htmlFor={fieldId} className=\"sr-only\">\n One-time password\n </label>\n <OTPField.Root\n id={fieldId}\n className={cn('group flex items-center gap-2xs has-disabled:opacity-30', className)}\n ref={ref}\n {...props}\n >\n {children}\n </OTPField.Root>\n </>\n )\n}\n","import { OTPField } from '@base-ui/react'\n\nimport { cn } from '@/utils/cn'\n\nimport { Icon } from '../icon'\nimport type { InputOtpSeparatorProps } from './input-otp.types'\n\nexport function InputOtpSeparator({ className, children, ref, ...props }: InputOtpSeparatorProps) {\n return (\n <OTPField.Separator\n className={cn('flex items-center justify-center text-on-surface-variant', className)}\n ref={ref}\n {...props}\n >\n {children ?? <Icon name=\"minus\" />}\n </OTPField.Separator>\n )\n}\n","import { OTPField } from '@base-ui/react'\n\nimport { cn } from '@/utils/cn'\n\nimport type { InputOTPSlotProps } from './input-otp.types'\n\nexport function InputOTPSlot({ className, ...props }: InputOTPSlotProps) {\n return (\n <OTPField.Input\n className={cn(\n 'relative h-lg w-md rounded-md bg-surface text-center style-text-default-0 shadow-2xs outline outline-transparent transition-colors hover:outline-border-strong focus:outline-brand-border-strong',\n className,\n )}\n {...props}\n />\n )\n}\n","import { InputOTP as InputOTPRoot } from './input-otp'\nimport { InputOtpSeparator } from './input-otp-separator'\nimport { InputOTPSlot } from './input-otp-slot'\n\nconst InputOTP = Object.assign(InputOTPRoot, {\n Separator: InputOtpSeparator,\n Slot: InputOTPSlot,\n})\n\nexport type { InputOTPProps, InputOTPSlotProps, InputOtpSeparatorProps } from './input-otp.types'\nexport { InputOTPSlot } from './input-otp-slot'\nexport { InputOtpSeparator } from './input-otp-separator'\n\nexport { InputOTP }\n"],"mappings":";;;;;;AAOA,SAAgBA,WAAS,EAAE,UAAU,WAAW,IAAI,KAAK,GAAG,SAAwB;CAClF,MAAM,cAAc,MAAM,GACxB,UAAU,MAAM;CAClB,OACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,SAAD;EAAO,SAAS;EAAS,WAAU;EAAU,UAAA;CAEtC,CAAA,GACP,oBAAC,SAAS,MAAV;EACE,IAAI;EACJ,WAAW,GAAG,2DAA2D,SAAS;EAC7E;EACL,GAAI;EAEH;CACY,CAAA,CACf,EAAA,CAAA;AAEN;;AClBA,SAAgB,kBAAkB,EAAE,WAAW,UAAU,KAAK,GAAG,SAAiC;CAChG,OACE,oBAAC,SAAS,WAAV;EACE,WAAW,GAAG,4DAA4D,SAAS;EAC9E;EACL,GAAI;EAEH,UAAA,YAAY,oBAAC,MAAD,EAAM,MAAK,QAAS,CAAA;CACf,CAAA;AAExB;;ACXA,SAAgB,aAAa,EAAE,WAAW,GAAG,SAA4B;CACvE,OACE,oBAAC,SAAS,OAAV;EACE,WAAW,GACT,oMACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;;ACZA,MAAM,WAAW,OAAO,OAAOC,YAAc;CAC3C,WAAW;CACX,MAAM;AACR,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { VariantProps } from "class-variance-authority";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
import { Input } from "@base-ui/react/input";
|
|
4
|
+
declare const formatFileSize: (bytes: number) => string, inputVariants: (props?: ({
|
|
5
|
+
size?: "large" | "medium" | "small" | null | undefined;
|
|
6
|
+
variant?: "ghost" | "outline" | "primary" | "secondary" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
type InputProps = VariantProps<typeof inputVariants> & Omit<ComponentProps<typeof Input>, 'size'> & {
|
|
9
|
+
fileUploadButtonLabel?: string;
|
|
10
|
+
fileUploadButtonIcon?: React.ReactNode;
|
|
11
|
+
maxFiles?: number;
|
|
12
|
+
maxFileSize?: number;
|
|
13
|
+
clearFilesLabel?: string;
|
|
14
|
+
filesSelectedLabel?: (count: number) => string;
|
|
15
|
+
maxFilesErrorLabel?: (maxFiles: number) => string;
|
|
16
|
+
maxFileSizeErrorLabel?: (fileName: string, maxFileSize: string) => string;
|
|
17
|
+
compact?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export { inputVariants as n, InputProps as t };
|
|
20
|
+
//# sourceMappingURL=input.types-816rEVWU.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
// src/components/input/input.types.tsx
|
|
3
|
+
const BYTES_PER_KILOBYTE = 1e3;
|
|
4
|
+
const INITIAL_UNIT_INDEX = 0;
|
|
5
|
+
const INTEGER_PRECISION = 0;
|
|
6
|
+
const FRACTIONAL_PRECISION = 1;
|
|
7
|
+
const UNIT_INDEX_INCREMENT = 1;
|
|
8
|
+
const getPrecision = (size) => {
|
|
9
|
+
if (Number.isInteger(size)) return INTEGER_PRECISION;
|
|
10
|
+
return FRACTIONAL_PRECISION;
|
|
11
|
+
};
|
|
12
|
+
const formatFileSize = (bytes) => {
|
|
13
|
+
if (bytes < BYTES_PER_KILOBYTE) return `${bytes} B`;
|
|
14
|
+
const units = [
|
|
15
|
+
"KB",
|
|
16
|
+
"MB",
|
|
17
|
+
"GB",
|
|
18
|
+
"TB"
|
|
19
|
+
];
|
|
20
|
+
let size = bytes / BYTES_PER_KILOBYTE, unitIndex = INITIAL_UNIT_INDEX;
|
|
21
|
+
while (size >= BYTES_PER_KILOBYTE && unitIndex < units.length - UNIT_INDEX_INCREMENT) {
|
|
22
|
+
size /= BYTES_PER_KILOBYTE;
|
|
23
|
+
unitIndex += UNIT_INDEX_INCREMENT;
|
|
24
|
+
}
|
|
25
|
+
return `${size.toFixed(getPrecision(size))} ${units[unitIndex]}`;
|
|
26
|
+
};
|
|
27
|
+
const inputVariants = cva("group flex w-full items-center text-ellipsis caret-brand-border-strong outline outline-transparent transition-all placeholder:opacity-60 focus-within:outline-brand-border-strong not-focus-within:hover:outline-border-strong disabled:cursor-not-allowed aria-invalid:bg-error-container aria-invalid:text-error-on-container aria-invalid:caret-error-border-strong aria-invalid:outline-error-border aria-invalid:focus-within:outline-error-border-strong aria-invalid:not-focus-within:hover:outline-error-border data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50", {
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
size: "medium",
|
|
30
|
+
variant: "primary"
|
|
31
|
+
},
|
|
32
|
+
variants: {
|
|
33
|
+
size: {
|
|
34
|
+
large: "h-2xl gap-xs rounded-2xl px-md style-text-prose-1",
|
|
35
|
+
medium: "h-xl gap-2xs rounded-xl px-sm style-text-prose-0",
|
|
36
|
+
small: "h-lg gap-3xs rounded-lg pr-3xs pl-xs style-text-prose--1"
|
|
37
|
+
},
|
|
38
|
+
variant: {
|
|
39
|
+
ghost: "bg-transparent",
|
|
40
|
+
outline: "bg-transparent outline outline-border",
|
|
41
|
+
primary: "bg-surface shadow-2xs",
|
|
42
|
+
secondary: "bg-neutral-container"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
export { inputVariants as n, formatFileSize as t };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=input.types-D0gyoaQv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.types-D0gyoaQv.js","names":[],"sources":["../src/components/input/input.types.tsx"],"sourcesContent":["import type { Input as BaseInput } from '@base-ui/react/input'\nimport { cva } from 'class-variance-authority'\nimport type { VariantProps } from 'class-variance-authority'\nimport type { ComponentProps } from 'react'\n\nconst BYTES_PER_KILOBYTE = 1000,\n INITIAL_UNIT_INDEX = 0,\n INTEGER_PRECISION = 0,\n FRACTIONAL_PRECISION = 1,\n UNIT_INDEX_INCREMENT = 1,\n getPrecision = (size: number): number => {\n if (Number.isInteger(size)) {\n return INTEGER_PRECISION\n }\n return FRACTIONAL_PRECISION\n },\n formatFileSize = (bytes: number): string => {\n if (bytes < BYTES_PER_KILOBYTE) {\n return `${bytes} B`\n }\n\n const units = ['KB', 'MB', 'GB', 'TB']\n let size = bytes / BYTES_PER_KILOBYTE,\n unitIndex = INITIAL_UNIT_INDEX\n\n while (size >= BYTES_PER_KILOBYTE && unitIndex < units.length - UNIT_INDEX_INCREMENT) {\n size /= BYTES_PER_KILOBYTE\n unitIndex += UNIT_INDEX_INCREMENT\n }\n\n return `${size.toFixed(getPrecision(size))} ${units[unitIndex]}`\n },\n inputVariants = cva(\n 'group flex w-full items-center text-ellipsis caret-brand-border-strong outline outline-transparent transition-all placeholder:opacity-60 focus-within:outline-brand-border-strong not-focus-within:hover:outline-border-strong disabled:cursor-not-allowed aria-invalid:bg-error-container aria-invalid:text-error-on-container aria-invalid:caret-error-border-strong aria-invalid:outline-error-border aria-invalid:focus-within:outline-error-border-strong aria-invalid:not-focus-within:hover:outline-error-border data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50',\n {\n defaultVariants: {\n size: 'medium',\n variant: 'primary',\n },\n variants: {\n size: {\n large: 'h-2xl gap-xs rounded-2xl px-md style-text-prose-1',\n medium: 'h-xl gap-2xs rounded-xl px-sm style-text-prose-0',\n small: 'h-lg gap-3xs rounded-lg pr-3xs pl-xs style-text-prose--1',\n },\n variant: {\n ghost: 'bg-transparent',\n outline: 'bg-transparent outline outline-border',\n primary: 'bg-surface shadow-2xs',\n secondary: 'bg-neutral-container',\n },\n },\n },\n )\n\ntype InputProps = VariantProps<typeof inputVariants> &\n Omit<ComponentProps<typeof BaseInput>, 'size'> & {\n fileUploadButtonLabel?: string\n fileUploadButtonIcon?: React.ReactNode\n maxFiles?: number\n maxFileSize?: number\n clearFilesLabel?: string\n filesSelectedLabel?: (count: number) => string\n maxFilesErrorLabel?: (maxFiles: number) => string\n maxFileSizeErrorLabel?: (fileName: string, maxFileSize: string) => string\n compact?: boolean\n }\n\nexport { formatFileSize, inputVariants, type InputProps }\n"],"mappings":";;AAKA,MAAM,qBAAqB;AACzB,MAAA,qBAAqB;AACrB,MAAA,oBAAoB;AACpB,MAAA,uBAAuB;AACvB,MAAA,uBAAuB;AACvB,MAAA,gBAAgB,SAAyB;CACvC,IAAI,OAAO,UAAU,IAAI,GACvB,OAAO;CAET,OAAO;AACT;AACA,MAAA,kBAAkB,UAA0B;CAC1C,IAAI,QAAQ,oBACV,OAAO,GAAG,MAAM;CAGlB,MAAM,QAAQ;EAAC;EAAM;EAAM;EAAM;CAAI;CACrC,IAAI,OAAO,QAAQ,oBACjB,YAAY;CAEd,OAAO,QAAQ,sBAAsB,YAAY,MAAM,SAAS,sBAAsB;EACpF,QAAQ;EACR,aAAa;CACf;CAEA,OAAO,GAAG,KAAK,QAAQ,aAAa,IAAI,CAAC,EAAE,GAAG,MAAM;AACtD;AACA,MAAA,gBAAgB,IACd,mkBACA;CACE,iBAAiB;EACf,MAAM;EACN,SAAS;CACX;CACA,UAAU;EACR,MAAM;GACJ,OAAO;GACP,QAAQ;GACR,OAAO;EACT;EACA,SAAS;GACP,OAAO;GACP,SAAS;GACT,SAAS;GACT,WAAW;EACb;CACF;AACF,CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type KbdProps = React.ComponentProps<'div'>;
|
|
2
|
+
type KbdGroupProps = React.ComponentProps<'div'>;
|
|
3
|
+
declare function Kbd$1({ className, children, ref, ...props }: KbdProps): import("react").JSX.Element;
|
|
4
|
+
export declare function KbdGroup({ className, ref, ...props }: KbdGroupProps): import("react").JSX.Element;
|
|
5
|
+
declare const Kbd: typeof Kbd$1 & {
|
|
6
|
+
Group: typeof KbdGroup;
|
|
7
|
+
};
|
|
8
|
+
export { Kbd, type KbdGroupProps, type KbdProps };
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { t as cn } from "../cn-BDi0DfT5.js";
|
|
2
|
+
import { t as trimTextChildren } from "../trim-text-children-CQRFg2fL.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/kbd/kbd.tsx
|
|
5
|
+
function Kbd$1({ className, children, ref, ...props }) {
|
|
6
|
+
return /* @__PURE__ */ jsx("div", {
|
|
7
|
+
className: cn("inline-flex h-md items-center justify-center rounded-full bg-neutral-container-high px-2xs align-middle style-text-default--2 whitespace-nowrap text-neutral-on-container select-none has-[svg]:size-md has-[svg]:p-0 [&>svg]:size-sm", className),
|
|
8
|
+
ref,
|
|
9
|
+
...props,
|
|
10
|
+
children: trimTextChildren(children)
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
// src/components/kbd/kbd-group.tsx
|
|
14
|
+
function KbdGroup({ className, ref, ...props }) {
|
|
15
|
+
return /* @__PURE__ */ jsx("div", {
|
|
16
|
+
className: cn("flex items-center justify-center gap-2xs", className),
|
|
17
|
+
ref,
|
|
18
|
+
...props
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
// src/components/kbd/index.ts
|
|
22
|
+
const Kbd = Object.assign(Kbd$1, { Group: KbdGroup });
|
|
23
|
+
export { Kbd, KbdGroup };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["Kbd","KbdRoot"],"sources":["../../src/components/kbd/kbd.tsx","../../src/components/kbd/kbd-group.tsx","../../src/components/kbd/index.ts"],"sourcesContent":["import { cn } from '@/utils/cn'\nimport { trimTextChildren } from '@/utils/trim-text-children'\n\nimport type { KbdProps } from './kbd.types'\n\nexport function Kbd({ className, children, ref, ...props }: KbdProps) {\n return (\n <div\n className={cn(\n 'inline-flex h-md items-center justify-center rounded-full bg-neutral-container-high px-2xs align-middle style-text-default--2 whitespace-nowrap text-neutral-on-container select-none has-[svg]:size-md has-[svg]:p-0 [&>svg]:size-sm',\n className,\n )}\n ref={ref}\n {...props}\n >\n {trimTextChildren(children)}\n </div>\n )\n}\n","import { cn } from '@/utils/cn'\n\nimport type { KbdGroupProps } from './kbd.types'\n\nexport function KbdGroup({ className, ref, ...props }: KbdGroupProps) {\n return (\n <div\n className={cn('flex items-center justify-center gap-2xs', className)}\n ref={ref}\n {...props}\n />\n )\n}\n","import { Kbd as KbdRoot } from './kbd'\nimport { KbdGroup } from './kbd-group'\n\nconst Kbd = Object.assign(KbdRoot, {\n Group: KbdGroup,\n})\n\nexport type { KbdGroupProps, KbdProps } from './kbd.types'\nexport { KbdGroup } from './kbd-group'\nexport { Kbd }\n"],"mappings":";;;;AAKA,SAAgBA,MAAI,EAAE,WAAW,UAAU,KAAK,GAAG,SAAmB;CACpE,OACE,oBAAC,OAAD;EACE,WAAW,GACT,yOACA,SACF;EACK;EACL,GAAI;EAEH,UAAA,iBAAiB,QAAQ;CACvB,CAAA;AAET;;ACdA,SAAgB,SAAS,EAAE,WAAW,KAAK,GAAG,SAAwB;CACpE,OACE,oBAAC,OAAD;EACE,WAAW,GAAG,4CAA4C,SAAS;EAC9D;EACL,GAAI;CACL,CAAA;AAEL;;ACTA,MAAM,MAAM,OAAO,OAAOC,OAAS,EACjC,OAAO,SACT,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { VariantProps } from "class-variance-authority";
|
|
2
|
+
type LabelProps = React.ComponentProps<'label'> & VariantProps<typeof labelVariants>;
|
|
3
|
+
declare const labelVariants: (props?: ({
|
|
4
|
+
size?: "large" | "medium" | "small" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
export declare function Label({ className, ref, size, ...props }: LabelProps): import("react").JSX.Element;
|
|
7
|
+
export type { LabelProps };
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as Label } from "../label-BgpayDvN.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
// src/components/label/label.types.ts
|
|
4
|
+
const labelVariants = cva("flex items-center gap-2xs select-none hover:cursor-pointer", {
|
|
5
|
+
defaultVariants: { size: "medium" },
|
|
6
|
+
variants: { size: {
|
|
7
|
+
large: "style-text-default-1",
|
|
8
|
+
medium: "style-text-default-0",
|
|
9
|
+
small: "style-text-default--1"
|
|
10
|
+
} }
|
|
11
|
+
});
|
|
12
|
+
// src/components/label/label.tsx
|
|
13
|
+
function Label({ className, ref, size, ...props }) {
|
|
14
|
+
return /* @__PURE__ */ jsx("label", {
|
|
15
|
+
className: labelVariants({
|
|
16
|
+
className,
|
|
17
|
+
size
|
|
18
|
+
}),
|
|
19
|
+
"data-slot": "label",
|
|
20
|
+
htmlFor: props.htmlFor,
|
|
21
|
+
ref,
|
|
22
|
+
...props
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export { Label as t };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=label-BgpayDvN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label-BgpayDvN.js","names":[],"sources":["../src/components/label/label.types.ts","../src/components/label/label.tsx"],"sourcesContent":["import { cva } from 'class-variance-authority'\nimport type { VariantProps } from 'class-variance-authority'\n\nexport type LabelProps = React.ComponentProps<'label'> & VariantProps<typeof labelVariants>\n\nexport const labelVariants = cva('flex items-center gap-2xs select-none hover:cursor-pointer', {\n defaultVariants: {\n size: 'medium',\n },\n variants: {\n size: {\n large: 'style-text-default-1',\n medium: 'style-text-default-0',\n small: 'style-text-default--1',\n },\n },\n})\n","import { labelVariants } from './label.types'\nimport type { LabelProps } from './label.types'\n\nexport function Label({ className, ref, size, ...props }: LabelProps) {\n return (\n <label\n className={labelVariants({ className, size })}\n data-slot=\"label\"\n htmlFor={props.htmlFor}\n ref={ref}\n {...props}\n />\n )\n}\n"],"mappings":";;;AAKA,MAAa,gBAAgB,IAAI,8DAA8D;CAC7F,iBAAiB,EACf,MAAM,SACR;CACA,UAAU,EACR,MAAM;EACJ,OAAO;EACP,QAAQ;EACR,OAAO;CACT,EACF;AACF,CAAC;;ACbD,SAAgB,MAAM,EAAE,WAAW,KAAK,MAAM,GAAG,SAAqB;CACpE,OACE,oBAAC,SAAD;EACE,WAAW,cAAc;GAAE;GAAW;EAAK,CAAC;EAC5C,aAAU;EACV,SAAS,MAAM;EACV;EACL,GAAI;CACL,CAAA;AAEL"}
|