@egose/shadcn-theme 0.1.11 → 0.1.12
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/{chunk-OURAYOOM.mjs → chunk-3NMW42UR.mjs} +2 -2
- package/{chunk-AQWVA6TL.js → chunk-BIO4TVNT.js} +3 -3
- package/{chunk-XF75HZNV.js → chunk-NDH24NNQ.js} +2 -2
- package/{chunk-DL6HJ3OB.mjs → chunk-OZF3JOG4.mjs} +2 -2
- package/chunk-VYBFV2QD.js +31 -0
- package/chunk-WJKG5MUH.mjs +30 -0
- package/components/form/date-picker.js +3 -3
- package/components/form/date-picker.mjs +2 -2
- package/components/form/date-range-picker.js +2 -2
- package/components/form/date-range-picker.mjs +1 -1
- package/components/form/hook-checkbox.d.mts +7 -5
- package/components/form/hook-checkbox.d.ts +7 -5
- package/components/form/hook-checkbox.js +11 -3
- package/components/form/hook-checkbox.js.map +1 -1
- package/components/form/hook-checkbox.mjs +11 -3
- package/components/form/hook-checkbox.mjs.map +1 -1
- package/components/form/hook-date-picker.js +3 -3
- package/components/form/hook-date-picker.mjs +2 -2
- package/components/form/hook-native-select.d.mts +7 -4
- package/components/form/hook-native-select.d.ts +7 -4
- package/components/form/hook-native-select.js +13 -6
- package/components/form/hook-native-select.js.map +1 -1
- package/components/form/hook-native-select.mjs +13 -6
- package/components/form/hook-native-select.mjs.map +1 -1
- package/components/form/hook-text-input.d.mts +7 -4
- package/components/form/hook-text-input.d.ts +7 -4
- package/components/form/hook-text-input.js +26 -6
- package/components/form/hook-text-input.js.map +1 -1
- package/components/form/hook-text-input.mjs +26 -6
- package/components/form/hook-text-input.mjs.map +1 -1
- package/components/form/hook-textarea.d.mts +7 -4
- package/components/form/hook-textarea.d.ts +7 -4
- package/components/form/hook-textarea.js +20 -6
- package/components/form/hook-textarea.js.map +1 -1
- package/components/form/hook-textarea.mjs +20 -6
- package/components/form/hook-textarea.mjs.map +1 -1
- package/components/form/hook-time-input.d.mts +7 -5
- package/components/form/hook-time-input.d.ts +7 -5
- package/components/form/hook-time-input.js +24 -3
- package/components/form/hook-time-input.js.map +1 -1
- package/components/form/hook-time-input.mjs +24 -3
- package/components/form/hook-time-input.mjs.map +1 -1
- package/components/form/types.d.mts +12 -2
- package/components/form/types.d.ts +12 -2
- package/components/form/types.js +12 -1
- package/components/form/types.js.map +1 -1
- package/components/form/types.mjs +11 -0
- package/components/ui/calendar.js +2 -2
- package/components/ui/calendar.mjs +1 -1
- package/components/ui/multi-select.d.mts +1 -1
- package/components/ui/multi-select.d.ts +1 -1
- package/package.json +13 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Calendar
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OZF3JOG4.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Popover,
|
|
6
6
|
PopoverContent,
|
|
@@ -103,4 +103,4 @@ function FormDatePicker({
|
|
|
103
103
|
export {
|
|
104
104
|
FormDatePicker
|
|
105
105
|
};
|
|
106
|
-
//# sourceMappingURL=chunk-
|
|
106
|
+
//# sourceMappingURL=chunk-3NMW42UR.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkNDH24NNQjs = require('./chunk-NDH24NNQ.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -85,7 +85,7 @@ function FormDatePicker({
|
|
|
85
85
|
/* @__PURE__ */ _react2.default.createElement(_lucidereact.CalendarIcon, null),
|
|
86
86
|
display
|
|
87
87
|
)), /* @__PURE__ */ _react2.default.createElement(_chunkW4ZJYYQPjs.PopoverContent, { className: "w-auto p-0", align: "start" }, /* @__PURE__ */ _react2.default.createElement(
|
|
88
|
-
|
|
88
|
+
_chunkNDH24NNQjs.Calendar,
|
|
89
89
|
{
|
|
90
90
|
mode: "single",
|
|
91
91
|
defaultMonth: date,
|
|
@@ -104,4 +104,4 @@ function FormDatePicker({
|
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
exports.FormDatePicker = FormDatePicker;
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
107
|
+
//# sourceMappingURL=chunk-BIO4TVNT.js.map
|
|
@@ -84,7 +84,7 @@ function Calendar(_a) {
|
|
|
84
84
|
captionLayout === "label" ? "text-sm" : "cn-calendar-caption-label flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
|
|
85
85
|
defaultClassNames.caption_label
|
|
86
86
|
),
|
|
87
|
-
|
|
87
|
+
month_grid: _chunkNBQEF4JDjs.cn.call(void 0, "w-full border-collapse", defaultClassNames.month_grid),
|
|
88
88
|
weekdays: _chunkNBQEF4JDjs.cn.call(void 0, "flex", defaultClassNames.weekdays),
|
|
89
89
|
weekday: _chunkNBQEF4JDjs.cn.call(void 0,
|
|
90
90
|
"flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none",
|
|
@@ -184,4 +184,4 @@ function CalendarDayButton(_a) {
|
|
|
184
184
|
|
|
185
185
|
|
|
186
186
|
exports.Calendar = Calendar; exports.CalendarDayButton = CalendarDayButton;
|
|
187
|
-
//# sourceMappingURL=chunk-
|
|
187
|
+
//# sourceMappingURL=chunk-NDH24NNQ.js.map
|
|
@@ -83,7 +83,7 @@ function Calendar(_a) {
|
|
|
83
83
|
captionLayout === "label" ? "text-sm" : "cn-calendar-caption-label flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
|
|
84
84
|
defaultClassNames.caption_label
|
|
85
85
|
),
|
|
86
|
-
|
|
86
|
+
month_grid: cn("w-full border-collapse", defaultClassNames.month_grid),
|
|
87
87
|
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
88
88
|
weekday: cn(
|
|
89
89
|
"flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none",
|
|
@@ -183,4 +183,4 @@ export {
|
|
|
183
183
|
Calendar,
|
|
184
184
|
CalendarDayButton
|
|
185
185
|
};
|
|
186
|
-
//# sourceMappingURL=chunk-
|
|
186
|
+
//# sourceMappingURL=chunk-OZF3JOG4.mjs.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
3
|
+
|
|
4
|
+
var _chunk2NMEKWO5js = require('./chunk-2NMEKWO5.js');
|
|
5
|
+
|
|
6
|
+
// components/form/types.ts
|
|
7
|
+
function mergeHookFormRules(rules, overrides) {
|
|
8
|
+
const mergedRules = _chunk2NMEKWO5js.__spreadValues.call(void 0, {}, rules != null ? rules : {});
|
|
9
|
+
if (overrides.required !== void 0) mergedRules.required = overrides.required;
|
|
10
|
+
if (overrides.min !== void 0) mergedRules.min = overrides.min;
|
|
11
|
+
if (overrides.max !== void 0) mergedRules.max = overrides.max;
|
|
12
|
+
if (overrides.maxLength !== void 0) mergedRules.maxLength = overrides.maxLength;
|
|
13
|
+
if (overrides.minLength !== void 0) mergedRules.minLength = overrides.minLength;
|
|
14
|
+
return Object.keys(mergedRules).length > 0 ? mergedRules : void 0;
|
|
15
|
+
}
|
|
16
|
+
function isValidationRuleEnabled(rule) {
|
|
17
|
+
if (typeof rule === "boolean") return rule;
|
|
18
|
+
if (typeof rule === "string") return rule.length > 0;
|
|
19
|
+
return (rule == null ? void 0 : rule.value) === true;
|
|
20
|
+
}
|
|
21
|
+
function getValidationRuleValue(rule) {
|
|
22
|
+
if (rule && typeof rule === "object") return rule.value;
|
|
23
|
+
return rule;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
exports.mergeHookFormRules = mergeHookFormRules; exports.isValidationRuleEnabled = isValidationRuleEnabled; exports.getValidationRuleValue = getValidationRuleValue;
|
|
31
|
+
//# sourceMappingURL=chunk-VYBFV2QD.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadValues
|
|
3
|
+
} from "./chunk-YOSPWY5K.mjs";
|
|
4
|
+
|
|
5
|
+
// components/form/types.ts
|
|
6
|
+
function mergeHookFormRules(rules, overrides) {
|
|
7
|
+
const mergedRules = __spreadValues({}, rules != null ? rules : {});
|
|
8
|
+
if (overrides.required !== void 0) mergedRules.required = overrides.required;
|
|
9
|
+
if (overrides.min !== void 0) mergedRules.min = overrides.min;
|
|
10
|
+
if (overrides.max !== void 0) mergedRules.max = overrides.max;
|
|
11
|
+
if (overrides.maxLength !== void 0) mergedRules.maxLength = overrides.maxLength;
|
|
12
|
+
if (overrides.minLength !== void 0) mergedRules.minLength = overrides.minLength;
|
|
13
|
+
return Object.keys(mergedRules).length > 0 ? mergedRules : void 0;
|
|
14
|
+
}
|
|
15
|
+
function isValidationRuleEnabled(rule) {
|
|
16
|
+
if (typeof rule === "boolean") return rule;
|
|
17
|
+
if (typeof rule === "string") return rule.length > 0;
|
|
18
|
+
return (rule == null ? void 0 : rule.value) === true;
|
|
19
|
+
}
|
|
20
|
+
function getValidationRuleValue(rule) {
|
|
21
|
+
if (rule && typeof rule === "object") return rule.value;
|
|
22
|
+
return rule;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
mergeHookFormRules,
|
|
27
|
+
isValidationRuleEnabled,
|
|
28
|
+
getValidationRuleValue
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=chunk-WJKG5MUH.mjs.map
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('../../chunk-
|
|
5
|
+
var _chunkBIO4TVNTjs = require('../../chunk-BIO4TVNT.js');
|
|
6
|
+
require('../../chunk-NDH24NNQ.js');
|
|
7
7
|
require('../../chunk-W4ZJYYQP.js');
|
|
8
8
|
require('../../chunk-IEPLSUBR.js');
|
|
9
9
|
require('../../chunk-5CUM73VT.js');
|
|
@@ -13,5 +13,5 @@ require('../../chunk-NBQEF4JD.js');
|
|
|
13
13
|
require('../../chunk-2NMEKWO5.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
exports.FormDatePicker =
|
|
16
|
+
exports.FormDatePicker = _chunkBIO4TVNTjs.FormDatePicker;
|
|
17
17
|
//# sourceMappingURL=date-picker.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
FormDatePicker
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-3NMW42UR.mjs";
|
|
5
|
+
import "../../chunk-OZF3JOG4.mjs";
|
|
6
6
|
import "../../chunk-N3WWOWZ4.mjs";
|
|
7
7
|
import "../../chunk-S2LLOGBR.mjs";
|
|
8
8
|
import "../../chunk-ZJRJN2UJ.mjs";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkNDH24NNQjs = require('../../chunk-NDH24NNQ.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -72,7 +72,7 @@ function FormDateRangePicker({
|
|
|
72
72
|
/* @__PURE__ */ _react2.default.createElement(_lucidereact.CalendarIcon, null),
|
|
73
73
|
(value == null ? void 0 : value.from) ? value.to ? /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, formatDate(value.from), " - ", formatDate(value.to)) : formatDate(value.from) : /* @__PURE__ */ _react2.default.createElement("span", null, "Pick a date")
|
|
74
74
|
)), /* @__PURE__ */ _react2.default.createElement(_chunkW4ZJYYQPjs.PopoverContent, { className: "w-auto p-0", align: "start" }, /* @__PURE__ */ _react2.default.createElement(
|
|
75
|
-
|
|
75
|
+
_chunkNDH24NNQjs.Calendar,
|
|
76
76
|
{
|
|
77
77
|
mode: "range",
|
|
78
78
|
defaultMonth: value == null ? void 0 : value.from,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import { FieldValues, Path
|
|
2
|
+
import { FieldValues, Path } from 'react-hook-form';
|
|
3
3
|
import { FormCheckboxProps } from './checkbox.mjs';
|
|
4
|
+
import { HookFormValidationAttributes, HookFormRules } from './types.mjs';
|
|
4
5
|
|
|
5
|
-
type
|
|
6
|
+
type HookFormCheckboxValidationAttributes = Pick<HookFormValidationAttributes, 'required'>;
|
|
7
|
+
type HookFormCheckboxProps<T extends FieldValues> = Omit<FormCheckboxProps, 'name' | 'checked' | 'onCheckedChange' | keyof HookFormCheckboxValidationAttributes> & {
|
|
6
8
|
name: Path<T>;
|
|
7
|
-
rules?:
|
|
9
|
+
rules?: HookFormRules<T>;
|
|
8
10
|
error?: string;
|
|
9
|
-
};
|
|
10
|
-
declare function HookFormCheckbox<T extends FieldValues>({ id, name, label, rules, error, disabled, classNames, ...rest }: HookFormCheckboxProps<T>): React__default.JSX.Element | null;
|
|
11
|
+
} & HookFormCheckboxValidationAttributes;
|
|
12
|
+
declare function HookFormCheckbox<T extends FieldValues>({ id, name, label, rules, required, error, disabled, classNames, ...rest }: HookFormCheckboxProps<T>): React__default.JSX.Element | null;
|
|
11
13
|
|
|
12
14
|
export { HookFormCheckbox };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import { FieldValues, Path
|
|
2
|
+
import { FieldValues, Path } from 'react-hook-form';
|
|
3
3
|
import { FormCheckboxProps } from './checkbox.js';
|
|
4
|
+
import { HookFormValidationAttributes, HookFormRules } from './types.js';
|
|
4
5
|
|
|
5
|
-
type
|
|
6
|
+
type HookFormCheckboxValidationAttributes = Pick<HookFormValidationAttributes, 'required'>;
|
|
7
|
+
type HookFormCheckboxProps<T extends FieldValues> = Omit<FormCheckboxProps, 'name' | 'checked' | 'onCheckedChange' | keyof HookFormCheckboxValidationAttributes> & {
|
|
6
8
|
name: Path<T>;
|
|
7
|
-
rules?:
|
|
9
|
+
rules?: HookFormRules<T>;
|
|
8
10
|
error?: string;
|
|
9
|
-
};
|
|
10
|
-
declare function HookFormCheckbox<T extends FieldValues>({ id, name, label, rules, error, disabled, classNames, ...rest }: HookFormCheckboxProps<T>): React__default.JSX.Element | null;
|
|
11
|
+
} & HookFormCheckboxValidationAttributes;
|
|
12
|
+
declare function HookFormCheckbox<T extends FieldValues>({ id, name, label, rules, required, error, disabled, classNames, ...rest }: HookFormCheckboxProps<T>): React__default.JSX.Element | null;
|
|
11
13
|
|
|
12
14
|
export { HookFormCheckbox };
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
var _chunkVYBFV2QDjs = require('../../chunk-VYBFV2QD.js');
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
var _chunkHDO7OG7Ijs = require('../../chunk-HDO7OG7I.js');
|
|
6
10
|
|
|
7
11
|
|
|
@@ -27,6 +31,7 @@ function HookFormCheckbox(_a) {
|
|
|
27
31
|
name,
|
|
28
32
|
label,
|
|
29
33
|
rules,
|
|
34
|
+
required,
|
|
30
35
|
error,
|
|
31
36
|
disabled,
|
|
32
37
|
classNames
|
|
@@ -35,6 +40,7 @@ function HookFormCheckbox(_a) {
|
|
|
35
40
|
"name",
|
|
36
41
|
"label",
|
|
37
42
|
"rules",
|
|
43
|
+
"required",
|
|
38
44
|
"error",
|
|
39
45
|
"disabled",
|
|
40
46
|
"classNames"
|
|
@@ -48,18 +54,20 @@ function HookFormCheckbox(_a) {
|
|
|
48
54
|
const fieldError = _get3.default.call(void 0, errors, name);
|
|
49
55
|
const errorMessage = error != null ? error : fieldError == null ? void 0 : fieldError.message;
|
|
50
56
|
const showError = !!fieldError && !disabled;
|
|
57
|
+
const mergedRules = _chunkVYBFV2QDjs.mergeHookFormRules.call(void 0, rules, { required });
|
|
51
58
|
return /* @__PURE__ */ _react2.default.createElement("div", { className: _chunkNBQEF4JDjs.cn.call(void 0, "$hook-form-checkbox", classNames == null ? void 0 : classNames.wrapper) }, /* @__PURE__ */ _react2.default.createElement(
|
|
52
59
|
_reacthookform.Controller,
|
|
53
60
|
{
|
|
54
61
|
name,
|
|
55
62
|
control,
|
|
56
|
-
rules,
|
|
63
|
+
rules: mergedRules,
|
|
57
64
|
render: ({ field: { value, onChange } }) => /* @__PURE__ */ _react2.default.createElement(
|
|
58
65
|
_chunkSOJSGQJOjs.FormCheckbox,
|
|
59
|
-
_chunk2NMEKWO5js.__spreadValues.call(void 0, {
|
|
66
|
+
_chunk2NMEKWO5js.__spreadProps.call(void 0, _chunk2NMEKWO5js.__spreadValues.call(void 0, {}, rest), {
|
|
60
67
|
id,
|
|
61
68
|
name,
|
|
62
69
|
label,
|
|
70
|
+
required: _chunkVYBFV2QDjs.isValidationRuleEnabled.call(void 0, mergedRules == null ? void 0 : mergedRules.required),
|
|
63
71
|
disabled,
|
|
64
72
|
checked: value,
|
|
65
73
|
onCheckedChange: onChange,
|
|
@@ -71,7 +79,7 @@ function HookFormCheckbox(_a) {
|
|
|
71
79
|
"ring-danger text-danger": showError
|
|
72
80
|
})
|
|
73
81
|
})
|
|
74
|
-
}
|
|
82
|
+
})
|
|
75
83
|
)
|
|
76
84
|
}
|
|
77
85
|
), showError && /* @__PURE__ */ _react2.default.createElement(_chunkHDO7OG7Ijs.FormError, { field: name, className: "mt-1", message: errorMessage }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-checkbox.js","../../../components/form/hook-checkbox.tsx"],"names":[],"mappings":"AAAA,qLAAY;AACZ;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC;AACA;
|
|
1
|
+
{"version":3,"sources":["/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-checkbox.js","../../../components/form/hook-checkbox.tsx"],"names":[],"mappings":"AAAA,qLAAY;AACZ;AACE;AACA;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC;AACA;ACrBA,4EAAkB;AAClB,gFAAiB;AACjB,gDAA8D;AAmBvD,SAAS,gBAAA,CAAwC,EAAA,EAU3B;AAV2B,EAAA,IAAA,GAAA,EAAA,EAAA,EACtD;AAAA,IAAA,EAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,EA9BF,EAAA,EAsBwD,EAAA,EASnD,KAAA,EAAA,wCAAA,EATmD,EASnD;AAAA,IARH,IAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,EAAA,CAAA,CAAA;AAGA,EAAA,MAAM,QAAA,EAAU,2CAAA,CAAkB;AAClC,EAAA,GAAA,CAAI,CAAC,OAAA,EAAS,OAAO,IAAA;AAErB,EAAA,MAAM;AAAA,IACJ,OAAA;AAAA,IACA,SAAA,EAAW,EAAE,OAAO;AAAA,EACtB,EAAA,EAAI,OAAA;AAEJ,EAAA,MAAM,WAAA,EAAa,2BAAA,MAAK,EAAQ,IAAI,CAAA;AACpC,EAAA,MAAM,aAAA,EAAe,MAAA,GAAA,KAAA,EAAA,MAAA,EAAU,WAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,OAAA;AAC3C,EAAA,MAAM,UAAA,EAAY,CAAC,CAAC,WAAA,GAAc,CAAC,QAAA;AACnC,EAAA,MAAM,YAAA,EAAc,iDAAA,KAAmB,EAAO,EAAE,SAAS,CAAC,CAAA;AAE1D,EAAA,uBACE,eAAA,CAAA,aAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAW,iCAAA,qBAAG,EAAuB,WAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,OAAO,EAAA,CAAA,kBAC3D,eAAA,CAAA,aAAA;AAAA,IAAC,yBAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,OAAA;AAAA,MACA,KAAA,EAAO,WAAA;AAAA,MACP,MAAA,EAAQ,CAAC,EAAE,KAAA,EAAO,EAAE,KAAA,EAAO,SAAS,EAAE,CAAA,EAAA,mBACpC,eAAA,CAAA,aAAA;AAAA,QAAC,6BAAA;AAAA,QAAA,4CAAA,6CAAA,CAAA,CAAA,EACK,IAAA,CAAA,EADL;AAAA,UAEC,EAAA;AAAA,UACA,IAAA;AAAA,UACA,KAAA;AAAA,UACA,QAAA,EAAU,sDAAA,YAAwB,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,WAAA,CAAa,QAAQ,CAAA;AAAA,UACvD,QAAA;AAAA,UACA,OAAA,EAAS,KAAA;AAAA,UACT,eAAA,EAAiB,QAAA;AAAA,UACjB,UAAA,EAAY,4CAAA,6CAAA,CAAA,CAAA,EACP,UAAA,CAAA,EADO;AAAA,YAEV,KAAA,EAAO,iCAAA,WAAG,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,KAAA,EAAO;AAAA,cAC3B,aAAA,EAAe;AAAA,YACjB,CAAC,CAAA;AAAA,YACD,QAAA,EAAU,iCAAA,WAAG,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,QAAA,EAAU;AAAA,cACjC,yBAAA,EAA2B;AAAA,YAC7B,CAAC;AAAA,UACH,CAAA;AAAA,QAAA,CAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ,CAAA,EACC,UAAA,mBAAa,eAAA,CAAA,aAAA,CAAC,0BAAA,EAAA,EAAU,KAAA,EAAO,IAAA,EAAM,SAAA,EAAU,MAAA,EAAO,OAAA,EAAS,aAAA,CAAc,CAChF,CAAA;AAEJ;ADQA;AACE;AACF,4CAAC","file":"/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-checkbox.js","sourcesContent":[null,"\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { Controller, FieldValues, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormCheckbox } from './checkbox';\nimport type { FormCheckboxProps } from './checkbox';\nimport { isValidationRuleEnabled, mergeHookFormRules } from './types';\nimport type { HookFormRules, HookFormValidationAttributes } from './types';\n\ntype HookFormCheckboxValidationAttributes = Pick<HookFormValidationAttributes, 'required'>;\n\ntype HookFormCheckboxProps<T extends FieldValues> = Omit<\n FormCheckboxProps,\n 'name' | 'checked' | 'onCheckedChange' | keyof HookFormCheckboxValidationAttributes\n> & {\n name: Path<T>;\n rules?: HookFormRules<T>;\n error?: string;\n} & HookFormCheckboxValidationAttributes;\n\nexport function HookFormCheckbox<T extends FieldValues>({\n id,\n name,\n label,\n rules,\n required,\n error,\n disabled,\n classNames,\n ...rest\n}: HookFormCheckboxProps<T>) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n control,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError?.message as string);\n const showError = !!fieldError && !disabled;\n const mergedRules = mergeHookFormRules(rules, { required });\n\n return (\n <div className={cn('$hook-form-checkbox', classNames?.wrapper)}>\n <Controller\n name={name}\n control={control}\n rules={mergedRules}\n render={({ field: { value, onChange } }) => (\n <FormCheckbox\n {...rest}\n id={id}\n name={name}\n label={label}\n required={isValidationRuleEnabled(mergedRules?.required)}\n disabled={disabled}\n checked={value}\n onCheckedChange={onChange}\n classNames={{\n ...classNames,\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n checkbox: cn(classNames?.checkbox, {\n 'ring-danger text-danger': showError,\n }),\n }}\n />\n )}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"]}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
isValidationRuleEnabled,
|
|
4
|
+
mergeHookFormRules
|
|
5
|
+
} from "../../chunk-WJKG5MUH.mjs";
|
|
2
6
|
import {
|
|
3
7
|
FormError
|
|
4
8
|
} from "../../chunk-42IQSRLZ.mjs";
|
|
@@ -26,6 +30,7 @@ function HookFormCheckbox(_a) {
|
|
|
26
30
|
name,
|
|
27
31
|
label,
|
|
28
32
|
rules,
|
|
33
|
+
required,
|
|
29
34
|
error,
|
|
30
35
|
disabled,
|
|
31
36
|
classNames
|
|
@@ -34,6 +39,7 @@ function HookFormCheckbox(_a) {
|
|
|
34
39
|
"name",
|
|
35
40
|
"label",
|
|
36
41
|
"rules",
|
|
42
|
+
"required",
|
|
37
43
|
"error",
|
|
38
44
|
"disabled",
|
|
39
45
|
"classNames"
|
|
@@ -47,18 +53,20 @@ function HookFormCheckbox(_a) {
|
|
|
47
53
|
const fieldError = _get(errors, name);
|
|
48
54
|
const errorMessage = error != null ? error : fieldError == null ? void 0 : fieldError.message;
|
|
49
55
|
const showError = !!fieldError && !disabled;
|
|
56
|
+
const mergedRules = mergeHookFormRules(rules, { required });
|
|
50
57
|
return /* @__PURE__ */ React.createElement("div", { className: cn("$hook-form-checkbox", classNames == null ? void 0 : classNames.wrapper) }, /* @__PURE__ */ React.createElement(
|
|
51
58
|
Controller,
|
|
52
59
|
{
|
|
53
60
|
name,
|
|
54
61
|
control,
|
|
55
|
-
rules,
|
|
62
|
+
rules: mergedRules,
|
|
56
63
|
render: ({ field: { value, onChange } }) => /* @__PURE__ */ React.createElement(
|
|
57
64
|
FormCheckbox,
|
|
58
|
-
__spreadValues({
|
|
65
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
59
66
|
id,
|
|
60
67
|
name,
|
|
61
68
|
label,
|
|
69
|
+
required: isValidationRuleEnabled(mergedRules == null ? void 0 : mergedRules.required),
|
|
62
70
|
disabled,
|
|
63
71
|
checked: value,
|
|
64
72
|
onCheckedChange: onChange,
|
|
@@ -70,7 +78,7 @@ function HookFormCheckbox(_a) {
|
|
|
70
78
|
"ring-danger text-danger": showError
|
|
71
79
|
})
|
|
72
80
|
})
|
|
73
|
-
}
|
|
81
|
+
})
|
|
74
82
|
)
|
|
75
83
|
}
|
|
76
84
|
), showError && /* @__PURE__ */ React.createElement(FormError, { field: name, className: "mt-1", message: errorMessage }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../components/form/hook-checkbox.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { Controller, FieldValues,
|
|
1
|
+
{"version":3,"sources":["../../../components/form/hook-checkbox.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { Controller, FieldValues, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormCheckbox } from './checkbox';\nimport type { FormCheckboxProps } from './checkbox';\nimport { isValidationRuleEnabled, mergeHookFormRules } from './types';\nimport type { HookFormRules, HookFormValidationAttributes } from './types';\n\ntype HookFormCheckboxValidationAttributes = Pick<HookFormValidationAttributes, 'required'>;\n\ntype HookFormCheckboxProps<T extends FieldValues> = Omit<\n FormCheckboxProps,\n 'name' | 'checked' | 'onCheckedChange' | keyof HookFormCheckboxValidationAttributes\n> & {\n name: Path<T>;\n rules?: HookFormRules<T>;\n error?: string;\n} & HookFormCheckboxValidationAttributes;\n\nexport function HookFormCheckbox<T extends FieldValues>({\n id,\n name,\n label,\n rules,\n required,\n error,\n disabled,\n classNames,\n ...rest\n}: HookFormCheckboxProps<T>) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n control,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError?.message as string);\n const showError = !!fieldError && !disabled;\n const mergedRules = mergeHookFormRules(rules, { required });\n\n return (\n <div className={cn('$hook-form-checkbox', classNames?.wrapper)}>\n <Controller\n name={name}\n control={control}\n rules={mergedRules}\n render={({ field: { value, onChange } }) => (\n <FormCheckbox\n {...rest}\n id={id}\n name={name}\n label={label}\n required={isValidationRuleEnabled(mergedRules?.required)}\n disabled={disabled}\n checked={value}\n onCheckedChange={onChange}\n classNames={{\n ...classNames,\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n checkbox: cn(classNames?.checkbox, {\n 'ring-danger text-danger': showError,\n }),\n }}\n />\n )}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAAS,YAA+B,sBAAsB;AAmBvD,SAAS,iBAAwC,IAU3B;AAV2B,eACtD;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EA9BF,IAsBwD,IASnD,iBATmD,IASnD;AAAA,IARH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM,UAAU,eAAkB;AAClC,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM;AAAA,IACJ;AAAA,IACA,WAAW,EAAE,OAAO;AAAA,EACtB,IAAI;AAEJ,QAAM,aAAa,KAAK,QAAQ,IAAI;AACpC,QAAM,eAAe,wBAAU,yCAAY;AAC3C,QAAM,YAAY,CAAC,CAAC,cAAc,CAAC;AACnC,QAAM,cAAc,mBAAmB,OAAO,EAAE,SAAS,CAAC;AAE1D,SACE,oCAAC,SAAI,WAAW,GAAG,uBAAuB,yCAAY,OAAO,KAC3D;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,SAAS,EAAE,MACpC;AAAA,QAAC;AAAA,yCACK,OADL;AAAA,UAEC;AAAA,UACA;AAAA,UACA;AAAA,UACA,UAAU,wBAAwB,2CAAa,QAAQ;AAAA,UACvD;AAAA,UACA,SAAS;AAAA,UACT,iBAAiB;AAAA,UACjB,YAAY,iCACP,aADO;AAAA,YAEV,OAAO,GAAG,yCAAY,OAAO;AAAA,cAC3B,eAAe;AAAA,YACjB,CAAC;AAAA,YACD,UAAU,GAAG,yCAAY,UAAU;AAAA,cACjC,2BAA2B;AAAA,YAC7B,CAAC;AAAA,UACH;AAAA;AAAA,MACF;AAAA;AAAA,EAEJ,GACC,aAAa,oCAAC,aAAU,OAAO,MAAM,WAAU,QAAO,SAAS,cAAc,CAChF;AAEJ;","names":[]}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
var _chunkHDO7OG7Ijs = require('../../chunk-HDO7OG7I.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
require('../../chunk-
|
|
8
|
+
var _chunkBIO4TVNTjs = require('../../chunk-BIO4TVNT.js');
|
|
9
|
+
require('../../chunk-NDH24NNQ.js');
|
|
10
10
|
require('../../chunk-W4ZJYYQP.js');
|
|
11
11
|
require('../../chunk-IEPLSUBR.js');
|
|
12
12
|
require('../../chunk-5CUM73VT.js');
|
|
@@ -52,7 +52,7 @@ function HookFormDatePicker(_a) {
|
|
|
52
52
|
rules,
|
|
53
53
|
render: ({ field: { onChange, onBlur, value } }) => {
|
|
54
54
|
return /* @__PURE__ */ _react2.default.createElement(
|
|
55
|
-
|
|
55
|
+
_chunkBIO4TVNTjs.FormDatePicker,
|
|
56
56
|
_chunk2NMEKWO5js.__spreadProps.call(void 0, _chunk2NMEKWO5js.__spreadValues.call(void 0, {
|
|
57
57
|
id,
|
|
58
58
|
name,
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
} from "../../chunk-42IQSRLZ.mjs";
|
|
5
5
|
import {
|
|
6
6
|
FormDatePicker
|
|
7
|
-
} from "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
7
|
+
} from "../../chunk-3NMW42UR.mjs";
|
|
8
|
+
import "../../chunk-OZF3JOG4.mjs";
|
|
9
9
|
import "../../chunk-N3WWOWZ4.mjs";
|
|
10
10
|
import "../../chunk-S2LLOGBR.mjs";
|
|
11
11
|
import "../../chunk-ZJRJN2UJ.mjs";
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import { FieldValues, Path
|
|
2
|
+
import { FieldValues, Path } from 'react-hook-form';
|
|
3
3
|
import { FormNativeSelectProps } from './native-select.mjs';
|
|
4
|
+
import { HookFormValidationAttributes, HookFormRules } from './types.mjs';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
type HookFormNativeSelectValidationAttributes = Pick<HookFormValidationAttributes, 'required'>;
|
|
7
|
+
type HookFormNativeSelectProps<T extends FieldValues> = Omit<FormNativeSelectProps, 'name' | 'selectProps' | keyof HookFormNativeSelectValidationAttributes> & {
|
|
6
8
|
name: Path<T>;
|
|
7
|
-
rules?:
|
|
9
|
+
rules?: HookFormRules<T>;
|
|
8
10
|
error?: string;
|
|
9
|
-
}
|
|
11
|
+
} & HookFormNativeSelectValidationAttributes;
|
|
12
|
+
declare function HookFormNativeSelect<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, required, ...rest }: HookFormNativeSelectProps<T>): React__default.JSX.Element | null;
|
|
10
13
|
|
|
11
14
|
export { HookFormNativeSelect };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import { FieldValues, Path
|
|
2
|
+
import { FieldValues, Path } from 'react-hook-form';
|
|
3
3
|
import { FormNativeSelectProps } from './native-select.js';
|
|
4
|
+
import { HookFormValidationAttributes, HookFormRules } from './types.js';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
type HookFormNativeSelectValidationAttributes = Pick<HookFormValidationAttributes, 'required'>;
|
|
7
|
+
type HookFormNativeSelectProps<T extends FieldValues> = Omit<FormNativeSelectProps, 'name' | 'selectProps' | keyof HookFormNativeSelectValidationAttributes> & {
|
|
6
8
|
name: Path<T>;
|
|
7
|
-
rules?:
|
|
9
|
+
rules?: HookFormRules<T>;
|
|
8
10
|
error?: string;
|
|
9
|
-
}
|
|
11
|
+
} & HookFormNativeSelectValidationAttributes;
|
|
12
|
+
declare function HookFormNativeSelect<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, required, ...rest }: HookFormNativeSelectProps<T>): React__default.JSX.Element | null;
|
|
10
13
|
|
|
11
14
|
export { HookFormNativeSelect };
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
var _chunkVHXALM6Ojs = require('../../chunk-VHXALM6O.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
|
|
9
|
+
var _chunkVYBFV2QDjs = require('../../chunk-VYBFV2QD.js');
|
|
10
|
+
|
|
11
|
+
|
|
8
12
|
var _chunkHDO7OG7Ijs = require('../../chunk-HDO7OG7I.js');
|
|
9
13
|
require('../../chunk-OZAVO5UA.js');
|
|
10
14
|
|
|
@@ -28,7 +32,8 @@ function HookFormNativeSelect(_a) {
|
|
|
28
32
|
label,
|
|
29
33
|
error,
|
|
30
34
|
classNames,
|
|
31
|
-
disabled
|
|
35
|
+
disabled,
|
|
36
|
+
required
|
|
32
37
|
} = _b, rest = _chunk2NMEKWO5js.__objRest.call(void 0, _b, [
|
|
33
38
|
"id",
|
|
34
39
|
"name",
|
|
@@ -36,7 +41,8 @@ function HookFormNativeSelect(_a) {
|
|
|
36
41
|
"label",
|
|
37
42
|
"error",
|
|
38
43
|
"classNames",
|
|
39
|
-
"disabled"
|
|
44
|
+
"disabled",
|
|
45
|
+
"required"
|
|
40
46
|
]);
|
|
41
47
|
const methods = _reacthookform.useFormContext.call(void 0, );
|
|
42
48
|
if (!methods) return null;
|
|
@@ -47,14 +53,15 @@ function HookFormNativeSelect(_a) {
|
|
|
47
53
|
const fieldError = _get3.default.call(void 0, errors, name);
|
|
48
54
|
const errorMessage = error != null ? error : fieldError && String(fieldError == null ? void 0 : fieldError.message);
|
|
49
55
|
const showError = !!fieldError && !disabled;
|
|
56
|
+
const mergedRules = _chunkVYBFV2QDjs.mergeHookFormRules.call(void 0, rules, { required });
|
|
50
57
|
return /* @__PURE__ */ _react2.default.createElement("div", { className: _chunkNBQEF4JDjs.cn.call(void 0, "$hook-form-native-select", classNames == null ? void 0 : classNames.wrapper) }, /* @__PURE__ */ _react2.default.createElement(
|
|
51
58
|
_chunkVHXALM6Ojs.FormNativeSelect,
|
|
52
|
-
_chunk2NMEKWO5js.__spreadProps.call(void 0, _chunk2NMEKWO5js.__spreadValues.call(void 0, {
|
|
59
|
+
_chunk2NMEKWO5js.__spreadProps.call(void 0, _chunk2NMEKWO5js.__spreadValues.call(void 0, {}, rest), {
|
|
53
60
|
id,
|
|
54
61
|
name,
|
|
55
62
|
label,
|
|
56
|
-
disabled
|
|
57
|
-
|
|
63
|
+
disabled,
|
|
64
|
+
required: _chunkVYBFV2QDjs.isValidationRuleEnabled.call(void 0, mergedRules == null ? void 0 : mergedRules.required),
|
|
58
65
|
classNames: {
|
|
59
66
|
label: _chunkNBQEF4JDjs.cn.call(void 0, classNames == null ? void 0 : classNames.label, {
|
|
60
67
|
"text-danger": showError
|
|
@@ -63,7 +70,7 @@ function HookFormNativeSelect(_a) {
|
|
|
63
70
|
"ring-danger text-danger": showError
|
|
64
71
|
})
|
|
65
72
|
},
|
|
66
|
-
selectProps: register(name,
|
|
73
|
+
selectProps: register(name, mergedRules)
|
|
67
74
|
})
|
|
68
75
|
), showError && /* @__PURE__ */ _react2.default.createElement(_chunkHDO7OG7Ijs.FormError, { field: name, className: "mt-1", message: errorMessage }));
|
|
69
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-native-select.js","../../../components/form/hook-native-select.tsx"],"names":[],"mappings":"AAAA,qLAAY;AACZ;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC;AACA;
|
|
1
|
+
{"version":3,"sources":["/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-native-select.js","../../../components/form/hook-native-select.tsx"],"names":[],"mappings":"AAAA,qLAAY;AACZ;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC;AACA;ACpBA,4EAAkB;AAClB,gFAAiB;AACjB,gDAAkD;AAmB3C,SAAS,oBAAA,CAA4C,EAAA,EAU3B;AAV2B,EAAA,IAAA,GAAA,EAAA,EAAA,EAC1D;AAAA,IAAA,EAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,EA9BF,EAAA,EAsB4D,EAAA,EASvD,KAAA,EAAA,wCAAA,EATuD,EASvD;AAAA,IARH,IAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,YAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,EAAA,CAAA,CAAA;AAGA,EAAA,MAAM,QAAA,EAAU,2CAAA,CAAkB;AAClC,EAAA,GAAA,CAAI,CAAC,OAAA,EAAS,OAAO,IAAA;AAErB,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,SAAA,EAAW,EAAE,OAAO;AAAA,EACtB,EAAA,EAAI,OAAA;AAEJ,EAAA,MAAM,WAAA,EAAa,2BAAA,MAAK,EAAQ,IAAI,CAAA;AACpC,EAAA,MAAM,aAAA,EAAe,MAAA,GAAA,KAAA,EAAA,MAAA,EAAU,WAAA,GAAc,MAAA,CAAO,WAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,OAAO,CAAA;AACvE,EAAA,MAAM,UAAA,EAAY,CAAC,CAAC,WAAA,GAAc,CAAC,QAAA;AACnC,EAAA,MAAM,YAAA,EAAc,iDAAA,KAAmB,EAAO,EAAE,SAAS,CAAC,CAAA;AAE1D,EAAA,uBACE,eAAA,CAAA,aAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAW,iCAAA,0BAAG,EAA4B,WAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,OAAO,EAAA,CAAA,kBAChE,eAAA,CAAA,aAAA;AAAA,IAAC,iCAAA;AAAA,IAAA,4CAAA,6CAAA,CAAA,CAAA,EACK,IAAA,CAAA,EADL;AAAA,MAEC,EAAA;AAAA,MACA,IAAA;AAAA,MACA,KAAA;AAAA,MACA,QAAA;AAAA,MACA,QAAA,EAAU,sDAAA,YAAwB,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,WAAA,CAAa,QAAQ,CAAA;AAAA,MACvD,UAAA,EAAY;AAAA,QACV,KAAA,EAAO,iCAAA,WAAG,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,KAAA,EAAO;AAAA,UAC3B,aAAA,EAAe;AAAA,QACjB,CAAC,CAAA;AAAA,QACD,KAAA,EAAO,iCAAA,WAAG,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,KAAA,EAAO;AAAA,UAC3B,yBAAA,EAA2B;AAAA,QAC7B,CAAC;AAAA,MACH,CAAA;AAAA,MACA,WAAA,EAAa,QAAA,CAAS,IAAA,EAAM,WAAW;AAAA,IAAA,CAAA;AAAA,EACzC,CAAA,EACC,UAAA,mBAAa,eAAA,CAAA,aAAA,CAAC,0BAAA,EAAA,EAAU,KAAA,EAAO,IAAA,EAAM,SAAA,EAAU,MAAA,EAAO,OAAA,EAAS,aAAA,CAAc,CAChF,CAAA;AAEJ;ADOA;AACE;AACF,oDAAC","file":"/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-native-select.js","sourcesContent":[null,"\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { FieldValues, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormNativeSelect } from './native-select';\nimport type { FormNativeSelectProps } from './native-select';\nimport { isValidationRuleEnabled, mergeHookFormRules } from './types';\nimport type { HookFormRules, HookFormValidationAttributes } from './types';\n\ntype HookFormNativeSelectValidationAttributes = Pick<HookFormValidationAttributes, 'required'>;\n\ntype HookFormNativeSelectProps<T extends FieldValues> = Omit<\n FormNativeSelectProps,\n 'name' | 'selectProps' | keyof HookFormNativeSelectValidationAttributes\n> & {\n name: Path<T>;\n rules?: HookFormRules<T>;\n error?: string;\n} & HookFormNativeSelectValidationAttributes;\n\nexport function HookFormNativeSelect<T extends FieldValues>({\n id,\n name,\n rules,\n label,\n error,\n classNames,\n disabled,\n required,\n ...rest\n}: HookFormNativeSelectProps<T>) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n register,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError && String(fieldError?.message));\n const showError = !!fieldError && !disabled;\n const mergedRules = mergeHookFormRules(rules, { required });\n\n return (\n <div className={cn('$hook-form-native-select', classNames?.wrapper)}>\n <FormNativeSelect\n {...rest}\n id={id}\n name={name}\n label={label}\n disabled={disabled}\n required={isValidationRuleEnabled(mergedRules?.required)}\n classNames={{\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n input: cn(classNames?.input, {\n 'ring-danger text-danger': showError,\n }),\n }}\n selectProps={register(name, mergedRules)}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"]}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
FormNativeSelect
|
|
4
4
|
} from "../../chunk-NQQR2NDC.mjs";
|
|
5
|
+
import {
|
|
6
|
+
isValidationRuleEnabled,
|
|
7
|
+
mergeHookFormRules
|
|
8
|
+
} from "../../chunk-WJKG5MUH.mjs";
|
|
5
9
|
import {
|
|
6
10
|
FormError
|
|
7
11
|
} from "../../chunk-42IQSRLZ.mjs";
|
|
@@ -27,7 +31,8 @@ function HookFormNativeSelect(_a) {
|
|
|
27
31
|
label,
|
|
28
32
|
error,
|
|
29
33
|
classNames,
|
|
30
|
-
disabled
|
|
34
|
+
disabled,
|
|
35
|
+
required
|
|
31
36
|
} = _b, rest = __objRest(_b, [
|
|
32
37
|
"id",
|
|
33
38
|
"name",
|
|
@@ -35,7 +40,8 @@ function HookFormNativeSelect(_a) {
|
|
|
35
40
|
"label",
|
|
36
41
|
"error",
|
|
37
42
|
"classNames",
|
|
38
|
-
"disabled"
|
|
43
|
+
"disabled",
|
|
44
|
+
"required"
|
|
39
45
|
]);
|
|
40
46
|
const methods = useFormContext();
|
|
41
47
|
if (!methods) return null;
|
|
@@ -46,14 +52,15 @@ function HookFormNativeSelect(_a) {
|
|
|
46
52
|
const fieldError = _get(errors, name);
|
|
47
53
|
const errorMessage = error != null ? error : fieldError && String(fieldError == null ? void 0 : fieldError.message);
|
|
48
54
|
const showError = !!fieldError && !disabled;
|
|
55
|
+
const mergedRules = mergeHookFormRules(rules, { required });
|
|
49
56
|
return /* @__PURE__ */ React.createElement("div", { className: cn("$hook-form-native-select", classNames == null ? void 0 : classNames.wrapper) }, /* @__PURE__ */ React.createElement(
|
|
50
57
|
FormNativeSelect,
|
|
51
|
-
__spreadProps(__spreadValues({
|
|
58
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
52
59
|
id,
|
|
53
60
|
name,
|
|
54
61
|
label,
|
|
55
|
-
disabled
|
|
56
|
-
|
|
62
|
+
disabled,
|
|
63
|
+
required: isValidationRuleEnabled(mergedRules == null ? void 0 : mergedRules.required),
|
|
57
64
|
classNames: {
|
|
58
65
|
label: cn(classNames == null ? void 0 : classNames.label, {
|
|
59
66
|
"text-danger": showError
|
|
@@ -62,7 +69,7 @@ function HookFormNativeSelect(_a) {
|
|
|
62
69
|
"ring-danger text-danger": showError
|
|
63
70
|
})
|
|
64
71
|
},
|
|
65
|
-
selectProps: register(name,
|
|
72
|
+
selectProps: register(name, mergedRules)
|
|
66
73
|
})
|
|
67
74
|
), showError && /* @__PURE__ */ React.createElement(FormError, { field: name, className: "mt-1", message: errorMessage }));
|
|
68
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../components/form/hook-native-select.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { FieldValues,
|
|
1
|
+
{"version":3,"sources":["../../../components/form/hook-native-select.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { FieldValues, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormNativeSelect } from './native-select';\nimport type { FormNativeSelectProps } from './native-select';\nimport { isValidationRuleEnabled, mergeHookFormRules } from './types';\nimport type { HookFormRules, HookFormValidationAttributes } from './types';\n\ntype HookFormNativeSelectValidationAttributes = Pick<HookFormValidationAttributes, 'required'>;\n\ntype HookFormNativeSelectProps<T extends FieldValues> = Omit<\n FormNativeSelectProps,\n 'name' | 'selectProps' | keyof HookFormNativeSelectValidationAttributes\n> & {\n name: Path<T>;\n rules?: HookFormRules<T>;\n error?: string;\n} & HookFormNativeSelectValidationAttributes;\n\nexport function HookFormNativeSelect<T extends FieldValues>({\n id,\n name,\n rules,\n label,\n error,\n classNames,\n disabled,\n required,\n ...rest\n}: HookFormNativeSelectProps<T>) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n register,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError && String(fieldError?.message));\n const showError = !!fieldError && !disabled;\n const mergedRules = mergeHookFormRules(rules, { required });\n\n return (\n <div className={cn('$hook-form-native-select', classNames?.wrapper)}>\n <FormNativeSelect\n {...rest}\n id={id}\n name={name}\n label={label}\n disabled={disabled}\n required={isValidationRuleEnabled(mergedRules?.required)}\n classNames={{\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n input: cn(classNames?.input, {\n 'ring-danger text-danger': showError,\n }),\n }}\n selectProps={register(name, mergedRules)}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAA4B,sBAAsB;AAmB3C,SAAS,qBAA4C,IAU3B;AAV2B,eAC1D;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EA9BF,IAsB4D,IASvD,iBATuD,IASvD;AAAA,IARH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM,UAAU,eAAkB;AAClC,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM;AAAA,IACJ;AAAA,IACA,WAAW,EAAE,OAAO;AAAA,EACtB,IAAI;AAEJ,QAAM,aAAa,KAAK,QAAQ,IAAI;AACpC,QAAM,eAAe,wBAAU,cAAc,OAAO,yCAAY,OAAO;AACvE,QAAM,YAAY,CAAC,CAAC,cAAc,CAAC;AACnC,QAAM,cAAc,mBAAmB,OAAO,EAAE,SAAS,CAAC;AAE1D,SACE,oCAAC,SAAI,WAAW,GAAG,4BAA4B,yCAAY,OAAO,KAChE;AAAA,IAAC;AAAA,qCACK,OADL;AAAA,MAEC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,wBAAwB,2CAAa,QAAQ;AAAA,MACvD,YAAY;AAAA,QACV,OAAO,GAAG,yCAAY,OAAO;AAAA,UAC3B,eAAe;AAAA,QACjB,CAAC;AAAA,QACD,OAAO,GAAG,yCAAY,OAAO;AAAA,UAC3B,2BAA2B;AAAA,QAC7B,CAAC;AAAA,MACH;AAAA,MACA,aAAa,SAAS,MAAM,WAAW;AAAA;AAAA,EACzC,GACC,aAAa,oCAAC,aAAU,OAAO,MAAM,WAAU,QAAO,SAAS,cAAc,CAChF;AAEJ;","names":[]}
|