@xjur-ui/react 1.0.6 → 2.0.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/.turbo/turbo-build.log +97 -45
- package/CHANGELOG.md +44 -0
- package/README.md +146 -0
- package/dist/chunk-CBFC4QME.js +2 -0
- package/dist/chunk-CBFC4QME.js.map +1 -0
- package/dist/chunk-EIG6CBTQ.js +2 -0
- package/dist/chunk-EIG6CBTQ.js.map +1 -0
- package/dist/chunk-FASEHVMD.js +2 -0
- package/dist/chunk-FASEHVMD.js.map +1 -0
- package/dist/chunk-KIFR5VIE.js +2 -0
- package/dist/chunk-KIFR5VIE.js.map +1 -0
- package/dist/chunk-KS6WGBHQ.js +2 -0
- package/dist/chunk-KS6WGBHQ.js.map +1 -0
- package/dist/chunk-NELCN6E2.js +2 -0
- package/dist/chunk-NELCN6E2.js.map +1 -0
- package/dist/chunk-NPTLORW5.js +2 -0
- package/dist/chunk-NPTLORW5.js.map +1 -0
- package/dist/chunk-RWMV7APX.js +2 -0
- package/dist/chunk-RWMV7APX.js.map +1 -0
- package/dist/chunk-SHHXKVVR.js +2 -0
- package/dist/chunk-SHHXKVVR.js.map +1 -0
- package/dist/chunk-TB6KI6CL.js +2 -0
- package/dist/chunk-TB6KI6CL.js.map +1 -0
- package/dist/components/avatar-group.js +2 -179
- package/dist/components/avatar-group.js.map +1 -0
- package/dist/components/avatar.js +2 -59
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.js +2 -111
- package/dist/components/badge.js.map +1 -0
- package/dist/components/button.js +2 -98
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.js +2 -751
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/checkbox.js +2 -153
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/chip.d.ts +3 -1
- package/dist/components/chip.js +2 -256
- package/dist/components/chip.js.map +1 -0
- package/dist/components/collapsible.js +2 -41
- package/dist/components/collapsible.js.map +1 -0
- package/dist/components/date-picker.d.ts +8 -3
- package/dist/components/date-picker.js +2 -232
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/divider.js +2 -29
- package/dist/components/divider.js.map +1 -0
- package/dist/components/dropdown-menu.js +2 -295
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/icon.js +2 -177
- package/dist/components/icon.js.map +1 -0
- package/dist/components/input.d.ts +9 -4
- package/dist/components/input.js +2 -315
- package/dist/components/input.js.map +1 -0
- package/dist/components/list.js +2 -179
- package/dist/components/list.js.map +1 -0
- package/dist/components/logo.js +2 -324
- package/dist/components/logo.js.map +1 -0
- package/dist/components/otp-input.js +2 -47
- package/dist/components/otp-input.js.map +1 -0
- package/dist/components/radio.js +2 -156
- package/dist/components/radio.js.map +1 -0
- package/dist/components/rich-editor.d.ts +2 -1
- package/dist/components/rich-editor.js +2 -723
- package/dist/components/rich-editor.js.map +1 -0
- package/dist/components/search-input.js +2 -274
- package/dist/components/search-input.js.map +1 -0
- package/dist/components/select.d.ts +6 -3
- package/dist/components/select.js +2 -550
- package/dist/components/select.js.map +1 -0
- package/dist/components/sheet.js +2 -251
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/skeleton.js +2 -16
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/status.js +2 -111
- package/dist/components/status.js.map +1 -0
- package/dist/components/switch.js +2 -36
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.js +2 -196
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.d.ts +9 -6
- package/dist/components/tabs.js +2 -54
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/tag.d.ts +3 -1
- package/dist/components/tag.js +2 -189
- package/dist/components/tag.js.map +1 -0
- package/dist/components/tooltip.js +2 -58
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/typography.js +2 -78
- package/dist/components/typography.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.css +2 -2322
- package/dist/index.css.map +1 -0
- package/dist/logo-PQRZORCS.js +3 -0
- package/dist/logo-PQRZORCS.js.map +1 -0
- package/package.json +41 -8
- package/src/components/calendar.tsx +7 -6
- package/src/components/chip.tsx +11 -3
- package/src/components/date-picker.tsx +125 -22
- package/src/components/icon.tsx +1 -1
- package/src/components/input.tsx +124 -60
- package/src/components/logo.tsx +25 -20
- package/src/components/rich-editor.tsx +4 -3
- package/src/components/select.tsx +104 -26
- package/src/components/tabs.tsx +56 -37
- package/src/components/tag.tsx +11 -3
- package/src/index.css +2 -2
- package/src/resources/logo/index.tsx +33 -0
- package/tsup.config.ts +23 -5
- package/dist/components/test.d.ts +0 -5
- package/dist/components/test.js +0 -8
- package/dist/index.js +0 -0
- package/src/components/test.tsx +0 -3
- package/src/index.ts +0 -1
- package/src/resources/logo/index.ts +0 -3
package/dist/components/icon.js
CHANGED
|
@@ -1,177 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// src/resources/icons.ts
|
|
5
|
-
var icons = [
|
|
6
|
-
"account_balance",
|
|
7
|
-
"ad_units",
|
|
8
|
-
"add_a_photo",
|
|
9
|
-
"add",
|
|
10
|
-
"adjust",
|
|
11
|
-
"archive",
|
|
12
|
-
"arrow_downward_alt",
|
|
13
|
-
"arrow_downward",
|
|
14
|
-
"arrow_drop_down",
|
|
15
|
-
"arrow_drop_up",
|
|
16
|
-
"arrow_split",
|
|
17
|
-
"arrow_upward_alt",
|
|
18
|
-
"arrow_upward",
|
|
19
|
-
"attach_file",
|
|
20
|
-
"attach_money",
|
|
21
|
-
"autorenew",
|
|
22
|
-
"brightness_1",
|
|
23
|
-
"calendar_today",
|
|
24
|
-
"call",
|
|
25
|
-
"chat_bubble",
|
|
26
|
-
"check_circle",
|
|
27
|
-
"check",
|
|
28
|
-
"chevron_left",
|
|
29
|
-
"chevron_right",
|
|
30
|
-
"close",
|
|
31
|
-
"collapse_all",
|
|
32
|
-
"contacts",
|
|
33
|
-
"content_copy",
|
|
34
|
-
"dangerous",
|
|
35
|
-
"dashboard",
|
|
36
|
-
"delete",
|
|
37
|
-
"download",
|
|
38
|
-
"draft",
|
|
39
|
-
"drafts",
|
|
40
|
-
"drag_handle",
|
|
41
|
-
"drag_indicator",
|
|
42
|
-
"edit_document",
|
|
43
|
-
"edit_square",
|
|
44
|
-
"edit",
|
|
45
|
-
"error",
|
|
46
|
-
"expand_all",
|
|
47
|
-
"file_export",
|
|
48
|
-
"filter_alt",
|
|
49
|
-
"filter_list",
|
|
50
|
-
"first_page",
|
|
51
|
-
"flag_2",
|
|
52
|
-
"folder_open",
|
|
53
|
-
"folder",
|
|
54
|
-
"format_bold",
|
|
55
|
-
"format_italic",
|
|
56
|
-
"format_italic",
|
|
57
|
-
"format_size",
|
|
58
|
-
"format_strikethrough",
|
|
59
|
-
"gavel",
|
|
60
|
-
"group",
|
|
61
|
-
"headphones",
|
|
62
|
-
"help",
|
|
63
|
-
"hourglass_bottom",
|
|
64
|
-
"imagesmode",
|
|
65
|
-
"import_contacts",
|
|
66
|
-
"inbox",
|
|
67
|
-
"info",
|
|
68
|
-
"inventory_2",
|
|
69
|
-
"keep",
|
|
70
|
-
"keep",
|
|
71
|
-
"keyboard_arrow_down",
|
|
72
|
-
"keyboard_arrow_up",
|
|
73
|
-
"keyboard_return",
|
|
74
|
-
"label_off",
|
|
75
|
-
"label",
|
|
76
|
-
"last_page",
|
|
77
|
-
"left_panel_close",
|
|
78
|
-
"left_panel_open",
|
|
79
|
-
"link_off",
|
|
80
|
-
"link",
|
|
81
|
-
"linked_services",
|
|
82
|
-
"list",
|
|
83
|
-
"location_on",
|
|
84
|
-
"lock",
|
|
85
|
-
"logout",
|
|
86
|
-
"mail",
|
|
87
|
-
"menu",
|
|
88
|
-
"mic",
|
|
89
|
-
"more_vert",
|
|
90
|
-
"notifications",
|
|
91
|
-
"numbers",
|
|
92
|
-
"person_add",
|
|
93
|
-
"person_off",
|
|
94
|
-
"person",
|
|
95
|
-
"play_circle",
|
|
96
|
-
"progress_activity",
|
|
97
|
-
"question_mark",
|
|
98
|
-
"radio_button_unchecked",
|
|
99
|
-
"refresh",
|
|
100
|
-
"remove",
|
|
101
|
-
"reply",
|
|
102
|
-
"right_panel_close",
|
|
103
|
-
"right_panel_open",
|
|
104
|
-
"schedule",
|
|
105
|
-
"search",
|
|
106
|
-
"sell",
|
|
107
|
-
"send",
|
|
108
|
-
"settings",
|
|
109
|
-
"share",
|
|
110
|
-
"smart_display",
|
|
111
|
-
"star",
|
|
112
|
-
"star",
|
|
113
|
-
"swap_vert",
|
|
114
|
-
"thumb_down",
|
|
115
|
-
"thumb_up",
|
|
116
|
-
"tune",
|
|
117
|
-
"unarchive",
|
|
118
|
-
"undo",
|
|
119
|
-
"upload",
|
|
120
|
-
"verified_user",
|
|
121
|
-
"videocam",
|
|
122
|
-
"view_list",
|
|
123
|
-
"view_module",
|
|
124
|
-
"view_object_track",
|
|
125
|
-
"visibility_off",
|
|
126
|
-
"visibility",
|
|
127
|
-
"warning",
|
|
128
|
-
"wifi_2_bar",
|
|
129
|
-
"wifi_off",
|
|
130
|
-
"wifi",
|
|
131
|
-
"work",
|
|
132
|
-
"workspaces",
|
|
133
|
-
"article",
|
|
134
|
-
"id_card",
|
|
135
|
-
"badge",
|
|
136
|
-
"home",
|
|
137
|
-
"save",
|
|
138
|
-
"code",
|
|
139
|
-
"favorite",
|
|
140
|
-
"analytics",
|
|
141
|
-
"reports",
|
|
142
|
-
"event",
|
|
143
|
-
"account_circle",
|
|
144
|
-
"history",
|
|
145
|
-
"security",
|
|
146
|
-
"bar_chart",
|
|
147
|
-
"category",
|
|
148
|
-
"format_underlined",
|
|
149
|
-
"format_list_bulleted",
|
|
150
|
-
"format_list_numbered",
|
|
151
|
-
"redo"
|
|
152
|
-
];
|
|
153
|
-
|
|
154
|
-
// src/components/icon.tsx
|
|
155
|
-
import { jsx } from "react/jsx-runtime";
|
|
156
|
-
function Icon({ className, filled = false, name, ...props }) {
|
|
157
|
-
return /* @__PURE__ */ jsx(
|
|
158
|
-
"span",
|
|
159
|
-
{
|
|
160
|
-
...props,
|
|
161
|
-
className: cx(
|
|
162
|
-
"material-symbols-outlined",
|
|
163
|
-
"text-size-body-lg",
|
|
164
|
-
className
|
|
165
|
-
),
|
|
166
|
-
style: {
|
|
167
|
-
fontVariationSettings: `'FILL' ${filled ? 1 : 0}, 'wght' 600, 'GRAD' 0, 'opsz' 20`,
|
|
168
|
-
...props.style
|
|
169
|
-
},
|
|
170
|
-
children: name
|
|
171
|
-
}
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
export {
|
|
175
|
-
Icon,
|
|
176
|
-
icons
|
|
177
|
-
};
|
|
1
|
+
export{b as Icon,a as icons}from'../chunk-SHHXKVVR.js';//# sourceMappingURL=icon.js.map
|
|
2
|
+
//# sourceMappingURL=icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"icon.js"}
|
|
@@ -3,16 +3,21 @@ import { ComponentProps } from 'react';
|
|
|
3
3
|
import { MaskOptions } from '@react-input/mask';
|
|
4
4
|
export { MaskOptions } from '@react-input/mask';
|
|
5
5
|
import { InputNumberFormatProps } from '@react-input/number-format';
|
|
6
|
+
import { Typography } from './typography.js';
|
|
7
|
+
import 'class-variance-authority/types';
|
|
8
|
+
import '@xjur-ui/util';
|
|
6
9
|
|
|
7
10
|
type InputMaskType = 'cpf' | 'cnpj' | 'telefone' | 'cep' | 'numero-processo' | 'custom' | 'data' | 'hora' | 'data-hora';
|
|
8
11
|
declare function inputMask(type: InputMaskType, options?: MaskOptions): MaskOptions;
|
|
9
12
|
|
|
10
13
|
type InputProps = {
|
|
11
14
|
variant?: 'outlined' | 'filled';
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
hasError?: boolean;
|
|
12
17
|
};
|
|
13
|
-
declare function InputRoot({ className, children, variant, ...props }: ComponentProps<'div'> & InputProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
declare function InputRoot({ className, children, variant, disabled, hasError, ...props }: ComponentProps<'div'> & InputProps): react_jsx_runtime.JSX.Element;
|
|
14
19
|
declare function InputContent({ className, ...props }: ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
15
|
-
declare function InputLabel({ htmlFor, className, children, ...props }: ComponentProps<
|
|
20
|
+
declare function InputLabel({ htmlFor, className, children, ...props }: ComponentProps<typeof Typography> & {
|
|
16
21
|
htmlFor: string;
|
|
17
22
|
}): react_jsx_runtime.JSX.Element;
|
|
18
23
|
declare function InputText({ className, maskOptions, maskType, ...props }: ComponentProps<'input'> & {
|
|
@@ -22,11 +27,11 @@ declare function InputText({ className, maskOptions, maskType, ...props }: Compo
|
|
|
22
27
|
declare function InputNumber({ className, locales, ...props }: InputNumberFormatProps): react_jsx_runtime.JSX.Element;
|
|
23
28
|
declare function InputLeftSlot({ className, ...props }: ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
24
29
|
declare function InputRightSlot({ className, ...props }: ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
25
|
-
declare function
|
|
30
|
+
declare function InputCaption({ className, variant, size, weight, ...props }: ComponentProps<typeof Typography>): react_jsx_runtime.JSX.Element;
|
|
26
31
|
declare function InputContainer({ className, ...props }: ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
27
32
|
declare function InputAction({ className, side, ...props }: ComponentProps<'div'> & {
|
|
28
33
|
side: 'left' | 'right';
|
|
29
34
|
}): react_jsx_runtime.JSX.Element;
|
|
30
35
|
declare function InputActionButton({ className, ...props }: ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
31
36
|
|
|
32
|
-
export { InputAction, InputActionButton, InputContainer, InputContent, InputLabel, InputLeftSlot, type InputMaskType,
|
|
37
|
+
export { InputAction, InputActionButton, InputCaption, InputContainer, InputContent, InputLabel, InputLeftSlot, type InputMaskType, InputNumber, type InputProps, InputRightSlot, InputRoot, InputText, inputMask };
|
package/dist/components/input.js
CHANGED
|
@@ -1,315 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { createContext } from "react";
|
|
4
|
-
import { InputMask } from "@react-input/mask";
|
|
5
|
-
import {
|
|
6
|
-
InputNumberFormat
|
|
7
|
-
} from "@react-input/number-format";
|
|
8
|
-
|
|
9
|
-
// src/resources/input-mask.ts
|
|
10
|
-
function inputMask(type, options) {
|
|
11
|
-
switch (type) {
|
|
12
|
-
case "cpf":
|
|
13
|
-
return { ...options, ...CPF_MASK };
|
|
14
|
-
case "cnpj":
|
|
15
|
-
return { ...options, ...CNPJ_MASK };
|
|
16
|
-
case "telefone":
|
|
17
|
-
return { ...options, ...PHONE_MASK };
|
|
18
|
-
case "cep":
|
|
19
|
-
return { ...options, ...CEP_MASK };
|
|
20
|
-
case "numero-processo":
|
|
21
|
-
return { ...options, ...NUMERO_PROCESSO_MASK };
|
|
22
|
-
case "data":
|
|
23
|
-
return { ...options, ...DATE_MASK };
|
|
24
|
-
case "hora":
|
|
25
|
-
return { ...options, ...TIME_MASK };
|
|
26
|
-
case "data-hora":
|
|
27
|
-
return { ...options, ...DATETIME_MASK };
|
|
28
|
-
case "custom":
|
|
29
|
-
if (!options) {
|
|
30
|
-
throw new Error("Options are required for custom mask");
|
|
31
|
-
}
|
|
32
|
-
return options;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
var CPF_MASK = {
|
|
36
|
-
mask: "###.###.###-##",
|
|
37
|
-
replacement: {
|
|
38
|
-
"#": /\d/
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var CNPJ_MASK = {
|
|
42
|
-
mask: "##.###.###/####-##",
|
|
43
|
-
replacement: {
|
|
44
|
-
"#": /\d/
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
var PHONE_MASK = {
|
|
48
|
-
mask: "(##) #####-####",
|
|
49
|
-
replacement: {
|
|
50
|
-
"#": /\d/
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var CEP_MASK = {
|
|
54
|
-
mask: "#####-###",
|
|
55
|
-
replacement: {
|
|
56
|
-
"#": /\d/
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
var NUMERO_PROCESSO_MASK = {
|
|
60
|
-
mask: "#######-##.####.#.##.####",
|
|
61
|
-
replacement: {
|
|
62
|
-
"#": /\d/
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
var DATE_MASK = {
|
|
66
|
-
mask: "##/##/####",
|
|
67
|
-
replacement: {
|
|
68
|
-
"#": /\d/
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var TIME_MASK = {
|
|
72
|
-
mask: "##:##",
|
|
73
|
-
replacement: {
|
|
74
|
-
"#": /\d/
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
var DATETIME_MASK = {
|
|
78
|
-
mask: "##/##/#### ##:##",
|
|
79
|
-
replacement: {
|
|
80
|
-
"#": /\d/
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// src/components/input.tsx
|
|
85
|
-
import { jsx } from "react/jsx-runtime";
|
|
86
|
-
var FieldContext = createContext({
|
|
87
|
-
variant: "filled"
|
|
88
|
-
});
|
|
89
|
-
function InputRoot({
|
|
90
|
-
className,
|
|
91
|
-
children,
|
|
92
|
-
variant = "filled",
|
|
93
|
-
...props
|
|
94
|
-
}) {
|
|
95
|
-
return /* @__PURE__ */ jsx(FieldContext.Provider, { value: { variant }, children: /* @__PURE__ */ jsx(
|
|
96
|
-
"div",
|
|
97
|
-
{
|
|
98
|
-
className: cx(
|
|
99
|
-
"group gap-small relative flex w-full flex-col",
|
|
100
|
-
className
|
|
101
|
-
),
|
|
102
|
-
...props,
|
|
103
|
-
children
|
|
104
|
-
}
|
|
105
|
-
) });
|
|
106
|
-
}
|
|
107
|
-
function InputContent({ className, ...props }) {
|
|
108
|
-
const variants = cva(
|
|
109
|
-
[
|
|
110
|
-
"relative h-large-4x rounded-small-1x gap-small py-small_1x-alt px-small flex items-center w-full",
|
|
111
|
-
"focus-within:border-primary-idle focus-within:border",
|
|
112
|
-
"group-has-[div[data-slot=input-right-action-slot]]:rounded-r-none",
|
|
113
|
-
"group-has-[div[data-slot=input-left-action-slot]]:rounded-l-none"
|
|
114
|
-
],
|
|
115
|
-
{
|
|
116
|
-
variants: {
|
|
117
|
-
variant: {
|
|
118
|
-
default: "",
|
|
119
|
-
outlined: "bg-layer-2-idle border-border-layer-2 border hover:group-has-[input:not(:focus-within)]:border-border-layer-3 has-[input:not(:placeholder-shown)]:border-primary-idle",
|
|
120
|
-
filled: "bg-layer-2-hover group-hover:border-border-layer-1 group-hover:border-1"
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
return /* @__PURE__ */ jsx(FieldContext.Consumer, { children: ({ variant }) => {
|
|
126
|
-
return /* @__PURE__ */ jsx("div", { className: cx(className, variants({ variant })), ...props });
|
|
127
|
-
} });
|
|
128
|
-
}
|
|
129
|
-
function InputLabel({
|
|
130
|
-
htmlFor,
|
|
131
|
-
className,
|
|
132
|
-
children,
|
|
133
|
-
...props
|
|
134
|
-
}) {
|
|
135
|
-
return /* @__PURE__ */ jsx(FieldContext.Consumer, { children: ({ variant }) => {
|
|
136
|
-
return /* @__PURE__ */ jsx(
|
|
137
|
-
"label",
|
|
138
|
-
{
|
|
139
|
-
className: cx(
|
|
140
|
-
"group text-size-body-md text-neutral-dark inline-block max-w-full truncate text-left",
|
|
141
|
-
"ease animate-in left-small right-small pointer-events-none absolute top-1/2 -translate-y-1/2 transition-all duration-250",
|
|
142
|
-
// Filled
|
|
143
|
-
"group-focus-within:text-primary-idle group-focus-within:-top-[3px]",
|
|
144
|
-
"group-focus-within:text-size-label-sm-1x group-focus-within:font-medium",
|
|
145
|
-
"group-has-[input:not(:placeholder-shown)]:-top-[3px]",
|
|
146
|
-
"group-has-[input:not(:placeholder-shown)]:text-size-label-sm-1x",
|
|
147
|
-
"group-has-[input:not(:placeholder-shown)]:font-medium",
|
|
148
|
-
"data-[variant=outlined]:group-has-[input:not(:placeholder-shown)]:text-primary-idle",
|
|
149
|
-
// If has left slot
|
|
150
|
-
"group-has-[div[data-slot=input-left-slot]]:left-large-4x",
|
|
151
|
-
"group-has-[div[data-slot=input-left-slot]]:group-focus-within:left-small",
|
|
152
|
-
"group-has-[div[data-slot=input-left-slot]]:group-has-[input:not(:placeholder-shown)]:left-small",
|
|
153
|
-
// If has right slot
|
|
154
|
-
"group-has-[div[data-slot=input-right-slot]]:right-large-4x",
|
|
155
|
-
"group-has-[div[data-slot=input-right-slot]]:group-focus-within:right-small",
|
|
156
|
-
"group-has-[div[data-slot=input-right-slot]]:group-has-[input:not(:placeholder-shown)]:right-small",
|
|
157
|
-
// Animate
|
|
158
|
-
"group-focus-within:animate-in",
|
|
159
|
-
"group-has-[input:not(:placeholder-shown)]:animate-out",
|
|
160
|
-
className
|
|
161
|
-
),
|
|
162
|
-
"data-variant": variant,
|
|
163
|
-
htmlFor,
|
|
164
|
-
...props,
|
|
165
|
-
children: /* @__PURE__ */ jsx(
|
|
166
|
-
"span",
|
|
167
|
-
{
|
|
168
|
-
className: cx(
|
|
169
|
-
"rounded-small-1x max-w-full",
|
|
170
|
-
"group-data-[variant=outlined]:group-focus-within:bg-layer-2-idle group-data-[variant=filled]:group-focus-within:bg-layer-2-hover",
|
|
171
|
-
"group-data-[variant=outlined]:bg-layer-2-idle group-data-[variant=filled]:bg-layer-2-hover"
|
|
172
|
-
),
|
|
173
|
-
children
|
|
174
|
-
}
|
|
175
|
-
)
|
|
176
|
-
}
|
|
177
|
-
);
|
|
178
|
-
} });
|
|
179
|
-
}
|
|
180
|
-
function InputText({
|
|
181
|
-
className,
|
|
182
|
-
maskOptions,
|
|
183
|
-
maskType,
|
|
184
|
-
...props
|
|
185
|
-
}) {
|
|
186
|
-
const Component = maskOptions || maskType ? InputMask : "input";
|
|
187
|
-
return /* @__PURE__ */ jsx(
|
|
188
|
-
Component,
|
|
189
|
-
{
|
|
190
|
-
...props,
|
|
191
|
-
...maskType ? { ...inputMask(maskType) } : maskOptions && { ...maskOptions },
|
|
192
|
-
className: cx(
|
|
193
|
-
className,
|
|
194
|
-
"peer text-size-body-md text-neutral-dark flex-1 font-medium outline-none",
|
|
195
|
-
"group-has-[div[data-slot=input-left-slot]]:pl-large-1x ml-small-1x"
|
|
196
|
-
),
|
|
197
|
-
placeholder: props.placeholder || " ",
|
|
198
|
-
...maskOptions && { ...maskOptions }
|
|
199
|
-
}
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
function InputNumber({
|
|
203
|
-
className,
|
|
204
|
-
locales = "pt-BR",
|
|
205
|
-
...props
|
|
206
|
-
}) {
|
|
207
|
-
return /* @__PURE__ */ jsx(
|
|
208
|
-
InputNumberFormat,
|
|
209
|
-
{
|
|
210
|
-
...props,
|
|
211
|
-
className: cx(
|
|
212
|
-
className,
|
|
213
|
-
"peer text-size-body-md text-neutral-dark flex-1 font-medium outline-none",
|
|
214
|
-
"group-has-[div[data-slot=input-left-slot]]:pl-large-1x ml-small-1x"
|
|
215
|
-
),
|
|
216
|
-
locales,
|
|
217
|
-
placeholder: props.placeholder || " "
|
|
218
|
-
}
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
function InputLeftSlot({ className, ...props }) {
|
|
222
|
-
return /* @__PURE__ */ jsx(
|
|
223
|
-
"div",
|
|
224
|
-
{
|
|
225
|
-
...props,
|
|
226
|
-
className: cx(
|
|
227
|
-
className,
|
|
228
|
-
"left-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center"
|
|
229
|
-
),
|
|
230
|
-
"data-slot": "input-left-slot"
|
|
231
|
-
}
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
function InputRightSlot({ className, ...props }) {
|
|
235
|
-
return /* @__PURE__ */ jsx(
|
|
236
|
-
"div",
|
|
237
|
-
{
|
|
238
|
-
...props,
|
|
239
|
-
className: cx(
|
|
240
|
-
className,
|
|
241
|
-
"right-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center"
|
|
242
|
-
),
|
|
243
|
-
"data-slot": "input-right-slot"
|
|
244
|
-
}
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
function InputMessage({ className, ...props }) {
|
|
248
|
-
return /* @__PURE__ */ jsx(
|
|
249
|
-
"p",
|
|
250
|
-
{
|
|
251
|
-
...props,
|
|
252
|
-
className: cx(
|
|
253
|
-
"text-size-body-sm text-neutral-dark font-normal",
|
|
254
|
-
className
|
|
255
|
-
)
|
|
256
|
-
}
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
function InputContainer({ className, ...props }) {
|
|
260
|
-
return /* @__PURE__ */ jsx(
|
|
261
|
-
"div",
|
|
262
|
-
{
|
|
263
|
-
...props,
|
|
264
|
-
className: cx(className, "flex items-center"),
|
|
265
|
-
"data-slot": "input-content"
|
|
266
|
-
}
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
function InputAction({
|
|
270
|
-
className,
|
|
271
|
-
side,
|
|
272
|
-
...props
|
|
273
|
-
}) {
|
|
274
|
-
return /* @__PURE__ */ jsx(
|
|
275
|
-
"div",
|
|
276
|
-
{
|
|
277
|
-
...props,
|
|
278
|
-
className: cx(
|
|
279
|
-
className,
|
|
280
|
-
"group h-large-4x flex items-center justify-center"
|
|
281
|
-
),
|
|
282
|
-
"data-side": side,
|
|
283
|
-
"data-slot": `input-${side}-action-slot`
|
|
284
|
-
}
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
function InputActionButton({
|
|
288
|
-
className,
|
|
289
|
-
...props
|
|
290
|
-
}) {
|
|
291
|
-
return /* @__PURE__ */ jsx(
|
|
292
|
-
"div",
|
|
293
|
-
{
|
|
294
|
-
...props,
|
|
295
|
-
className: cx(
|
|
296
|
-
className,
|
|
297
|
-
"h-large-4x w-large-4x bg-layer-2-hover flex cursor-pointer items-center justify-center"
|
|
298
|
-
)
|
|
299
|
-
}
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
export {
|
|
303
|
-
InputAction,
|
|
304
|
-
InputActionButton,
|
|
305
|
-
InputContainer,
|
|
306
|
-
InputContent,
|
|
307
|
-
InputLabel,
|
|
308
|
-
InputLeftSlot,
|
|
309
|
-
InputMessage,
|
|
310
|
-
InputNumber,
|
|
311
|
-
InputRightSlot,
|
|
312
|
-
InputRoot,
|
|
313
|
-
InputText,
|
|
314
|
-
inputMask
|
|
315
|
-
};
|
|
1
|
+
import {a}from'../chunk-EIG6CBTQ.js';import {twMerge,tv}from'@xjur-ui/util';import {createContext,useMemo,useContext}from'react';import {InputMask}from'@react-input/mask';import {InputNumberFormat}from'@react-input/number-format';import {jsx}from'react/jsx-runtime';function c(e,t){switch(e){case "cpf":return {...t,...h};case "cnpj":return {...t,...f};case "telefone":return {...t,...g};case "cep":return {...t,...x};case "numero-processo":return {...t,...b};case "data":return {...t,...v};case "hora":return {...t,...y};case "data-hora":return {...t,...w};case "custom":if(!t)throw new Error("Options are required for custom mask");return t}}var h={mask:"###.###.###-##",replacement:{"#":/\d/}},f={mask:"##.###.###/####-##",replacement:{"#":/\d/}},g={mask:"(##) #####-####",replacement:{"#":/\d/}},x={mask:"#####-###",replacement:{"#":/\d/}},b={mask:"#######-##.####.#.##.####",replacement:{"#":/\d/}},v={mask:"##/##/####",replacement:{"#":/\d/}},y={mask:"##:##",replacement:{"#":/\d/}},w={mask:"##/##/#### ##:##",replacement:{"#":/\d/}};var p=createContext({variant:"filled",disabled:false,hasError:false});function u(){let e=useContext(p);if(!e)throw new Error("useInput must be used within a InputRoot");return e}function _({className:e,children:t,variant:r="filled",disabled:a=false,hasError:l=false,...s}){let i=useMemo(()=>({variant:r,disabled:a,hasError:l}),[r,a,l]);return jsx(p.Provider,{value:i,children:jsx("div",{className:twMerge("group relative flex w-full flex-col",e),...s,children:t})})}function K({className:e,...t}){let r=tv({base:twMerge("border border-transparent relative h-large-4x rounded-small-1x gap-small py-small_1x-alt px-small flex items-center w-full","group-has-[div[data-slot=input-right-action-slot]]:rounded-r-none","group-has-[div[data-slot=input-left-action-slot]]:rounded-l-none","focus-within:border-primary-idle focus-within:hover:border-primary-idle","hover:border-border-layer-1"),variants:{variant:{filled:"bg-layer-2-hover",outlined:"bg-layer-2-idle border-border-layer-2 hover:border-border-layer-3",disabled:"hover:border-transparent border-none bg-layer-2-idle"},state:{idle:"",error:"focus-within:border-danger-idle hover:border-danger-idle border-danger-idle focus-within:hover:border-danger-idle"}},defaultVariants:{variant:"filled",state:"idle"}});return jsx(p.Consumer,{children:({variant:a,disabled:l,hasError:s})=>jsx("div",{className:r({variant:l?"disabled":a,state:s?"error":"idle",className:e}),...t})})}function z({htmlFor:e,className:t,children:r,...a$1}){return jsx(p.Consumer,{children:({variant:l,disabled:s,hasError:i})=>jsx(a,{asChild:true,className:twMerge("group inline-block max-w-full truncate text-left","ease animate-in left-small right-small pointer-events-none absolute top-1/2 -translate-y-1/2 transition-all duration-250","group-focus-within:!text-primary-idle group-focus-within:data-[has-error=true]:!text-danger-label-active group-focus-within:-top-[3px]","group-focus-within:text-size-label-sm-1x group-focus-within:font-medium","group-has-[input:not(:placeholder-shown)]:-top-[3px]","group-has-[input:not(:placeholder-shown)]:text-size-label-sm-1x","group-has-[input:not(:placeholder-shown)]:font-medium","group-has-[input:not(:placeholder-shown)]:!text-primary-idle","group-has-[input:not(:placeholder-shown)]:!text-danger-label-active","group-has-[div[data-slot=input-left-slot]]:left-large-4x","group-has-[div[data-slot=input-left-slot]]:group-focus-within:left-small","group-has-[div[data-slot=input-left-slot]]:group-has-[input:not(:placeholder-shown)]:left-small","group-has-[div[data-slot=input-right-slot]]:right-large-4x","group-has-[div[data-slot=input-right-slot]]:group-focus-within:right-small","group-has-[div[data-slot=input-right-slot]]:group-has-[input:not(:placeholder-shown)]:right-small","group-focus-within:animate-in","group-has-[input:not(:placeholder-shown)]:animate-out","data-[disabled=true]:hidden",t),"data-disabled":s,"data-has-error":i,"data-variant":l,...a$1,children:jsx("label",{htmlFor:e,children:jsx("span",{className:twMerge("rounded-small-1x max-w-full","group-data-[variant=outlined]:group-focus-within:bg-layer-2-idle group-data-[variant=filled]:group-focus-within:bg-layer-2-hover","group-data-[variant=outlined]:bg-layer-2-idle group-data-[variant=filled]:bg-layer-2-hover"),children:r})})})})}function R({className:e,maskOptions:t,maskType:r,...a}){let{disabled:l}=u();return jsx(t||r?InputMask:"input",{...a,disabled:l,...r?{...c(r)}:t&&{...t},className:twMerge(e,"peer !text-size-body-md text-neutral-dark flex-1 outline-none","group-has-[div[data-slot=input-left-slot]]:pl-large-1x ml-small-1x"),placeholder:a.placeholder||" ",...t&&{...t}})}function j({className:e,locales:t="pt-BR",...r}){let{disabled:a}=u();return jsx(InputNumberFormat,{...r,className:twMerge(e,"peer !text-size-body-md text-neutral-dark flex-1 font-medium outline-none","group-has-[div[data-slot=input-left-slot]]:pl-large-1x ml-small-1x"),disabled:a,locales:t,placeholder:r.placeholder||" "})}function B({className:e,...t}){return jsx("div",{...t,className:twMerge(e,"left-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center"),"data-slot":"input-left-slot"})}function D({className:e,...t}){return jsx("div",{...t,className:twMerge(e,"right-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center"),"data-slot":"input-right-slot"})}function L({className:e,variant:t="body",size:r="sm",weight:a$1="normal",...l}){let{hasError:s}=u(),i=tv({base:"text-size-body-sm mt-small-1x font-normal",variants:{state:{error:"text-danger-label-active",idle:"text-neutral-dark"}}});return jsx(a,{className:i({state:s?"error":"idle",className:e}),size:r,variant:t,weight:a$1,...l})}function V({className:e,...t}){return jsx("div",{...t,className:twMerge(e,"flex items-center"),"data-slot":"input-content"})}function q({className:e,side:t,...r}){let{disabled:a}=u();return jsx("div",{...r,className:twMerge(e,"group h-large-4x flex items-center justify-center data-[disabled=true]:hidden"),"data-disabled":a,"data-side":t,"data-slot":`input-${t}-action-slot`})}function H({className:e,...t}){return jsx("div",{...t,className:twMerge(e,"h-large-4x w-large-4x bg-layer-2-hover flex cursor-pointer items-center justify-center")})}export{q as InputAction,H as InputActionButton,L as InputCaption,V as InputContainer,K as InputContent,z as InputLabel,B as InputLeftSlot,j as InputNumber,D as InputRightSlot,_ as InputRoot,R as InputText,c as inputMask};//# sourceMappingURL=input.js.map
|
|
2
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resources/input-mask.ts","../../src/components/input.tsx"],"names":["inputMask","type","options","CPF_MASK","CNPJ_MASK","PHONE_MASK","CEP_MASK","NUMERO_PROCESSO_MASK","DATE_MASK","TIME_MASK","DATETIME_MASK","FieldContext","createContext","useInput","context","useContext","InputRoot","className","children","variant","disabled","hasError","props","providerValue","useMemo","jsx","twMerge","InputContent","content","tv","InputLabel","htmlFor","Typography","InputText","maskOptions","maskType","InputMask","InputNumber","locales","InputNumberFormat","InputLeftSlot","InputRightSlot","InputCaption","size","weight","caption","InputContainer","InputAction","side","InputActionButton"],"mappings":"0QAaO,SAASA,CAAAA,CACdC,CAAAA,CACAC,EACa,CACb,OAAQD,GACN,KAAK,MACH,OAAO,CAAE,GAAGC,CAAAA,CAAS,GAAGC,CAAS,CAAA,CACnC,KAAK,OACH,OAAO,CAAE,GAAGD,CAAAA,CAAS,GAAGE,CAAU,CAAA,CACpC,KAAK,UAAA,CACH,OAAO,CAAE,GAAGF,CAAAA,CAAS,GAAGG,CAAW,CAAA,CACrC,KAAK,KAAA,CACH,OAAO,CAAE,GAAGH,CAAAA,CAAS,GAAGI,CAAS,CAAA,CACnC,KAAK,iBAAA,CACH,OAAO,CAAE,GAAGJ,CAAAA,CAAS,GAAGK,CAAqB,CAAA,CAC/C,KAAK,MAAA,CACH,OAAO,CAAE,GAAGL,CAAAA,CAAS,GAAGM,CAAU,CAAA,CACpC,KAAK,MAAA,CACH,OAAO,CAAE,GAAGN,CAAAA,CAAS,GAAGO,CAAU,CAAA,CACpC,KAAK,WAAA,CACH,OAAO,CAAE,GAAGP,EAA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,CAED,OACEJ,GAAAA,CAACO,CAAAA,CAAA,CACC,SAAA,CAAWa,CAAAA,CAAQ,CACjB,KAAA,CAAOxB,CAAAA,CAAW,QAAU,MAAA,CAC5B,SAAA,CAAAJ,CACF,CAAC,EACD,IAAA,CAAM0B,CAAAA,CACN,QAASxB,CAAAA,CACT,MAAA,CAAQyB,IACP,GAAGtB,CAAAA,CACN,CAEJ,CAEO,SAASwB,EAAe,CAAE,SAAA,CAAA7B,EAAW,GAAGK,CAAM,EAA0B,CAC7E,OACEG,IAAC,KAAA,CAAA,CACE,GAAGH,EACJ,SAAA,CAAWI,OAAAA,CAAQT,EAAW,mBAAmB,CAAA,CACjD,YAAU,eAAA,CACZ,CAEJ,CAEO,SAAS8B,CAAAA,CAAY,CAC1B,SAAA,CAAA9B,CAAAA,CACA,KAAA+B,CAAAA,CACA,GAAG1B,CACL,CAAA,CAEG,CACD,GAAM,CAAE,QAAA,CAAAF,CAAS,CAAA,CAAIP,CAAAA,GACrB,OACEY,GAAAA,CAAC,OACE,GAAGH,CAAAA,CACJ,UAAWI,OAAAA,CACTT,CAAAA,CACA,+EACF,CAAA,CACA,eAAA,CAAeG,EACf,WAAA,CAAW4B,CAAAA,CACX,YAAW,CAAA,MAAA,EAASA,CAAI,eAC1B,CAEJ,CAEO,SAASC,CAAAA,CAAkB,CAChC,UAAAhC,CAAAA,CACA,GAAGK,CACL,CAAA,CAA0B,CACxB,OACEG,GAAAA,CAAC,KAAA,CAAA,CACE,GAAGH,CAAAA,CACJ,SAAA,CAAWI,QACTT,CAAAA,CACA,wFACF,EACF,CAEJ","file":"input.js","sourcesContent":["import type { MaskOptions } from '@react-input/mask'\n\nexport type InputMaskType =\n | 'cpf'\n | 'cnpj'\n | 'telefone'\n | 'cep'\n | 'numero-processo'\n | 'custom'\n | 'data'\n | 'hora'\n | 'data-hora'\n\nexport function inputMask(\n type: InputMaskType,\n options?: MaskOptions\n): MaskOptions {\n switch (type) {\n case 'cpf':\n return { ...options, ...CPF_MASK }\n case 'cnpj':\n return { ...options, ...CNPJ_MASK }\n case 'telefone':\n return { ...options, ...PHONE_MASK }\n case 'cep':\n return { ...options, ...CEP_MASK }\n case 'numero-processo':\n return { ...options, ...NUMERO_PROCESSO_MASK }\n case 'data':\n return { ...options, ...DATE_MASK }\n case 'hora':\n return { ...options, ...TIME_MASK }\n case 'data-hora':\n return { ...options, ...DATETIME_MASK }\n case 'custom':\n if (!options) {\n throw new Error('Options are required for custom mask')\n }\n\n return options\n }\n}\n\nconst CPF_MASK: MaskOptions = {\n mask: '###.###.###-##',\n replacement: {\n '#': /\\d/\n }\n}\nconst CNPJ_MASK: MaskOptions = {\n mask: '##.###.###/####-##',\n replacement: {\n '#': /\\d/\n }\n}\nconst PHONE_MASK: MaskOptions = {\n mask: '(##) #####-####',\n replacement: {\n '#': /\\d/\n }\n}\nconst CEP_MASK: MaskOptions = {\n mask: '#####-###',\n replacement: {\n '#': /\\d/\n }\n}\nconst NUMERO_PROCESSO_MASK: MaskOptions = {\n mask: '#######-##.####.#.##.####',\n replacement: {\n '#': /\\d/\n }\n}\nconst DATE_MASK: MaskOptions = {\n mask: '##/##/####',\n replacement: {\n '#': /\\d/\n }\n}\nconst TIME_MASK: MaskOptions = {\n mask: '##:##',\n replacement: {\n '#': /\\d/\n }\n}\nconst DATETIME_MASK: MaskOptions = {\n mask: '##/##/#### ##:##',\n replacement: {\n '#': /\\d/\n }\n}\n","import { tv, twMerge } from '@xjur-ui/util'\nimport type { ComponentProps } from 'react'\nimport { createContext, useContext, useMemo } from 'react'\nimport { InputMask, type MaskOptions } from '@react-input/mask'\nimport {\n InputNumberFormat,\n type InputNumberFormatProps\n} from '@react-input/number-format'\nimport { inputMask, type InputMaskType } from '../resources/input-mask'\nimport { Typography } from './typography'\n\nexport { inputMask, type InputMaskType, type MaskOptions }\n\nexport type InputProps = {\n variant?: 'outlined' | 'filled'\n disabled?: boolean\n hasError?: boolean\n}\n\nconst FieldContext = createContext<InputProps>({\n variant: 'filled',\n disabled: false,\n hasError: false\n})\n\nfunction useInput() {\n const context = useContext(FieldContext)\n if (!context) {\n throw new Error('useInput must be used within a InputRoot')\n }\n return context\n}\n\nexport function InputRoot({\n className,\n children,\n variant = 'filled',\n disabled = false,\n hasError = false,\n ...props\n}: ComponentProps<'div'> & InputProps) {\n const providerValue = useMemo(\n () => ({ variant, disabled, hasError }),\n [variant, disabled, hasError]\n )\n\n return (\n <FieldContext.Provider value={providerValue}>\n <div\n className={twMerge('group relative flex w-full flex-col', className)}\n {...props}\n >\n {children}\n </div>\n </FieldContext.Provider>\n )\n}\n\nexport function InputContent({ className, ...props }: ComponentProps<'div'>) {\n const content = tv({\n base: twMerge(\n 'border border-transparent relative h-large-4x rounded-small-1x gap-small py-small_1x-alt px-small flex items-center w-full',\n 'group-has-[div[data-slot=input-right-action-slot]]:rounded-r-none',\n 'group-has-[div[data-slot=input-left-action-slot]]:rounded-l-none',\n 'focus-within:border-primary-idle focus-within:hover:border-primary-idle',\n 'hover:border-border-layer-1'\n ),\n variants: {\n variant: {\n filled: 'bg-layer-2-hover',\n outlined:\n 'bg-layer-2-idle border-border-layer-2 hover:border-border-layer-3',\n disabled: 'hover:border-transparent border-none bg-layer-2-idle'\n },\n state: {\n idle: '',\n error:\n 'focus-within:border-danger-idle hover:border-danger-idle border-danger-idle focus-within:hover:border-danger-idle'\n }\n },\n defaultVariants: {\n variant: 'filled',\n state: 'idle'\n }\n })\n\n return (\n <FieldContext.Consumer>\n {({ variant, disabled, hasError }) => {\n return (\n <div\n className={content({\n variant: disabled ? 'disabled' : variant,\n state: hasError ? 'error' : 'idle',\n className\n })}\n {...props}\n />\n )\n }}\n </FieldContext.Consumer>\n )\n}\n\nexport function InputLabel({\n htmlFor,\n className,\n children,\n ...props\n}: ComponentProps<typeof Typography> & { htmlFor: string }) {\n return (\n <FieldContext.Consumer>\n {({ variant, disabled, hasError }) => {\n return (\n <Typography\n asChild={true}\n className={twMerge(\n 'group inline-block max-w-full truncate text-left',\n 'ease animate-in left-small right-small pointer-events-none absolute top-1/2 -translate-y-1/2 transition-all duration-250',\n // Filled\n 'group-focus-within:!text-primary-idle group-focus-within:data-[has-error=true]:!text-danger-label-active group-focus-within:-top-[3px]',\n 'group-focus-within:text-size-label-sm-1x group-focus-within:font-medium',\n 'group-has-[input:not(:placeholder-shown)]:-top-[3px]',\n 'group-has-[input:not(:placeholder-shown)]:text-size-label-sm-1x',\n 'group-has-[input:not(:placeholder-shown)]:font-medium',\n 'group-has-[input:not(:placeholder-shown)]:!text-primary-idle',\n 'group-has-[input:not(:placeholder-shown)]:!text-danger-label-active',\n // If has left slot\n 'group-has-[div[data-slot=input-left-slot]]:left-large-4x',\n 'group-has-[div[data-slot=input-left-slot]]:group-focus-within:left-small',\n 'group-has-[div[data-slot=input-left-slot]]:group-has-[input:not(:placeholder-shown)]:left-small',\n // If has right slot\n 'group-has-[div[data-slot=input-right-slot]]:right-large-4x',\n 'group-has-[div[data-slot=input-right-slot]]:group-focus-within:right-small',\n 'group-has-[div[data-slot=input-right-slot]]:group-has-[input:not(:placeholder-shown)]:right-small',\n // Animate\n 'group-focus-within:animate-in',\n 'group-has-[input:not(:placeholder-shown)]:animate-out',\n 'data-[disabled=true]:hidden',\n className\n )}\n data-disabled={disabled}\n data-has-error={hasError}\n data-variant={variant}\n {...props}\n >\n <label htmlFor={htmlFor}>\n <span\n className={twMerge(\n 'rounded-small-1x max-w-full',\n 'group-data-[variant=outlined]:group-focus-within:bg-layer-2-idle group-data-[variant=filled]:group-focus-within:bg-layer-2-hover',\n 'group-data-[variant=outlined]:bg-layer-2-idle group-data-[variant=filled]:bg-layer-2-hover'\n )}\n >\n {children}\n </span>\n </label>\n </Typography>\n )\n }}\n </FieldContext.Consumer>\n )\n}\n\nexport function InputText({\n className,\n maskOptions,\n maskType,\n ...props\n}: ComponentProps<'input'> & {\n maskOptions?: MaskOptions\n maskType?: InputMaskType\n}) {\n const { disabled } = useInput()\n const Component = maskOptions || maskType ? InputMask : 'input'\n\n return (\n <Component\n {...props}\n disabled={disabled}\n {...(maskType\n ? { ...inputMask(maskType) }\n : maskOptions && { ...maskOptions })}\n className={twMerge(\n className,\n 'peer !text-size-body-md text-neutral-dark flex-1 outline-none',\n 'group-has-[div[data-slot=input-left-slot]]:pl-large-1x ml-small-1x'\n )}\n placeholder={props.placeholder || ' '}\n {...(maskOptions && { ...maskOptions })}\n />\n )\n}\n\nexport function InputNumber({\n className,\n locales = 'pt-BR',\n ...props\n}: InputNumberFormatProps) {\n const { disabled } = useInput()\n return (\n <InputNumberFormat\n {...props}\n className={twMerge(\n className,\n 'peer !text-size-body-md text-neutral-dark flex-1 font-medium outline-none',\n 'group-has-[div[data-slot=input-left-slot]]:pl-large-1x ml-small-1x'\n )}\n disabled={disabled}\n locales={locales}\n placeholder={props.placeholder || ' '}\n />\n )\n}\n\nexport function InputLeftSlot({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n {...props}\n className={twMerge(\n className,\n 'left-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center'\n )}\n data-slot=\"input-left-slot\"\n />\n )\n}\n\nexport function InputRightSlot({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n {...props}\n className={twMerge(\n className,\n 'right-small absolute top-1/2 flex -translate-y-1/2 items-center justify-center'\n )}\n data-slot=\"input-right-slot\"\n />\n )\n}\n\nexport function InputCaption({\n className,\n variant = 'body',\n size = 'sm',\n weight = 'normal',\n ...props\n}: ComponentProps<typeof Typography>) {\n const { hasError } = useInput()\n\n const caption = tv({\n base: 'text-size-body-sm mt-small-1x font-normal',\n variants: {\n state: {\n error: 'text-danger-label-active',\n idle: 'text-neutral-dark'\n }\n }\n })\n\n return (\n <Typography\n className={caption({\n state: hasError ? 'error' : 'idle',\n className\n })}\n size={size}\n variant={variant}\n weight={weight}\n {...props}\n />\n )\n}\n\nexport function InputContainer({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n {...props}\n className={twMerge(className, 'flex items-center')}\n data-slot=\"input-content\"\n />\n )\n}\n\nexport function InputAction({\n className,\n side,\n ...props\n}: ComponentProps<'div'> & {\n side: 'left' | 'right'\n}) {\n const { disabled } = useInput()\n return (\n <div\n {...props}\n className={twMerge(\n className,\n 'group h-large-4x flex items-center justify-center data-[disabled=true]:hidden'\n )}\n data-disabled={disabled}\n data-side={side}\n data-slot={`input-${side}-action-slot`}\n />\n )\n}\n\nexport function InputActionButton({\n className,\n ...props\n}: ComponentProps<'div'>) {\n return (\n <div\n {...props}\n className={twMerge(\n className,\n 'h-large-4x w-large-4x bg-layer-2-hover flex cursor-pointer items-center justify-center'\n )}\n />\n )\n}\n"]}
|