@karakuri-ui/react 0.2.2 → 0.2.4
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 +9 -0
- package/dist/components/ui/accordion.d.mts +49 -0
- package/dist/components/ui/accordion.d.ts +49 -0
- package/dist/components/ui/accordion.js +220 -0
- package/dist/components/ui/accordion.js.map +1 -0
- package/dist/components/ui/accordion.mjs +181 -0
- package/dist/components/ui/accordion.mjs.map +1 -0
- package/dist/components/ui/alert.d.mts +47 -0
- package/dist/components/ui/alert.d.ts +47 -0
- package/dist/components/ui/alert.js +223 -0
- package/dist/components/ui/alert.js.map +1 -0
- package/dist/components/ui/alert.mjs +185 -0
- package/dist/components/ui/alert.mjs.map +1 -0
- package/dist/components/ui/avatar.d.mts +232 -0
- package/dist/components/ui/avatar.d.ts +232 -0
- package/dist/components/ui/avatar.js +250 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/avatar.mjs +209 -0
- package/dist/components/ui/avatar.mjs.map +1 -0
- package/dist/components/ui/badge.d.mts +31 -0
- package/dist/components/ui/badge.d.ts +31 -0
- package/dist/components/ui/badge.js +205 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/badge.mjs +170 -0
- package/dist/components/ui/badge.mjs.map +1 -0
- package/dist/components/ui/breadcrumb.d.mts +57 -0
- package/dist/components/ui/breadcrumb.d.ts +57 -0
- package/dist/components/ui/breadcrumb.js +209 -0
- package/dist/components/ui/breadcrumb.js.map +1 -0
- package/dist/components/ui/breadcrumb.mjs +168 -0
- package/dist/components/ui/breadcrumb.mjs.map +1 -0
- package/dist/components/ui/button-group.d.mts +22 -0
- package/dist/components/ui/button-group.d.ts +22 -0
- package/dist/components/ui/button-group.js +107 -0
- package/dist/components/ui/button-group.js.map +1 -0
- package/dist/components/ui/button-group.mjs +72 -0
- package/dist/components/ui/button-group.mjs.map +1 -0
- package/dist/components/ui/button.d.mts +31 -0
- package/dist/components/ui/button.d.ts +31 -0
- package/dist/components/ui/button.js +176 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/button.mjs +141 -0
- package/dist/components/ui/button.mjs.map +1 -0
- package/dist/components/ui/card.d.mts +77 -0
- package/dist/components/ui/card.d.ts +77 -0
- package/dist/components/ui/card.js +370 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/card.mjs +328 -0
- package/dist/components/ui/card.mjs.map +1 -0
- package/dist/{chart.js → components/ui/chart.js} +29 -39
- package/dist/components/ui/chart.js.map +1 -0
- package/dist/{chart.mjs → components/ui/chart.mjs} +21 -31
- package/dist/components/ui/chart.mjs.map +1 -0
- package/dist/components/ui/checkbox.d.mts +24 -0
- package/dist/components/ui/checkbox.d.ts +24 -0
- package/dist/components/ui/checkbox.js +173 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/checkbox.mjs +138 -0
- package/dist/components/ui/checkbox.mjs.map +1 -0
- package/dist/components/ui/divider.d.mts +27 -0
- package/dist/components/ui/divider.d.ts +27 -0
- package/dist/components/ui/divider.js +147 -0
- package/dist/components/ui/divider.js.map +1 -0
- package/dist/components/ui/divider.mjs +112 -0
- package/dist/components/ui/divider.mjs.map +1 -0
- package/dist/components/ui/drawer.d.mts +51 -0
- package/dist/components/ui/drawer.d.ts +51 -0
- package/dist/components/ui/drawer.js +225 -0
- package/dist/components/ui/drawer.js.map +1 -0
- package/dist/components/ui/drawer.mjs +178 -0
- package/dist/components/ui/drawer.mjs.map +1 -0
- package/dist/components/ui/dropdown.d.mts +59 -0
- package/dist/components/ui/dropdown.d.ts +59 -0
- package/dist/components/ui/dropdown.js +310 -0
- package/dist/components/ui/dropdown.js.map +1 -0
- package/dist/components/ui/dropdown.mjs +263 -0
- package/dist/components/ui/dropdown.mjs.map +1 -0
- package/dist/components/ui/field.d.mts +33 -0
- package/dist/components/ui/field.d.ts +33 -0
- package/dist/components/ui/field.js +146 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/field.mjs +108 -0
- package/dist/components/ui/field.mjs.map +1 -0
- package/dist/components/ui/icon-button.d.mts +20 -0
- package/dist/components/ui/icon-button.d.ts +20 -0
- package/dist/components/ui/icon-button.js +147 -0
- package/dist/components/ui/icon-button.js.map +1 -0
- package/dist/components/ui/icon-button.mjs +112 -0
- package/dist/components/ui/icon-button.mjs.map +1 -0
- package/dist/components/ui/index.d.mts +55 -0
- package/dist/components/ui/index.d.ts +55 -0
- package/dist/components/ui/index.js +476 -0
- package/dist/components/ui/index.js.map +1 -0
- package/dist/components/ui/index.mjs +246 -0
- package/dist/components/ui/index.mjs.map +1 -0
- package/dist/components/ui/input.d.mts +20 -0
- package/dist/components/ui/input.d.ts +20 -0
- package/dist/components/ui/input.js +250 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/input.mjs +215 -0
- package/dist/components/ui/input.mjs.map +1 -0
- package/dist/components/ui/metric-card.d.mts +53 -0
- package/dist/components/ui/metric-card.d.ts +53 -0
- package/dist/components/ui/metric-card.js +258 -0
- package/dist/components/ui/metric-card.js.map +1 -0
- package/dist/components/ui/metric-card.mjs +217 -0
- package/dist/components/ui/metric-card.mjs.map +1 -0
- package/dist/components/ui/modal.d.mts +77 -0
- package/dist/components/ui/modal.d.ts +77 -0
- package/dist/components/ui/modal.js +396 -0
- package/dist/components/ui/modal.js.map +1 -0
- package/dist/components/ui/modal.mjs +338 -0
- package/dist/components/ui/modal.mjs.map +1 -0
- package/dist/components/ui/navigation-menu.d.mts +139 -0
- package/dist/components/ui/navigation-menu.d.ts +139 -0
- package/dist/components/ui/navigation-menu.js +531 -0
- package/dist/components/ui/navigation-menu.js.map +1 -0
- package/dist/components/ui/navigation-menu.mjs +488 -0
- package/dist/components/ui/navigation-menu.mjs.map +1 -0
- package/dist/components/ui/pagination.d.mts +130 -0
- package/dist/components/ui/pagination.d.ts +130 -0
- package/dist/components/ui/pagination.js +495 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/pagination.mjs +449 -0
- package/dist/components/ui/pagination.mjs.map +1 -0
- package/dist/components/ui/popover.d.mts +41 -0
- package/dist/components/ui/popover.d.ts +41 -0
- package/dist/components/ui/popover.js +175 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/popover.mjs +133 -0
- package/dist/components/ui/popover.mjs.map +1 -0
- package/dist/components/ui/progress.d.mts +35 -0
- package/dist/components/ui/progress.d.ts +35 -0
- package/dist/components/ui/progress.js +194 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/progress.mjs +159 -0
- package/dist/components/ui/progress.mjs.map +1 -0
- package/dist/components/ui/radio-group.d.mts +40 -0
- package/dist/components/ui/radio-group.d.ts +40 -0
- package/dist/components/ui/radio-group.js +177 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/radio-group.mjs +140 -0
- package/dist/components/ui/radio-group.mjs.map +1 -0
- package/dist/components/ui/segmented.d.mts +30 -0
- package/dist/components/ui/segmented.d.ts +30 -0
- package/dist/components/ui/segmented.js +241 -0
- package/dist/components/ui/segmented.js.map +1 -0
- package/dist/components/ui/segmented.mjs +204 -0
- package/dist/components/ui/segmented.mjs.map +1 -0
- package/dist/components/ui/select.d.mts +31 -0
- package/dist/components/ui/select.d.ts +31 -0
- package/dist/components/ui/select.js +317 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/select.mjs +276 -0
- package/dist/components/ui/select.mjs.map +1 -0
- package/dist/components/ui/skeleton.d.mts +26 -0
- package/dist/components/ui/skeleton.d.ts +26 -0
- package/dist/components/ui/skeleton.js +144 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/skeleton.mjs +109 -0
- package/dist/components/ui/skeleton.mjs.map +1 -0
- package/dist/components/ui/slider.d.mts +38 -0
- package/dist/components/ui/slider.d.ts +38 -0
- package/dist/components/ui/slider.js +180 -0
- package/dist/components/ui/slider.js.map +1 -0
- package/dist/components/ui/slider.mjs +145 -0
- package/dist/components/ui/slider.mjs.map +1 -0
- package/dist/components/ui/spinner.d.mts +23 -0
- package/dist/components/ui/spinner.d.ts +23 -0
- package/dist/components/ui/spinner.js +471 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/spinner.mjs +436 -0
- package/dist/components/ui/spinner.mjs.map +1 -0
- package/dist/components/ui/switch.d.mts +22 -0
- package/dist/components/ui/switch.d.ts +22 -0
- package/dist/components/ui/switch.js +173 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/switch.mjs +138 -0
- package/dist/components/ui/switch.mjs.map +1 -0
- package/dist/components/ui/table.d.mts +74 -0
- package/dist/components/ui/table.d.ts +74 -0
- package/dist/components/ui/table.js +240 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/table.mjs +199 -0
- package/dist/components/ui/table.mjs.map +1 -0
- package/dist/components/ui/tabs.d.mts +40 -0
- package/dist/components/ui/tabs.d.ts +40 -0
- package/dist/components/ui/tabs.js +238 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/tabs.mjs +199 -0
- package/dist/components/ui/tabs.mjs.map +1 -0
- package/dist/components/ui/textarea.d.mts +19 -0
- package/dist/components/ui/textarea.d.ts +19 -0
- package/dist/components/ui/textarea.js +181 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/textarea.mjs +146 -0
- package/dist/components/ui/textarea.mjs.map +1 -0
- package/dist/components/ui/toast.d.mts +93 -0
- package/dist/components/ui/toast.d.ts +93 -0
- package/dist/components/ui/toast.js +429 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/toast.mjs +393 -0
- package/dist/components/ui/toast.mjs.map +1 -0
- package/dist/components/ui/toggle-group.d.mts +47 -0
- package/dist/components/ui/toggle-group.d.ts +47 -0
- package/dist/components/ui/toggle-group.js +186 -0
- package/dist/components/ui/toggle-group.js.map +1 -0
- package/dist/components/ui/toggle-group.mjs +149 -0
- package/dist/components/ui/toggle-group.mjs.map +1 -0
- package/dist/components/ui/toggle.d.mts +19 -0
- package/dist/components/ui/toggle.d.ts +19 -0
- package/dist/components/ui/toggle.js +194 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/toggle.mjs +159 -0
- package/dist/components/ui/toggle.mjs.map +1 -0
- package/dist/components/ui/tooltip.d.mts +37 -0
- package/dist/components/ui/tooltip.d.ts +37 -0
- package/dist/components/ui/tooltip.js +137 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/components/ui/tooltip.mjs +96 -0
- package/dist/components/ui/tooltip.mjs.map +1 -0
- package/dist/lib/utils.d.mts +10 -0
- package/dist/lib/utils.d.ts +10 -0
- package/dist/lib/utils.js +33 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/utils.mjs +9 -0
- package/dist/lib/utils.mjs.map +1 -0
- package/package.json +11 -11
- package/dist/chart.js.map +0 -1
- package/dist/chart.mjs.map +0 -1
- package/dist/index.d.mts +0 -1636
- package/dist/index.d.ts +0 -1636
- package/dist/index.js +0 -7291
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -7048
- package/dist/index.mjs.map +0 -1
- /package/dist/{chart.d.mts → components/ui/chart.d.mts} +0 -0
- /package/dist/{chart.d.ts → components/ui/chart.d.ts} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
interface FieldContextValue {
|
|
6
|
+
id: string;
|
|
7
|
+
error?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare function useFieldContext(): FieldContextValue | null;
|
|
11
|
+
declare const fieldVariants: (props?: ({
|
|
12
|
+
gap?: "default" | "sm" | "lg" | "none" | "xs" | null | undefined;
|
|
13
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
14
|
+
interface FieldProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof fieldVariants> {
|
|
15
|
+
error?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface FieldLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
19
|
+
required?: boolean;
|
|
20
|
+
}
|
|
21
|
+
declare const FieldLabel: React.ForwardRefExoticComponent<FieldLabelProps & React.RefAttributes<HTMLLabelElement>>;
|
|
22
|
+
declare const FieldError: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
23
|
+
declare const FieldCharCount: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
24
|
+
declare const Field: React.ForwardRefExoticComponent<FieldProps & React.RefAttributes<HTMLDivElement>> & {
|
|
25
|
+
Label: React.ForwardRefExoticComponent<FieldLabelProps & React.RefAttributes<HTMLLabelElement>>;
|
|
26
|
+
Error: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
27
|
+
CharCount: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
28
|
+
};
|
|
29
|
+
declare namespace Field {
|
|
30
|
+
type LabelProps = FieldLabelProps;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { Field, FieldCharCount, FieldError, FieldLabel, type FieldLabelProps, type FieldProps, useFieldContext };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
interface FieldContextValue {
|
|
6
|
+
id: string;
|
|
7
|
+
error?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare function useFieldContext(): FieldContextValue | null;
|
|
11
|
+
declare const fieldVariants: (props?: ({
|
|
12
|
+
gap?: "default" | "sm" | "lg" | "none" | "xs" | null | undefined;
|
|
13
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
14
|
+
interface FieldProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof fieldVariants> {
|
|
15
|
+
error?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface FieldLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
19
|
+
required?: boolean;
|
|
20
|
+
}
|
|
21
|
+
declare const FieldLabel: React.ForwardRefExoticComponent<FieldLabelProps & React.RefAttributes<HTMLLabelElement>>;
|
|
22
|
+
declare const FieldError: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
23
|
+
declare const FieldCharCount: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
24
|
+
declare const Field: React.ForwardRefExoticComponent<FieldProps & React.RefAttributes<HTMLDivElement>> & {
|
|
25
|
+
Label: React.ForwardRefExoticComponent<FieldLabelProps & React.RefAttributes<HTMLLabelElement>>;
|
|
26
|
+
Error: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
27
|
+
CharCount: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
28
|
+
};
|
|
29
|
+
declare namespace Field {
|
|
30
|
+
type LabelProps = FieldLabelProps;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { Field, FieldCharCount, FieldError, FieldLabel, type FieldLabelProps, type FieldProps, useFieldContext };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var field_exports = {};
|
|
31
|
+
__export(field_exports, {
|
|
32
|
+
Field: () => Field,
|
|
33
|
+
FieldCharCount: () => FieldCharCount,
|
|
34
|
+
FieldError: () => FieldError,
|
|
35
|
+
FieldLabel: () => FieldLabel,
|
|
36
|
+
useFieldContext: () => useFieldContext
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(field_exports);
|
|
39
|
+
var React = __toESM(require("react"));
|
|
40
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
41
|
+
var import_utils = require("../../lib/utils");
|
|
42
|
+
const FieldContext = React.createContext(null);
|
|
43
|
+
function useFieldContext() {
|
|
44
|
+
return React.useContext(FieldContext);
|
|
45
|
+
}
|
|
46
|
+
const fieldVariants = (0, import_class_variance_authority.cva)("flex flex-col", {
|
|
47
|
+
variants: {
|
|
48
|
+
gap: {
|
|
49
|
+
none: "gap-0",
|
|
50
|
+
xs: "gap-1",
|
|
51
|
+
sm: "gap-1.5",
|
|
52
|
+
default: "gap-2",
|
|
53
|
+
lg: "gap-3"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
defaultVariants: {
|
|
57
|
+
gap: "default"
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const FieldRoot = React.forwardRef(
|
|
61
|
+
({ className, gap, error, disabled, children, ...props }, ref) => {
|
|
62
|
+
const id = React.useId();
|
|
63
|
+
return /* @__PURE__ */ React.createElement(FieldContext.Provider, { value: { id, error, disabled } }, /* @__PURE__ */ React.createElement(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
ref,
|
|
67
|
+
className: (0, import_utils.cn)(fieldVariants({ gap }), className),
|
|
68
|
+
"data-error": error || void 0,
|
|
69
|
+
"data-disabled": disabled || void 0,
|
|
70
|
+
...props
|
|
71
|
+
},
|
|
72
|
+
children
|
|
73
|
+
));
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
FieldRoot.displayName = "Field";
|
|
77
|
+
const FieldLabel = React.forwardRef(
|
|
78
|
+
({ className, required, children, ...props }, ref) => {
|
|
79
|
+
const context = useFieldContext();
|
|
80
|
+
return /* @__PURE__ */ React.createElement(
|
|
81
|
+
"label",
|
|
82
|
+
{
|
|
83
|
+
ref,
|
|
84
|
+
htmlFor: context?.id,
|
|
85
|
+
className: (0, import_utils.cn)(
|
|
86
|
+
"text-md font-semibold text-foreground",
|
|
87
|
+
// 14px - primary field identifier
|
|
88
|
+
context?.disabled && "opacity-50 cursor-not-allowed",
|
|
89
|
+
className
|
|
90
|
+
),
|
|
91
|
+
...props
|
|
92
|
+
},
|
|
93
|
+
children,
|
|
94
|
+
required && /* @__PURE__ */ React.createElement("span", { className: "text-error ml-0.5" }, "*")
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
FieldLabel.displayName = "FieldLabel";
|
|
99
|
+
const FieldError = React.forwardRef(({ className, children, ...props }, ref) => {
|
|
100
|
+
const context = useFieldContext();
|
|
101
|
+
if (!children) return null;
|
|
102
|
+
return /* @__PURE__ */ React.createElement(
|
|
103
|
+
"p",
|
|
104
|
+
{
|
|
105
|
+
ref,
|
|
106
|
+
id: context ? `${context.id}-error` : void 0,
|
|
107
|
+
role: "alert",
|
|
108
|
+
className: (0, import_utils.cn)("text-xs text-error pl-1", className),
|
|
109
|
+
...props
|
|
110
|
+
},
|
|
111
|
+
children
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
FieldError.displayName = "FieldError";
|
|
115
|
+
const FieldCharCount = React.forwardRef(({ className, ...props }, ref) => {
|
|
116
|
+
const context = useFieldContext();
|
|
117
|
+
return /* @__PURE__ */ React.createElement(
|
|
118
|
+
"p",
|
|
119
|
+
{
|
|
120
|
+
ref,
|
|
121
|
+
id: context ? `${context.id}-charcount` : void 0,
|
|
122
|
+
className: (0, import_utils.cn)(
|
|
123
|
+
"text-xs text-text-muted text-right pr-1 -mt-1",
|
|
124
|
+
// 12px - right-aligned, 4px gap from input (gap-2 8px - mt-1 4px)
|
|
125
|
+
context?.disabled && "opacity-50",
|
|
126
|
+
className
|
|
127
|
+
),
|
|
128
|
+
...props
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
FieldCharCount.displayName = "FieldCharCount";
|
|
133
|
+
const Field = Object.assign(FieldRoot, {
|
|
134
|
+
Label: FieldLabel,
|
|
135
|
+
Error: FieldError,
|
|
136
|
+
CharCount: FieldCharCount
|
|
137
|
+
});
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
Field,
|
|
141
|
+
FieldCharCount,
|
|
142
|
+
FieldError,
|
|
143
|
+
FieldLabel,
|
|
144
|
+
useFieldContext
|
|
145
|
+
});
|
|
146
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/field.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// Field Context for sharing state between components\ninterface FieldContextValue {\n id: string\n error?: boolean\n disabled?: boolean\n}\n\nconst FieldContext = React.createContext<FieldContextValue | null>(null)\n\nfunction useFieldContext() {\n return React.useContext(FieldContext)\n}\n\n// Field wrapper\nconst fieldVariants = cva('flex flex-col', {\n variants: {\n gap: {\n none: 'gap-0',\n xs: 'gap-1',\n sm: 'gap-1.5',\n default: 'gap-2',\n lg: 'gap-3',\n },\n },\n defaultVariants: {\n gap: 'default',\n },\n})\n\nexport interface FieldProps\n extends React.HTMLAttributes<HTMLDivElement>,\n VariantProps<typeof fieldVariants> {\n error?: boolean\n disabled?: boolean\n}\n\nconst FieldRoot = React.forwardRef<HTMLDivElement, FieldProps>(\n ({ className, gap, error, disabled, children, ...props }, ref) => {\n const id = React.useId()\n\n return (\n <FieldContext.Provider value={{ id, error, disabled }}>\n <div\n ref={ref}\n className={cn(fieldVariants({ gap }), className)}\n data-error={error || undefined}\n data-disabled={disabled || undefined}\n {...props}\n >\n {children}\n </div>\n </FieldContext.Provider>\n )\n }\n)\nFieldRoot.displayName = 'Field'\n\n// Field Label\nexport interface FieldLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {\n required?: boolean\n}\n\nconst FieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(\n ({ className, required, children, ...props }, ref) => {\n const context = useFieldContext()\n\n return (\n <label\n ref={ref}\n htmlFor={context?.id}\n className={cn(\n 'text-md font-semibold text-foreground', // 14px - primary field identifier\n context?.disabled && 'opacity-50 cursor-not-allowed',\n className\n )}\n {...props}\n >\n {children}\n {required && <span className=\"text-error ml-0.5\">*</span>}\n </label>\n )\n }\n)\nFieldLabel.displayName = 'FieldLabel'\n\n// Field Error\nconst FieldError = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\n const context = useFieldContext()\n\n if (!children) return null\n\n return (\n <p\n ref={ref}\n id={context ? `${context.id}-error` : undefined}\n role=\"alert\"\n className={cn('text-xs text-error pl-1', className)} // 12px - color-distinguished, left-aligned with input text\n {...props}\n >\n {children}\n </p>\n )\n})\nFieldError.displayName = 'FieldError'\n\n// Field Character Count\nconst FieldCharCount = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const context = useFieldContext()\n\n return (\n <p\n ref={ref}\n id={context ? `${context.id}-charcount` : undefined}\n className={cn(\n 'text-xs text-text-muted text-right pr-1 -mt-1', // 12px - right-aligned, 4px gap from input (gap-2 8px - mt-1 4px)\n context?.disabled && 'opacity-50',\n className\n )}\n {...props}\n />\n )\n})\nFieldCharCount.displayName = 'FieldCharCount'\n\n// ─── Namespace ──────────────────────────────────────────\nconst Field = Object.assign(FieldRoot, {\n Label: FieldLabel,\n Error: FieldError,\n CharCount: FieldCharCount,\n})\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nnamespace Field {\n export type LabelProps = FieldLabelProps\n}\n\nexport { Field, FieldLabel, FieldError, FieldCharCount, useFieldContext }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AACvB,sCAAuC;AACvC,mBAAmB;AASnB,MAAM,eAAe,MAAM,cAAwC,IAAI;AA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AAEhC,MAAI,CAAC,SAAU,QAAO;AAEtB,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,IAAI,UAAU,GAAG,QAAQ,EAAE,WAAW;AAAA,MACtC,MAAK;AAAA,MACL,eAAW,iBAAG,2BAA2B,SAAS;AAAA,MACjD,GAAG;AAAA;AAAA,IAEH;AAAA,EACH;AAEJ,CAAC;AACD,WAAW,cAAc;AAGzB,MAAM,iBAAiB,MAAM,WAG3B,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAAQ;AAClC,QAAM,UAAU,gBAAgB;AAEhC,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,IAAI,UAAU,GAAG,QAAQ,EAAE,eAAe;AAAA,MAC1C,eAAW;AAAA,QACT;AAAA;AAAA,QACA,SAAS,YAAY;AAAA,QACrB;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ,CAAC;AACD,eAAe,cAAc;AAG7B,MAAM,QAAQ,OAAO,OAAO,WAAW;AAAA,EACrC,OAAO;AAAA,EACP,OAAO;AAAA,EACP,WAAW;AACb,CAAC;","names":[]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
const FieldContext = React.createContext(null);
|
|
6
|
+
function useFieldContext() {
|
|
7
|
+
return React.useContext(FieldContext);
|
|
8
|
+
}
|
|
9
|
+
const fieldVariants = cva("flex flex-col", {
|
|
10
|
+
variants: {
|
|
11
|
+
gap: {
|
|
12
|
+
none: "gap-0",
|
|
13
|
+
xs: "gap-1",
|
|
14
|
+
sm: "gap-1.5",
|
|
15
|
+
default: "gap-2",
|
|
16
|
+
lg: "gap-3"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
gap: "default"
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const FieldRoot = React.forwardRef(
|
|
24
|
+
({ className, gap, error, disabled, children, ...props }, ref) => {
|
|
25
|
+
const id = React.useId();
|
|
26
|
+
return /* @__PURE__ */ React.createElement(FieldContext.Provider, { value: { id, error, disabled } }, /* @__PURE__ */ React.createElement(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
ref,
|
|
30
|
+
className: cn(fieldVariants({ gap }), className),
|
|
31
|
+
"data-error": error || void 0,
|
|
32
|
+
"data-disabled": disabled || void 0,
|
|
33
|
+
...props
|
|
34
|
+
},
|
|
35
|
+
children
|
|
36
|
+
));
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
FieldRoot.displayName = "Field";
|
|
40
|
+
const FieldLabel = React.forwardRef(
|
|
41
|
+
({ className, required, children, ...props }, ref) => {
|
|
42
|
+
const context = useFieldContext();
|
|
43
|
+
return /* @__PURE__ */ React.createElement(
|
|
44
|
+
"label",
|
|
45
|
+
{
|
|
46
|
+
ref,
|
|
47
|
+
htmlFor: context?.id,
|
|
48
|
+
className: cn(
|
|
49
|
+
"text-md font-semibold text-foreground",
|
|
50
|
+
// 14px - primary field identifier
|
|
51
|
+
context?.disabled && "opacity-50 cursor-not-allowed",
|
|
52
|
+
className
|
|
53
|
+
),
|
|
54
|
+
...props
|
|
55
|
+
},
|
|
56
|
+
children,
|
|
57
|
+
required && /* @__PURE__ */ React.createElement("span", { className: "text-error ml-0.5" }, "*")
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
FieldLabel.displayName = "FieldLabel";
|
|
62
|
+
const FieldError = React.forwardRef(({ className, children, ...props }, ref) => {
|
|
63
|
+
const context = useFieldContext();
|
|
64
|
+
if (!children) return null;
|
|
65
|
+
return /* @__PURE__ */ React.createElement(
|
|
66
|
+
"p",
|
|
67
|
+
{
|
|
68
|
+
ref,
|
|
69
|
+
id: context ? `${context.id}-error` : void 0,
|
|
70
|
+
role: "alert",
|
|
71
|
+
className: cn("text-xs text-error pl-1", className),
|
|
72
|
+
...props
|
|
73
|
+
},
|
|
74
|
+
children
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
FieldError.displayName = "FieldError";
|
|
78
|
+
const FieldCharCount = React.forwardRef(({ className, ...props }, ref) => {
|
|
79
|
+
const context = useFieldContext();
|
|
80
|
+
return /* @__PURE__ */ React.createElement(
|
|
81
|
+
"p",
|
|
82
|
+
{
|
|
83
|
+
ref,
|
|
84
|
+
id: context ? `${context.id}-charcount` : void 0,
|
|
85
|
+
className: cn(
|
|
86
|
+
"text-xs text-text-muted text-right pr-1 -mt-1",
|
|
87
|
+
// 12px - right-aligned, 4px gap from input (gap-2 8px - mt-1 4px)
|
|
88
|
+
context?.disabled && "opacity-50",
|
|
89
|
+
className
|
|
90
|
+
),
|
|
91
|
+
...props
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
FieldCharCount.displayName = "FieldCharCount";
|
|
96
|
+
const Field = Object.assign(FieldRoot, {
|
|
97
|
+
Label: FieldLabel,
|
|
98
|
+
Error: FieldError,
|
|
99
|
+
CharCount: FieldCharCount
|
|
100
|
+
});
|
|
101
|
+
export {
|
|
102
|
+
Field,
|
|
103
|
+
FieldCharCount,
|
|
104
|
+
FieldError,
|
|
105
|
+
FieldLabel,
|
|
106
|
+
useFieldContext
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=field.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/field.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// Field Context for sharing state between components\ninterface FieldContextValue {\n id: string\n error?: boolean\n disabled?: boolean\n}\n\nconst FieldContext = React.createContext<FieldContextValue | null>(null)\n\nfunction useFieldContext() {\n return React.useContext(FieldContext)\n}\n\n// Field wrapper\nconst fieldVariants = cva('flex flex-col', {\n variants: {\n gap: {\n none: 'gap-0',\n xs: 'gap-1',\n sm: 'gap-1.5',\n default: 'gap-2',\n lg: 'gap-3',\n },\n },\n defaultVariants: {\n gap: 'default',\n },\n})\n\nexport interface FieldProps\n extends React.HTMLAttributes<HTMLDivElement>,\n VariantProps<typeof fieldVariants> {\n error?: boolean\n disabled?: boolean\n}\n\nconst FieldRoot = React.forwardRef<HTMLDivElement, FieldProps>(\n ({ className, gap, error, disabled, children, ...props }, ref) => {\n const id = React.useId()\n\n return (\n <FieldContext.Provider value={{ id, error, disabled }}>\n <div\n ref={ref}\n className={cn(fieldVariants({ gap }), className)}\n data-error={error || undefined}\n data-disabled={disabled || undefined}\n {...props}\n >\n {children}\n </div>\n </FieldContext.Provider>\n )\n }\n)\nFieldRoot.displayName = 'Field'\n\n// Field Label\nexport interface FieldLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {\n required?: boolean\n}\n\nconst FieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(\n ({ className, required, children, ...props }, ref) => {\n const context = useFieldContext()\n\n return (\n <label\n ref={ref}\n htmlFor={context?.id}\n className={cn(\n 'text-md font-semibold text-foreground', // 14px - primary field identifier\n context?.disabled && 'opacity-50 cursor-not-allowed',\n className\n )}\n {...props}\n >\n {children}\n {required && <span className=\"text-error ml-0.5\">*</span>}\n </label>\n )\n }\n)\nFieldLabel.displayName = 'FieldLabel'\n\n// Field Error\nconst FieldError = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\n const context = useFieldContext()\n\n if (!children) return null\n\n return (\n <p\n ref={ref}\n id={context ? `${context.id}-error` : undefined}\n role=\"alert\"\n className={cn('text-xs text-error pl-1', className)} // 12px - color-distinguished, left-aligned with input text\n {...props}\n >\n {children}\n </p>\n )\n})\nFieldError.displayName = 'FieldError'\n\n// Field Character Count\nconst FieldCharCount = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const context = useFieldContext()\n\n return (\n <p\n ref={ref}\n id={context ? `${context.id}-charcount` : undefined}\n className={cn(\n 'text-xs text-text-muted text-right pr-1 -mt-1', // 12px - right-aligned, 4px gap from input (gap-2 8px - mt-1 4px)\n context?.disabled && 'opacity-50',\n className\n )}\n {...props}\n />\n )\n})\nFieldCharCount.displayName = 'FieldCharCount'\n\n// ─── Namespace ──────────────────────────────────────────\nconst Field = Object.assign(FieldRoot, {\n Label: FieldLabel,\n Error: FieldError,\n CharCount: FieldCharCount,\n})\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nnamespace Field {\n export type LabelProps = FieldLabelProps\n}\n\nexport { Field, FieldLabel, FieldError, FieldCharCount, useFieldContext }\n"],"mappings":";AAEA,YAAY,WAAW;AACvB,SAAS,WAA8B;AACvC,SAAS,UAAU;AASnB,MAAM,eAAe,MAAM,cAAwC,IAAI;AAEvE,SAAS,kBAAkB;AACzB,SAAO,MAAM,WAAW,YAAY;AACtC;AAGA,MAAM,gBAAgB,IAAI,iBAAiB;AAAA,EACzC,UAAU;AAAA,IACR,KAAK;AAAA,MACH,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,IAAI;AAAA,IACN;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,KAAK;AAAA,EACP;AACF,CAAC;AASD,MAAM,YAAY,MAAM;AAAA,EACtB,CAAC,EAAE,WAAW,KAAK,OAAO,UAAU,UAAU,GAAG,MAAM,GAAG,QAAQ;AAChE,UAAM,KAAK,MAAM,MAAM;AAEvB,WACE,oCAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,IAAI,OAAO,SAAS,KAClD;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,WAAW,GAAG,cAAc,EAAE,IAAI,CAAC,GAAG,SAAS;AAAA,QAC/C,cAAY,SAAS;AAAA,QACrB,iBAAe,YAAY;AAAA,QAC1B,GAAG;AAAA;AAAA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A,EACP,WAAW;AACb,CAAC;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
import { ButtonColor } from './button.mjs';
|
|
5
|
+
|
|
6
|
+
declare const iconButtonVariants: (props?: ({
|
|
7
|
+
variant?: "outline" | "solid" | "subtle" | "ghost" | null | undefined;
|
|
8
|
+
size?: "default" | "sm" | "lg" | "md" | "xs" | null | undefined;
|
|
9
|
+
radius?: "default" | "sm" | "lg" | "base" | "none" | "xl" | "2xl" | "3xl" | "full" | null | undefined;
|
|
10
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
11
|
+
interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof iconButtonVariants> {
|
|
12
|
+
/** Solid variant color */
|
|
13
|
+
color?: ButtonColor;
|
|
14
|
+
asChild?: boolean;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
pressEffect?: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
19
|
+
|
|
20
|
+
export { IconButton, type IconButtonProps, iconButtonVariants };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
import { ButtonColor } from './button.js';
|
|
5
|
+
|
|
6
|
+
declare const iconButtonVariants: (props?: ({
|
|
7
|
+
variant?: "outline" | "solid" | "subtle" | "ghost" | null | undefined;
|
|
8
|
+
size?: "default" | "sm" | "lg" | "md" | "xs" | null | undefined;
|
|
9
|
+
radius?: "default" | "sm" | "lg" | "base" | "none" | "xl" | "2xl" | "3xl" | "full" | null | undefined;
|
|
10
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
11
|
+
interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof iconButtonVariants> {
|
|
12
|
+
/** Solid variant color */
|
|
13
|
+
color?: ButtonColor;
|
|
14
|
+
asChild?: boolean;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
pressEffect?: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
19
|
+
|
|
20
|
+
export { IconButton, type IconButtonProps, iconButtonVariants };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var icon_button_exports = {};
|
|
31
|
+
__export(icon_button_exports, {
|
|
32
|
+
IconButton: () => IconButton,
|
|
33
|
+
iconButtonVariants: () => iconButtonVariants
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(icon_button_exports);
|
|
36
|
+
var React = __toESM(require("react"));
|
|
37
|
+
var import_react_slot = require("@radix-ui/react-slot");
|
|
38
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
39
|
+
var import_utils = require("../../lib/utils");
|
|
40
|
+
var import_button_group = require("./button-group");
|
|
41
|
+
const solidColorMap = {
|
|
42
|
+
default: "bg-foreground text-background hover:bg-foreground/90 active:bg-foreground/80",
|
|
43
|
+
primary: "bg-primary text-primary-foreground hover:bg-primary-hover active:bg-primary-active",
|
|
44
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary-hover active:bg-secondary-active",
|
|
45
|
+
destructive: "bg-error text-error-foreground hover:bg-error-hover active:bg-error-active"
|
|
46
|
+
};
|
|
47
|
+
const iconButtonVariants = (0, import_class_variance_authority.cva)(
|
|
48
|
+
"inline-flex items-center justify-center transition-all duration-micro focus-visible:focus-ring disabled:pointer-events-none disabled:opacity-50",
|
|
49
|
+
{
|
|
50
|
+
variants: {
|
|
51
|
+
variant: {
|
|
52
|
+
solid: "",
|
|
53
|
+
outline: "border border-border-form bg-background text-foreground hover:bg-background-muted",
|
|
54
|
+
ghost: "text-foreground hover:bg-background-muted",
|
|
55
|
+
subtle: "text-text-muted hover:text-foreground"
|
|
56
|
+
},
|
|
57
|
+
size: {
|
|
58
|
+
xs: "h-7 w-7",
|
|
59
|
+
// 28px - spacing.7
|
|
60
|
+
sm: "h-8 w-8",
|
|
61
|
+
// 32px - spacing.8
|
|
62
|
+
md: "h-9 w-9",
|
|
63
|
+
// 36px - spacing.9
|
|
64
|
+
default: "h-10 w-10",
|
|
65
|
+
// 40px - spacing.10
|
|
66
|
+
lg: "h-12 w-12"
|
|
67
|
+
// 48px - spacing.12
|
|
68
|
+
},
|
|
69
|
+
radius: {
|
|
70
|
+
none: "rounded-none",
|
|
71
|
+
// 0px - primitive.borderRadius.none
|
|
72
|
+
sm: "rounded-sm",
|
|
73
|
+
// 2px - primitive.borderRadius.sm
|
|
74
|
+
base: "rounded",
|
|
75
|
+
// 4px - primitive.borderRadius.base
|
|
76
|
+
default: "rounded-md",
|
|
77
|
+
// 6px - primitive.borderRadius.md (Figma button default)
|
|
78
|
+
lg: "rounded-lg",
|
|
79
|
+
// 8px - primitive.borderRadius.lg
|
|
80
|
+
xl: "rounded-xl",
|
|
81
|
+
// 12px - primitive.borderRadius.xl
|
|
82
|
+
"2xl": "rounded-2xl",
|
|
83
|
+
// 16px - primitive.borderRadius.2xl
|
|
84
|
+
"3xl": "rounded-3xl",
|
|
85
|
+
// 24px - primitive.borderRadius.3xl
|
|
86
|
+
full: "rounded-full"
|
|
87
|
+
// 9999px - primitive.borderRadius.full
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
defaultVariants: {
|
|
91
|
+
variant: "solid",
|
|
92
|
+
size: "default",
|
|
93
|
+
radius: "default"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
const IconButton = React.forwardRef(
|
|
98
|
+
({ className, variant: variantProp, color: colorProp, size: sizeProp, radius: radiusProp, asChild = false, loading, pressEffect, children, disabled: disabledProp, ...props }, ref) => {
|
|
99
|
+
const groupContext = (0, import_button_group.useButtonGroup)();
|
|
100
|
+
const variant = variantProp ?? groupContext?.variant ?? "solid";
|
|
101
|
+
const color = colorProp ?? "default";
|
|
102
|
+
const size = sizeProp ?? groupContext?.size;
|
|
103
|
+
const radius = radiusProp ?? groupContext?.radius;
|
|
104
|
+
const disabled = disabledProp ?? groupContext?.disabled;
|
|
105
|
+
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
106
|
+
const iconSize = {
|
|
107
|
+
xs: "icon-xs",
|
|
108
|
+
// 14px
|
|
109
|
+
sm: "icon-sm",
|
|
110
|
+
// 16px
|
|
111
|
+
md: "icon-sm",
|
|
112
|
+
// 16px
|
|
113
|
+
default: "icon-md",
|
|
114
|
+
// 20px
|
|
115
|
+
lg: "icon-lg"
|
|
116
|
+
// 24px
|
|
117
|
+
}[size || "default"];
|
|
118
|
+
return /* @__PURE__ */ React.createElement(
|
|
119
|
+
Comp,
|
|
120
|
+
{
|
|
121
|
+
className: (0, import_utils.cn)(iconButtonVariants({ variant, size, radius }), variant === "solid" && solidColorMap[color], pressEffect !== false && "active:scale-pressed", className),
|
|
122
|
+
ref,
|
|
123
|
+
disabled: disabled || loading,
|
|
124
|
+
"aria-busy": loading || void 0,
|
|
125
|
+
...props
|
|
126
|
+
},
|
|
127
|
+
loading ? /* @__PURE__ */ React.createElement(
|
|
128
|
+
"svg",
|
|
129
|
+
{
|
|
130
|
+
className: (0, import_utils.cn)(iconSize, "animate-spin"),
|
|
131
|
+
fill: "none",
|
|
132
|
+
viewBox: "0 0 24 24",
|
|
133
|
+
"aria-hidden": "true"
|
|
134
|
+
},
|
|
135
|
+
/* @__PURE__ */ React.createElement("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
136
|
+
/* @__PURE__ */ React.createElement("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
137
|
+
) : /* @__PURE__ */ React.createElement("span", { className: (0, import_utils.cn)(iconSize, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true" }, children)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
IconButton.displayName = "IconButton";
|
|
142
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
143
|
+
0 && (module.exports = {
|
|
144
|
+
IconButton,
|
|
145
|
+
iconButtonVariants
|
|
146
|
+
});
|
|
147
|
+
//# sourceMappingURL=icon-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/icon-button.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\nimport { useButtonGroup } from './button-group'\n\nimport { type ButtonColor } from './button'\n\n// Solid color maps (same as Button)\nconst solidColorMap = {\n default: 'bg-foreground text-background hover:bg-foreground/90 active:bg-foreground/80',\n primary: 'bg-primary text-primary-foreground hover:bg-primary-hover active:bg-primary-active',\n secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary-hover active:bg-secondary-active',\n destructive: 'bg-error text-error-foreground hover:bg-error-hover active:bg-error-active',\n} as const\n\nconst iconButtonVariants = cva(\n 'inline-flex items-center justify-center transition-all duration-micro focus-visible:focus-ring disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n variant: {\n solid: '',\n outline: 'border border-border-form bg-background text-foreground hover:bg-background-muted',\n ghost: 'text-foreground hover:bg-background-muted',\n subtle: 'text-text-muted hover:text-foreground',\n },\n size: {\n xs: 'h-7 w-7', // 28px - spacing.7\n sm: 'h-8 w-8', // 32px - spacing.8\n md: 'h-9 w-9', // 36px - spacing.9\n default: 'h-10 w-10', // 40px - spacing.10\n lg: 'h-12 w-12', // 48px - spacing.12\n },\n radius: {\n none: 'rounded-none', // 0px - primitive.borderRadius.none\n sm: 'rounded-sm', // 2px - primitive.borderRadius.sm\n base: 'rounded', // 4px - primitive.borderRadius.base\n default: 'rounded-md', // 6px - primitive.borderRadius.md (Figma button default)\n lg: 'rounded-lg', // 8px - primitive.borderRadius.lg\n xl: 'rounded-xl', // 12px - primitive.borderRadius.xl\n '2xl': 'rounded-2xl', // 16px - primitive.borderRadius.2xl\n '3xl': 'rounded-3xl', // 24px - primitive.borderRadius.3xl\n full: 'rounded-full', // 9999px - primitive.borderRadius.full\n },\n },\n defaultVariants: {\n variant: 'solid',\n size: 'default',\n radius: 'default',\n },\n }\n)\n\nexport interface IconButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof iconButtonVariants> {\n /** Solid variant color */\n color?: ButtonColor\n asChild?: boolean\n loading?: boolean\n pressEffect?: boolean\n}\n\nconst IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(\n ({ className, variant: variantProp, color: colorProp, size: sizeProp, radius: radiusProp, asChild = false, loading, pressEffect, children, disabled: disabledProp, ...props }, ref) => {\n const groupContext = useButtonGroup()\n\n // Priority: direct prop > ButtonGroup context > variant default\n const variant = variantProp ?? groupContext?.variant ?? 'solid'\n const color = colorProp ?? 'default'\n const size = sizeProp ?? groupContext?.size\n const radius = radiusProp ?? groupContext?.radius\n const disabled = disabledProp ?? groupContext?.disabled\n\n const Comp = asChild ? Slot : 'button'\n\n // Icon size for icon-only button (5-step scale)\n // XS: 14px, SM~MD: 16px, Default: 20px, LG: 24px\n const iconSize = {\n xs: 'icon-xs', // 14px\n sm: 'icon-sm', // 16px\n md: 'icon-sm', // 16px\n default: 'icon-md', // 20px\n lg: 'icon-lg', // 24px\n }[size || 'default']\n\n return (\n <Comp\n className={cn(iconButtonVariants({ variant, size, radius }), variant === 'solid' && solidColorMap[color], pressEffect !== false && 'active:scale-pressed', className)}\n ref={ref}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n {...props}\n >\n {loading ? (\n <svg\n className={cn(iconSize, 'animate-spin')}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <circle className=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" strokeWidth=\"4\" />\n <path className=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\" />\n </svg>\n ) : (\n <span className={cn(iconSize, '[&>svg]:w-full [&>svg]:h-full')} aria-hidden=\"true\">\n {children}\n </span>\n )}\n </Comp>\n )\n }\n)\nIconButton.displayName = 'IconButton'\n\nexport { IconButton, iconButtonVariants }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AACvB,wBAAqB;AACrB,sCAAuC;AACvC,mBAAmB;AACnB,0BAA+B;AAK/B,MAAM,gBAAgB;AAAA,EACpB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa;AACf;AAEA,MAAM,yBAAqB;AAAA,EACzB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,OAAO;AAAA,QACP,SAAS;AAAA,QACT,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,MACA,MAAM;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,SAAS;AAAA;AAAA,QACT,IAAI;AAAA;AAAA,MACN;AAAA,MACA,QAAQ;AAAA,QACN,MAAM;AAAA;AAAA,QACN,IAAI;AAAA;AAAA,QACJ,MAAM;AAAA;AAAA,QACN,SAAS;AAAA;AAAA,QACT,IAAI;AAAA;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,OAAO;AAAA;AAAA,QACP,OAAO;AAAA;AAAA,QACP,MAAM;AAAA;AAAA,MACR;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACF;AACF;AAYA,MAAM,aAAa,MAAM;AAAA,E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