@lerianstudio/sindarian-ui 2.0.0-beta.25 → 2.0.0-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/chart.js +4 -231
- package/dist/charts/index.js +1 -11
- package/dist/components/breadcrumb/get-breadcrumb-paths.js +1 -18
- package/dist/components/breadcrumb/index.js +1 -37
- package/dist/components/card/account-card/index.js +1 -69
- package/dist/components/card/basic-card/index.js +1 -20
- package/dist/components/card/dashboard-card/index.js +1 -20
- package/dist/components/card/entity-card/index.js +1 -68
- package/dist/components/card/index.js +1 -20
- package/dist/components/dialog/confirmation-dialog/index.js +1 -96
- package/dist/components/dialog/confirmation-dialog/use-confirm-dialog.js +1 -55
- package/dist/components/dialog/index.js +1 -19
- package/dist/components/dialog/large-dialog/index.js +1 -21
- package/dist/components/entity-box/index.js +1 -67
- package/dist/components/entity-data-table/index.js +1 -20
- package/dist/components/form/combo-box-field/index.js +1 -35
- package/dist/components/form/country-field/index.js +1 -11
- package/dist/components/form/date-picker-field/index.js +1 -83
- package/dist/components/form/date-range-field/index.js +1 -58
- package/dist/components/form/date-time-picker-field/index.js +1 -114
- package/dist/components/form/file-upload-field/index.js +1 -69
- package/dist/components/form/index.js +1 -31
- package/dist/components/form/input-field/index.js +1 -96
- package/dist/components/form/otp-field/index.js +1 -19
- package/dist/components/form/pagination-limit-field/index.js +1 -10
- package/dist/components/form/password-field/index.js +1 -16
- package/dist/components/form/radio-group-field/index.js +1 -36
- package/dist/components/form/renderable-label.js +1 -57
- package/dist/components/form/select-field/index.js +1 -68
- package/dist/components/form/state-field/index.js +1 -42
- package/dist/components/form/switch-field/index.js +1 -16
- package/dist/components/form/textarea-field/index.js +1 -23
- package/dist/components/page/index.js +1 -20
- package/dist/components/page-header/index.js +1 -80
- package/dist/components/pagination/index.js +1 -10
- package/dist/components/table/id-table-cell.js +1 -109
- package/dist/components/table/index.js +1 -19
- package/dist/components/table/locked-table-actions.js +1 -41
- package/dist/components/table/name-table-cell.js +1 -58
- package/dist/components/ui/accordion/index.js +1 -62
- package/dist/components/ui/alert/index.js +1 -45
- package/dist/components/ui/alert-dialog/index.js +1 -84
- package/dist/components/ui/autocomplete/index.js +1 -440
- package/dist/components/ui/autosize-textarea/index.js +1 -89
- package/dist/components/ui/avatar/index.js +1 -51
- package/dist/components/ui/badge/index.js +1 -83
- package/dist/components/ui/breadcrumb/index.js +1 -35
- package/dist/components/ui/button/index.js +1 -65
- package/dist/components/ui/calendar/index.js +1 -118
- package/dist/components/ui/card/index.js +1 -32
- package/dist/components/ui/checkbox/index.js +1 -44
- package/dist/components/ui/collapsible/index.js +1 -50
- package/dist/components/ui/command/index.js +1 -95
- package/dist/components/ui/copy-field/index.js +1 -163
- package/dist/components/ui/dialog/index.js +1 -80
- package/dist/components/ui/dialog/styles.css +1 -1
- package/dist/components/ui/dropdown-menu/index.js +1 -110
- package/dist/components/ui/field/index.js +1 -82
- package/dist/components/ui/file-upload/index.js +1 -574
- package/dist/components/ui/form.js +1 -162
- package/dist/components/ui/hover-card/index.js +1 -51
- package/dist/components/ui/icon-button/index.js +1 -35
- package/dist/components/ui/input/adornment.js +1 -21
- package/dist/components/ui/input/index.js +1 -99
- package/dist/components/ui/label/index.js +1 -45
- package/dist/components/ui/lerian-wordmark/index.js +1 -7
- package/dist/components/ui/loading-button/index.js +1 -9
- package/dist/components/ui/multiple-select/index.js +1 -235
- package/dist/components/ui/otp-input/index.js +1 -62
- package/dist/components/ui/paper/index.js +1 -8
- package/dist/components/ui/paper-collapsible/index.js +1 -24
- package/dist/components/ui/popover/index.js +1 -55
- package/dist/components/ui/progress/index.js +1 -66
- package/dist/components/ui/qr-code/index.js +1 -27
- package/dist/components/ui/radio-group/index.js +1 -48
- package/dist/components/ui/scroll-area/index.js +1 -49
- package/dist/components/ui/select/index.js +1 -119
- package/dist/components/ui/separator/index.js +1 -43
- package/dist/components/ui/sheet/index.js +1 -136
- package/dist/components/ui/sidebar/index.js +1 -27
- package/dist/components/ui/sidebar/next-router.cjs +1 -119
- package/dist/components/ui/sidebar/sidebar-back-button.js +1 -8
- package/dist/components/ui/sidebar/sidebar-components.js +1 -23
- package/dist/components/ui/sidebar/sidebar-expand-button.js +1 -49
- package/dist/components/ui/sidebar/sidebar-item-button.js +1 -21
- package/dist/components/ui/sidebar/sidebar-item-collapsible.js +1 -52
- package/dist/components/ui/sidebar/sidebar-item-icon-button.js +1 -18
- package/dist/components/ui/sidebar/sidebar-item.js +1 -44
- package/dist/components/ui/sidebar/sidebar-provider.js +1 -201
- package/dist/components/ui/sidebar/sidebar-root.js +1 -130
- package/dist/components/ui/sidebar/sidebar-router.js +1 -126
- package/dist/components/ui/sidebar/sidebar-trigger.js +1 -57
- package/dist/components/ui/skeleton/index.js +1 -8
- package/dist/components/ui/stepper/index.js +1 -29
- package/dist/components/ui/switch/index.js +1 -43
- package/dist/components/ui/table/index.js +1 -56
- package/dist/components/ui/tabs/index.js +1 -55
- package/dist/components/ui/tabs/styles.css +1 -1
- package/dist/components/ui/textarea/index.js +1 -8
- package/dist/components/ui/time-picker/index.js +1 -85
- package/dist/components/ui/toast/index.js +1 -3
- package/dist/components/ui/toast/toaster.js +1 -16
- package/dist/components/ui/toggle-group/index.js +1 -156
- package/dist/components/ui/tooltip/index.js +1 -81
- package/dist/domain/blotter/index.js +1 -20
- package/dist/domain/delinquency-aging/aging-buckets.js +1 -120
- package/dist/domain/delinquency-aging/index.js +1 -222
- package/dist/domain/figure/index.js +1 -19
- package/dist/domain/format.js +1 -137
- package/dist/domain/index.js +1 -43
- package/dist/domain/key-id/index.js +1 -174
- package/dist/domain/ledger-sheet/index.js +1 -28
- package/dist/domain/money-diff.js +1 -48
- package/dist/domain/money-math.js +1 -104
- package/dist/domain/money-text/index.js +1 -123
- package/dist/domain/section-label/index.js +1 -17
- package/dist/domain/status-rail/index.js +1 -76
- package/dist/domain/threshold-gauge/index.js +1 -161
- package/dist/enterprise/alert-banner/index.js +1 -24
- package/dist/enterprise/app-shell/index.js +1 -87
- package/dist/enterprise/cursor-pager/index.js +1 -26
- package/dist/enterprise/data-table/column-size.js +1 -103
- package/dist/enterprise/data-table/index.js +1 -345
- package/dist/enterprise/date-range-picker/index.js +1 -115
- package/dist/enterprise/detail-panel/index.js +1 -20
- package/dist/enterprise/empty-state/index.js +1 -14
- package/dist/enterprise/index.js +1 -39
- package/dist/enterprise/number-input/index.js +1 -252
- package/dist/enterprise/search-input/index.js +1 -121
- package/dist/enterprise/stat-card/index.js +1 -75
- package/dist/enterprise/status-badge/index.js +1 -120
- package/dist/enterprise/use-is-mobile.js +1 -68
- package/dist/enterprise/virtualized-table/index.js +1 -141
- package/dist/esm/charts/chart.js +4 -190
- package/dist/esm/charts/index.js +1 -3
- package/dist/esm/components/breadcrumb/get-breadcrumb-paths.js +1 -12
- package/dist/esm/components/breadcrumb/index.js +1 -30
- package/dist/esm/components/card/account-card/index.js +1 -53
- package/dist/esm/components/card/basic-card/index.js +1 -14
- package/dist/esm/components/card/dashboard-card/index.js +1 -14
- package/dist/esm/components/card/entity-card/index.js +1 -52
- package/dist/esm/components/card/index.js +1 -4
- package/dist/esm/components/dialog/confirmation-dialog/index.js +1 -60
- package/dist/esm/components/dialog/confirmation-dialog/use-confirm-dialog.js +1 -49
- package/dist/esm/components/dialog/index.js +1 -3
- package/dist/esm/components/dialog/large-dialog/index.js +1 -16
- package/dist/esm/components/entity-box/index.js +1 -56
- package/dist/esm/components/entity-data-table/index.js +1 -17
- package/dist/esm/components/form/combo-box-field/index.js +1 -28
- package/dist/esm/components/form/country-field/index.js +1 -7
- package/dist/esm/components/form/date-picker-field/index.js +1 -43
- package/dist/esm/components/form/date-range-field/index.js +1 -18
- package/dist/esm/components/form/date-time-picker-field/index.js +1 -74
- package/dist/esm/components/form/file-upload-field/index.js +1 -65
- package/dist/esm/components/form/index.js +1 -15
- package/dist/esm/components/form/input-field/index.js +1 -92
- package/dist/esm/components/form/otp-field/index.js +1 -15
- package/dist/esm/components/form/pagination-limit-field/index.js +1 -6
- package/dist/esm/components/form/password-field/index.js +1 -10
- package/dist/esm/components/form/radio-group-field/index.js +1 -32
- package/dist/esm/components/form/renderable-label.js +1 -54
- package/dist/esm/components/form/select-field/index.js +1 -64
- package/dist/esm/components/form/state-field/index.js +1 -35
- package/dist/esm/components/form/switch-field/index.js +1 -12
- package/dist/esm/components/form/textarea-field/index.js +1 -19
- package/dist/esm/components/page/index.js +1 -15
- package/dist/esm/components/page-header/index.js +1 -71
- package/dist/esm/components/pagination/index.js +1 -6
- package/dist/esm/components/table/id-table-cell.js +1 -105
- package/dist/esm/components/table/index.js +1 -3
- package/dist/esm/components/table/locked-table-actions.js +1 -37
- package/dist/esm/components/table/name-table-cell.js +1 -54
- package/dist/esm/components/ui/accordion/index.js +1 -24
- package/dist/esm/components/ui/alert/index.js +1 -38
- package/dist/esm/components/ui/alert-dialog/index.js +1 -39
- package/dist/esm/components/ui/autocomplete/index.js +1 -392
- package/dist/esm/components/ui/autosize-textarea/index.js +1 -51
- package/dist/esm/components/ui/avatar/index.js +1 -14
- package/dist/esm/components/ui/badge/index.js +1 -79
- package/dist/esm/components/ui/breadcrumb/index.js +1 -27
- package/dist/esm/components/ui/button/index.js +1 -60
- package/dist/esm/components/ui/calendar/index.js +1 -82
- package/dist/esm/components/ui/card/index.js +1 -24
- package/dist/esm/components/ui/checkbox/index.js +1 -9
- package/dist/esm/components/ui/collapsible/index.js +1 -13
- package/dist/esm/components/ui/command/index.js +1 -51
- package/dist/esm/components/ui/copy-field/index.js +1 -127
- package/dist/esm/components/ui/dialog/index.js +1 -36
- package/dist/esm/components/ui/dropdown-menu/index.js +1 -60
- package/dist/esm/components/ui/field/index.js +1 -71
- package/dist/esm/components/ui/file-upload/index.js +1 -536
- package/dist/esm/components/ui/form.js +1 -118
- package/dist/esm/components/ui/hover-card/index.js +1 -14
- package/dist/esm/components/ui/icon-button/index.js +1 -31
- package/dist/esm/components/ui/input/adornment.js +1 -17
- package/dist/esm/components/ui/input/index.js +1 -60
- package/dist/esm/components/ui/label/index.js +1 -10
- package/dist/esm/components/ui/lerian-wordmark/index.js +1 -4
- package/dist/esm/components/ui/loading-button/index.js +1 -7
- package/dist/esm/components/ui/multiple-select/index.js +1 -196
- package/dist/esm/components/ui/otp-input/index.js +1 -21
- package/dist/esm/components/ui/paper/index.js +1 -5
- package/dist/esm/components/ui/paper-collapsible/index.js +1 -19
- package/dist/esm/components/ui/popover/index.js +1 -17
- package/dist/esm/components/ui/progress/index.js +1 -31
- package/dist/esm/components/ui/qr-code/index.js +1 -24
- package/dist/esm/components/ui/radio-group/index.js +1 -12
- package/dist/esm/components/ui/scroll-area/index.js +1 -13
- package/dist/esm/components/ui/select/index.js +1 -74
- package/dist/esm/components/ui/separator/index.js +1 -8
- package/dist/esm/components/ui/sheet/index.js +1 -92
- package/dist/esm/components/ui/sidebar/index.js +1 -11
- package/dist/esm/components/ui/sidebar/next-router.cjs +1 -119
- package/dist/esm/components/ui/sidebar/sidebar-back-button.js +1 -5
- package/dist/esm/components/ui/sidebar/sidebar-components.js +1 -15
- package/dist/esm/components/ui/sidebar/sidebar-expand-button.js +1 -42
- package/dist/esm/components/ui/sidebar/sidebar-item-button.js +1 -18
- package/dist/esm/components/ui/sidebar/sidebar-item-collapsible.js +1 -44
- package/dist/esm/components/ui/sidebar/sidebar-item-icon-button.js +1 -14
- package/dist/esm/components/ui/sidebar/sidebar-item.js +1 -40
- package/dist/esm/components/ui/sidebar/sidebar-provider.js +1 -193
- package/dist/esm/components/ui/sidebar/sidebar-root.js +1 -126
- package/dist/esm/components/ui/sidebar/sidebar-router.js +1 -89
- package/dist/esm/components/ui/sidebar/sidebar-trigger.js +1 -53
- package/dist/esm/components/ui/skeleton/index.js +1 -6
- package/dist/esm/components/ui/stepper/index.js +1 -20
- package/dist/esm/components/ui/switch/index.js +1 -8
- package/dist/esm/components/ui/table/index.js +1 -44
- package/dist/esm/components/ui/tabs/index.js +1 -17
- package/dist/esm/components/ui/textarea/index.js +1 -6
- package/dist/esm/components/ui/time-picker/index.js +1 -49
- package/dist/esm/components/ui/toast/index.js +1 -2
- package/dist/esm/components/ui/toast/toaster.js +1 -13
- package/dist/esm/components/ui/toggle-group/index.js +1 -120
- package/dist/esm/components/ui/tooltip/index.js +1 -43
- package/dist/esm/domain/blotter/index.js +1 -16
- package/dist/esm/domain/delinquency-aging/aging-buckets.js +1 -115
- package/dist/esm/domain/delinquency-aging/index.js +1 -218
- package/dist/esm/domain/figure/index.js +1 -15
- package/dist/esm/domain/format.js +1 -128
- package/dist/esm/domain/index.js +1 -19
- package/dist/esm/domain/key-id/index.js +1 -169
- package/dist/esm/domain/ledger-sheet/index.js +1 -24
- package/dist/esm/domain/money-diff.js +1 -45
- package/dist/esm/domain/money-math.js +1 -98
- package/dist/esm/domain/money-text/index.js +1 -118
- package/dist/esm/domain/section-label/index.js +1 -14
- package/dist/esm/domain/status-rail/index.js +1 -71
- package/dist/esm/domain/threshold-gauge/index.js +1 -157
- package/dist/esm/enterprise/alert-banner/index.js +1 -21
- package/dist/esm/enterprise/app-shell/index.js +1 -51
- package/dist/esm/enterprise/cursor-pager/index.js +1 -23
- package/dist/esm/enterprise/data-table/column-size.js +1 -97
- package/dist/esm/enterprise/data-table/index.js +1 -342
- package/dist/esm/enterprise/date-range-picker/index.js +1 -112
- package/dist/esm/enterprise/detail-panel/index.js +1 -17
- package/dist/esm/enterprise/empty-state/index.js +1 -11
- package/dist/esm/enterprise/index.js +1 -22
- package/dist/esm/enterprise/number-input/index.js +1 -214
- package/dist/esm/enterprise/search-input/index.js +1 -85
- package/dist/esm/enterprise/stat-card/index.js +1 -72
- package/dist/esm/enterprise/status-badge/index.js +1 -116
- package/dist/esm/enterprise/use-is-mobile.js +1 -31
- package/dist/esm/enterprise/virtualized-table/index.js +1 -138
- package/dist/esm/hooks/use-click-away.js +1 -22
- package/dist/esm/hooks/use-pagination.js +1 -38
- package/dist/esm/hooks/use-stepper.js +1 -22
- package/dist/esm/hooks/use-time.js +1 -13
- package/dist/esm/hooks/use-toast.js +1 -107
- package/dist/esm/index.js +1 -77
- package/dist/esm/lib/storage/get-storage-object.js +1 -17
- package/dist/esm/lib/storage/get-storage.js +1 -14
- package/dist/esm/lib/storage/index.js +1 -2
- package/dist/esm/lib/typography.js +1 -31
- package/dist/esm/lib/utils.js +1 -41
- package/dist/esm/theme/get-theme-script.js +1 -41
- package/dist/esm/theme/index.js +1 -4
- package/dist/esm/theme/mode-toggle.js +1 -45
- package/dist/esm/theme/theme-provider.js +1 -122
- package/dist/esm/toast/helpers.js +1 -36
- package/dist/esm/toast/index.js +1 -4
- package/dist/esm/types/metadata-type.js +1 -1
- package/dist/esm/utils/countries.cjs +1 -17
- package/dist/esm/utils/country-utils.js +1 -18
- package/dist/esm/utils/currency-codes.js +1 -181
- package/dist/hooks/use-click-away.js +1 -29
- package/dist/hooks/use-pagination.js +1 -41
- package/dist/hooks/use-stepper.js +1 -26
- package/dist/hooks/use-time.js +1 -20
- package/dist/hooks/use-toast.js +1 -111
- package/dist/index.js +1 -96
- package/dist/lib/storage/get-storage-object.js +1 -23
- package/dist/lib/storage/get-storage.js +1 -17
- package/dist/lib/storage/index.js +1 -18
- package/dist/lib/typography.js +1 -34
- package/dist/lib/utils.js +1 -45
- package/dist/theme/get-theme-script.js +1 -44
- package/dist/theme/index.js +1 -11
- package/dist/theme/mode-toggle.js +1 -48
- package/dist/theme/theme-provider.js +1 -160
- package/dist/toast/helpers.js +1 -41
- package/dist/toast/index.js +1 -10
- package/dist/types/metadata-type.js +1 -2
- package/dist/utils/countries.cjs +1 -17
- package/dist/utils/country-utils.js +1 -25
- package/dist/utils/currency-codes.js +1 -184
- package/package.json +4 -3
|
@@ -1,114 +1 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.DateTimePickerField = void 0;
|
|
41
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
|
-
const button_1 = require("../../../components/ui/button");
|
|
43
|
-
const calendar_1 = require("../../../components/ui/calendar");
|
|
44
|
-
const form_1 = require("../../../components/ui/form");
|
|
45
|
-
const popover_1 = require("../../../components/ui/popover");
|
|
46
|
-
const time_picker_1 = require("../../../components/ui/time-picker");
|
|
47
|
-
const utils_1 = require("../../../lib/utils");
|
|
48
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
|
49
|
-
const lucide_react_1 = require("lucide-react");
|
|
50
|
-
const React = __importStar(require("react"));
|
|
51
|
-
const locale_1 = require("react-day-picker/locale");
|
|
52
|
-
const DateTimePickerField = ({ name, label, tooltip, labelExtra, description, placeholder = 'Select date and time...', disabled, readOnly, control, required, dateFormat = 'MMM DD, YYYY HH:mm', align = 'start', locale = locale_1.enUS, minDate, maxDate, defaultTime = '00:00', ...others }) => {
|
|
53
|
-
const [open, setOpen] = React.useState(false);
|
|
54
|
-
const parseDefaultTime = (time) => {
|
|
55
|
-
const [h, m] = time.split(':').map(Number);
|
|
56
|
-
return {
|
|
57
|
-
hour: Number.isFinite(h) && h >= 0 && h <= 23 ? h : 0,
|
|
58
|
-
minute: Number.isFinite(m) && m >= 0 && m <= 59 ? m : 0
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
return ((0, jsx_runtime_1.jsx)(form_1.FormField, { name: name, control: control, render: ({ field }) => {
|
|
62
|
-
const current = field.value ? (0, dayjs_1.default)(field.value) : null;
|
|
63
|
-
const isValid = current?.isValid() ?? false;
|
|
64
|
-
const validCurrent = isValid ? current : null;
|
|
65
|
-
const handleDateSelect = (date) => {
|
|
66
|
-
if (!date)
|
|
67
|
-
return;
|
|
68
|
-
const time = validCurrent
|
|
69
|
-
? { hour: validCurrent.hour(), minute: validCurrent.minute() }
|
|
70
|
-
: parseDefaultTime(defaultTime);
|
|
71
|
-
const combined = (0, dayjs_1.default)(date)
|
|
72
|
-
.hour(time.hour)
|
|
73
|
-
.minute(time.minute)
|
|
74
|
-
.second(0)
|
|
75
|
-
.millisecond(0);
|
|
76
|
-
field.onChange(combined.toISOString());
|
|
77
|
-
};
|
|
78
|
-
const handleTimeChange = (time) => {
|
|
79
|
-
if (!validCurrent)
|
|
80
|
-
return;
|
|
81
|
-
const updated = validCurrent
|
|
82
|
-
.hour(time.hour)
|
|
83
|
-
.minute(time.minute)
|
|
84
|
-
.second(0)
|
|
85
|
-
.millisecond(0);
|
|
86
|
-
field.onChange(updated.toISOString());
|
|
87
|
-
};
|
|
88
|
-
const handleClear = (e) => {
|
|
89
|
-
e.stopPropagation();
|
|
90
|
-
field.onChange('');
|
|
91
|
-
setOpen(false);
|
|
92
|
-
};
|
|
93
|
-
const showClear = !!field.value && !readOnly && !disabled;
|
|
94
|
-
return ((0, jsx_runtime_1.jsxs)(form_1.FormItem, { required: required, children: [label && ((0, jsx_runtime_1.jsx)(form_1.FormLabel, { extra: tooltip ? (0, jsx_runtime_1.jsx)(form_1.FormTooltip, { children: tooltip }) : labelExtra, children: label })), (0, jsx_runtime_1.jsxs)(popover_1.Popover, { open: open, onOpenChange: setOpen, children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative w-full", children: [(0, jsx_runtime_1.jsx)(popover_1.PopoverTrigger, { asChild: true, children: (0, jsx_runtime_1.jsx)(form_1.FormControl, { children: (0, jsx_runtime_1.jsx)(button_1.Button, { variant: "outline", disabled: disabled, className: (0, utils_1.cn)('bg-input hover:bg-input border-input-border text-foreground h-10 w-full justify-start rounded-md px-2.5 font-normal', readOnly && 'pointer-events-none', showClear && 'pr-8', open && 'ring-ring ring-2 ring-offset-0'), "data-testid": others['data-testid'], icon: (0, jsx_runtime_1.jsx)(lucide_react_1.CalendarIcon, { className: "size-4" }), children: (0, jsx_runtime_1.jsx)("span", { className: (0, utils_1.cn)('text-foreground flex-1 text-left', validCurrent && 'font-bold'), children: validCurrent
|
|
95
|
-
? validCurrent.format(dateFormat)
|
|
96
|
-
: placeholder }) }) }) }), showClear && ((0, jsx_runtime_1.jsx)("span", { role: "button", tabIndex: 0, "aria-label": "Clear date and time", className: "text-muted-foreground hover:text-foreground focus-visible:ring-ring absolute top-1/2 right-2 z-10 inline-flex shrink-0 -translate-y-1/2 rounded-sm outline-none focus-visible:ring-2", onClick: handleClear, onKeyDown: (e) => {
|
|
97
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
98
|
-
e.preventDefault();
|
|
99
|
-
handleClear(e);
|
|
100
|
-
}
|
|
101
|
-
}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.XIcon, { className: "size-4" }) }))] }), (0, jsx_runtime_1.jsx)(popover_1.PopoverContent, { className: "w-auto p-0", align: align, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col sm:flex-row sm:items-stretch", children: [(0, jsx_runtime_1.jsx)(calendar_1.Calendar, { mode: "single", defaultMonth: validCurrent ? validCurrent.toDate() : undefined, selected: validCurrent ? validCurrent.toDate() : undefined, onSelect: handleDateSelect, locale: locale, disabled: (date) => {
|
|
102
|
-
if (disabled || readOnly)
|
|
103
|
-
return true;
|
|
104
|
-
if (minDate &&
|
|
105
|
-
date < (0, dayjs_1.default)(minDate).startOf('day').toDate())
|
|
106
|
-
return true;
|
|
107
|
-
if (maxDate &&
|
|
108
|
-
date > (0, dayjs_1.default)(maxDate).endOf('day').toDate())
|
|
109
|
-
return true;
|
|
110
|
-
return false;
|
|
111
|
-
} }), (0, jsx_runtime_1.jsx)("div", { className: "bg-border hidden w-px self-stretch sm:block" }), (0, jsx_runtime_1.jsx)("div", { className: "border-border border-t sm:hidden" }), (0, jsx_runtime_1.jsx)(time_picker_1.TimePicker, { hour: validCurrent ? validCurrent.hour() : undefined, minute: validCurrent ? validCurrent.minute() : undefined, onChange: handleTimeChange, disabled: disabled || readOnly || !validCurrent })] }) })] }), (0, jsx_runtime_1.jsx)(form_1.FormMessage, {}), description && (0, jsx_runtime_1.jsx)(form_1.FormDescription, { children: description })] }));
|
|
112
|
-
} }));
|
|
113
|
-
};
|
|
114
|
-
exports.DateTimePickerField = DateTimePickerField;
|
|
1
|
+
"use client";"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(t,e,o,r){if(r===void 0)r=o;var n=Object.getOwnPropertyDescriptor(e,o);if(!n||("get"in n?!e.__esModule:n.writable||n.configurable)){n={enumerable:true,get:function(){return e[o]}}}Object.defineProperty(t,r,n)}):(function(t,e,o,r){if(r===void 0)r=o;t[r]=e[o]}));var __setModuleDefault=this&&this.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:true,value:e})}):function(t,e){t["default"]=e});var __importStar=this&&this.__importStar||(function(){var t=function(e){t=Object.getOwnPropertyNames||function(o){var r=[];for(var n in o)if(Object.prototype.hasOwnProperty.call(o,n))r[r.length]=n;return r};return t(e)};return function(e){if(e&&e.__esModule)return e;var o={};if(e!=null){for(var r=t(e),n=0;n<r.length;n++)if(r[n]!=="default")__createBinding(o,e,r[n])}__setModuleDefault(o,e);return o}})();var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{"default":t}};Object.defineProperty(exports,"__esModule",{value:true});exports.DateTimePickerField=void 0;const jsx_runtime_1=require("react/jsx-runtime");const button_1=require("../../../components/ui/button");const calendar_1=require("../../../components/ui/calendar");const form_1=require("../../../components/ui/form");const popover_1=require("../../../components/ui/popover");const time_picker_1=require("../../../components/ui/time-picker");const utils_1=require("../../../lib/utils");const dayjs_1=__importDefault(require("dayjs"));const lucide_react_1=require("lucide-react");const React=__importStar(require("react"));const locale_1=require("react-day-picker/locale");const DateTimePickerField=({name:t,label:e,tooltip:o,labelExtra:r,description:n,placeholder:b="Select date and time...",disabled:c,readOnly:d,control:j,required:v,dateFormat:D="MMM DD, YYYY HH:mm",align:C="start",locale:y=locale_1.enUS,minDate:m,maxDate:h,defaultTime:N="00:00",...O})=>{const[p,x]=React.useState(false);const P=u=>{const[a,l]=u.split(":").map(Number);return{hour:Number.isFinite(a)&&a>=0&&a<=23?a:0,minute:Number.isFinite(l)&&l>=0&&l<=59?l:0}};return(0,jsx_runtime_1.jsx)(form_1.FormField,{name:t,control:j,render:({field:u})=>{const a=u.value?(0,dayjs_1.default)(u.value):null;const l=a?.isValid()??false;const i=l?a:null;const F=s=>{if(!s)return;const f=i?{hour:i.hour(),minute:i.minute()}:P(N);const w=(0,dayjs_1.default)(s).hour(f.hour).minute(f.minute).second(0).millisecond(0);u.onChange(w.toISOString())};const q=s=>{if(!i)return;const f=i.hour(s.hour).minute(s.minute).second(0).millisecond(0);u.onChange(f.toISOString())};const g=s=>{s.stopPropagation();u.onChange("");x(false)};const _=!!u.value&&!d&&!c;return(0,jsx_runtime_1.jsxs)(form_1.FormItem,{required:v,children:[e&&(0,jsx_runtime_1.jsx)(form_1.FormLabel,{extra:o?(0,jsx_runtime_1.jsx)(form_1.FormTooltip,{children:o}):r,children:e}),(0,jsx_runtime_1.jsxs)(popover_1.Popover,{open:p,onOpenChange:x,children:[(0,jsx_runtime_1.jsxs)("div",{className:"relative w-full",children:[(0,jsx_runtime_1.jsx)(popover_1.PopoverTrigger,{asChild:true,children:(0,jsx_runtime_1.jsx)(form_1.FormControl,{children:(0,jsx_runtime_1.jsx)(button_1.Button,{variant:"outline",disabled:c,className:(0,utils_1.cn)("bg-input hover:bg-input border-input-border text-foreground h-10 w-full justify-start rounded-md px-2.5 font-normal",d&&"pointer-events-none",_&&"pr-8",p&&"ring-ring ring-2 ring-offset-0"),"data-testid":O["data-testid"],icon:(0,jsx_runtime_1.jsx)(lucide_react_1.CalendarIcon,{className:"size-4"}),children:(0,jsx_runtime_1.jsx)("span",{className:(0,utils_1.cn)("text-foreground flex-1 text-left",i&&"font-bold"),children:i?i.format(D):b})})})}),_&&(0,jsx_runtime_1.jsx)("span",{role:"button",tabIndex:0,"aria-label":"Clear date and time",className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring absolute top-1/2 right-2 z-10 inline-flex shrink-0 -translate-y-1/2 rounded-sm outline-none focus-visible:ring-2",onClick:g,onKeyDown:s=>{if(s.key==="Enter"||s.key===" "){s.preventDefault();g(s)}},children:(0,jsx_runtime_1.jsx)(lucide_react_1.XIcon,{className:"size-4"})})]}),(0,jsx_runtime_1.jsx)(popover_1.PopoverContent,{className:"w-auto p-0",align:C,children:(0,jsx_runtime_1.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-stretch",children:[(0,jsx_runtime_1.jsx)(calendar_1.Calendar,{mode:"single",defaultMonth:i?i.toDate():void 0,selected:i?i.toDate():void 0,onSelect:F,locale:y,disabled:s=>{if(c||d)return true;if(m&&s<(0,dayjs_1.default)(m).startOf("day").toDate())return true;if(h&&s>(0,dayjs_1.default)(h).endOf("day").toDate())return true;return false}}),(0,jsx_runtime_1.jsx)("div",{className:"bg-border hidden w-px self-stretch sm:block"}),(0,jsx_runtime_1.jsx)("div",{className:"border-border border-t sm:hidden"}),(0,jsx_runtime_1.jsx)(time_picker_1.TimePicker,{hour:i?i.hour():void 0,minute:i?i.minute():void 0,onChange:q,disabled:c||d||!i})]})})]}),(0,jsx_runtime_1.jsx)(form_1.FormMessage,{}),n&&(0,jsx_runtime_1.jsx)(form_1.FormDescription,{children:n})]})}})};exports.DateTimePickerField=DateTimePickerField;
|
|
@@ -1,69 +1 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.FileUploadField = void 0;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const form_1 = require("../../../components/ui/form");
|
|
8
|
-
const file_upload_1 = require("../../../components/ui/file-upload");
|
|
9
|
-
const renderable_label_1 = require("../../../components/form/renderable-label");
|
|
10
|
-
/**
|
|
11
|
-
* FileUploadField — the react-hook-form field for FileUpload.
|
|
12
|
-
*
|
|
13
|
-
* The field VALUE is the file's UTF-8 TEXT string (so a Zod `z.string()` PEM
|
|
14
|
-
* schema validates directly), `''` when cleared — never the File, never null —
|
|
15
|
-
* so `z.string().min(1)` fires the required error with zero adapter code. The
|
|
16
|
-
* File metadata for the visible chip lives in field-LOCAL state, since the form
|
|
17
|
-
* only holds the text. The shown chip is DERIVED from the form field value, so
|
|
18
|
-
* an external `form.reset()` / `setValue(name, '')` that clears the text also
|
|
19
|
-
* clears the chip — local state can never linger out of sync with the form. A
|
|
20
|
-
* rejected pick (size/type/read) clears the form value so it can't pass
|
|
21
|
-
* validation, while the primitive's own inline `role="alert"` announces the
|
|
22
|
-
* rejection; on resolver failure the FormMessage announces. Both surfaces are
|
|
23
|
-
* wired.
|
|
24
|
-
*/
|
|
25
|
-
const FileUploadField = ({ control, name, label, description, tooltip, required, accept, maxSizeBytes, disabled, className, labels, onError, onSelect, 'aria-label': ariaLabelProp }) => {
|
|
26
|
-
const [localValue, setLocalValue] = (0, react_1.useState)(null);
|
|
27
|
-
const showLabel = (0, renderable_label_1.hasRenderableLabel)(label);
|
|
28
|
-
// An empty or whitespace-only aria-label is worse than none: it names the
|
|
29
|
-
// control "". Drop it so the attribute never reaches the DOM.
|
|
30
|
-
const ariaLabel = ariaLabelProp?.trim() ? ariaLabelProp : undefined;
|
|
31
|
-
// The type cannot rule out `label=""`, so this is the only signal a developer
|
|
32
|
-
// gets that the control shipped nameless.
|
|
33
|
-
if (process.env.NODE_ENV !== 'production' && !showLabel && !ariaLabel) {
|
|
34
|
-
console.error(`FileUploadField "${name}" has no accessible name: pass a non-empty label or aria-label.`);
|
|
35
|
-
}
|
|
36
|
-
return ((0, jsx_runtime_1.jsx)(form_1.FormField, { control: control, name: name, render: ({ field }) => {
|
|
37
|
-
// The chip follows the LOCAL selection, reconciled against the form
|
|
38
|
-
// value — not the form value's truthiness.
|
|
39
|
-
//
|
|
40
|
-
// Truthiness cannot tell "no file" from "an accepted EMPTY file": both
|
|
41
|
-
// store ''. So picking a legitimately empty file hid the chip, the zone
|
|
42
|
-
// went back to "Choose a file or drag and drop" even though the pick was
|
|
43
|
-
// accepted, and a `z.string().min(1)` rule then failed the field with
|
|
44
|
-
// nothing on screen to explain why.
|
|
45
|
-
//
|
|
46
|
-
// Comparing against the text we last wrote keeps the external-reset
|
|
47
|
-
// behaviour that truthiness was there for: after form.reset() or
|
|
48
|
-
// setValue(name, ''), the stored text no longer matches the selection, so
|
|
49
|
-
// the stale File metadata still cannot linger.
|
|
50
|
-
//
|
|
51
|
-
// ponytail: one residual case is irreducible from the form value alone —
|
|
52
|
-
// resetting AFTER picking an empty file leaves the chip up, because ''
|
|
53
|
-
// (reset) and '' (that file's text) are the same string and the form
|
|
54
|
-
// value carries nothing else to tell them apart. Fix needs a reset epoch
|
|
55
|
-
// from react-hook-form, or a form value richer than the file text.
|
|
56
|
-
const shown = localValue && field.value === localValue.text ? localValue : null;
|
|
57
|
-
return ((0, jsx_runtime_1.jsxs)(form_1.FormItem, { required: required, children: [showLabel && ((0, jsx_runtime_1.jsx)(form_1.FormLabel, { extra: tooltip ? (0, jsx_runtime_1.jsx)(form_1.FormTooltip, { children: tooltip }) : undefined, children: label })), (0, jsx_runtime_1.jsx)(form_1.FormControl, { children: (0, jsx_runtime_1.jsx)(file_upload_1.FileUpload, { ref: field.ref, name: field.name, onBlur: field.onBlur, "aria-label": ariaLabel, labels: labels, accept: accept, maxSizeBytes: maxSizeBytes, disabled: disabled, className: className, value: shown, onSelect: (result) => {
|
|
58
|
-
setLocalValue(result);
|
|
59
|
-
field.onChange(result?.text ?? '');
|
|
60
|
-
onSelect?.(result);
|
|
61
|
-
}, onError: (error) => {
|
|
62
|
-
setLocalValue(null);
|
|
63
|
-
field.onChange('');
|
|
64
|
-
onSelect?.(null);
|
|
65
|
-
onError?.(error);
|
|
66
|
-
} }) }), (0, jsx_runtime_1.jsx)(form_1.FormMessage, {}), description && (0, jsx_runtime_1.jsx)(form_1.FormDescription, { children: description })] }));
|
|
67
|
-
} }));
|
|
68
|
-
};
|
|
69
|
-
exports.FileUploadField = FileUploadField;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.FileUploadField=void 0;const jsx_runtime_1=require("react/jsx-runtime");const react_1=require("react");const form_1=require("../../../components/ui/form");const file_upload_1=require("../../../components/ui/file-upload");const renderable_label_1=require("../../../components/form/renderable-label");const FileUploadField=({control:m,name:o,label:n,description:a,tooltip:s,required:p,accept:x,maxSizeBytes:F,disabled:b,className:h,labels:j,onError:_,onSelect:t,"aria-label":i})=>{const[l,c]=(0,react_1.useState)(null);const u=(0,renderable_label_1.hasRenderableLabel)(n);const d=i?.trim()?i:void 0;if(process.env.NODE_ENV!=="production"&&!u&&!d){console.error(`FileUploadField "${o}" has no accessible name: pass a non-empty label or aria-label.`)}return(0,jsx_runtime_1.jsx)(form_1.FormField,{control:m,name:o,render:({field:e})=>{const f=l&&e.value===l.text?l:null;return(0,jsx_runtime_1.jsxs)(form_1.FormItem,{required:p,children:[u&&(0,jsx_runtime_1.jsx)(form_1.FormLabel,{extra:s?(0,jsx_runtime_1.jsx)(form_1.FormTooltip,{children:s}):void 0,children:n}),(0,jsx_runtime_1.jsx)(form_1.FormControl,{children:(0,jsx_runtime_1.jsx)(file_upload_1.FileUpload,{ref:e.ref,name:e.name,onBlur:e.onBlur,"aria-label":d,labels:j,accept:x,maxSizeBytes:F,disabled:b,className:h,value:f,onSelect:r=>{c(r);e.onChange(r?.text??"");t?.(r)},onError:r=>{c(null);e.onChange("");t?.(null);_?.(r)}})}),(0,jsx_runtime_1.jsx)(form_1.FormMessage,{}),a&&(0,jsx_runtime_1.jsx)(form_1.FormDescription,{children:a})]})}})};exports.FileUploadField=FileUploadField;
|
|
@@ -1,31 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./input-field"), exports);
|
|
18
|
-
__exportStar(require("./select-field"), exports);
|
|
19
|
-
__exportStar(require("./switch-field"), exports);
|
|
20
|
-
__exportStar(require("./pagination-limit-field"), exports);
|
|
21
|
-
__exportStar(require("./combo-box-field"), exports);
|
|
22
|
-
__exportStar(require("./country-field"), exports);
|
|
23
|
-
__exportStar(require("./state-field"), exports);
|
|
24
|
-
__exportStar(require("./date-range-field"), exports);
|
|
25
|
-
__exportStar(require("./date-picker-field"), exports);
|
|
26
|
-
__exportStar(require("./date-time-picker-field"), exports);
|
|
27
|
-
__exportStar(require("./otp-field"), exports);
|
|
28
|
-
__exportStar(require("./password-field"), exports);
|
|
29
|
-
__exportStar(require("./file-upload-field"), exports);
|
|
30
|
-
__exportStar(require("./radio-group-field"), exports);
|
|
31
|
-
__exportStar(require("./textarea-field"), exports);
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(t,r,e,i){if(i===void 0)i=e;var o=Object.getOwnPropertyDescriptor(r,e);if(!o||("get"in o?!r.__esModule:o.writable||o.configurable)){o={enumerable:true,get:function(){return r[e]}}}Object.defineProperty(t,i,o)}):(function(t,r,e,i){if(i===void 0)i=e;t[i]=r[e]}));var __exportStar=this&&this.__exportStar||function(t,r){for(var e in t)if(e!=="default"&&!Object.prototype.hasOwnProperty.call(r,e))__createBinding(r,t,e)};Object.defineProperty(exports,"__esModule",{value:true});__exportStar(require("./input-field"),exports);__exportStar(require("./select-field"),exports);__exportStar(require("./switch-field"),exports);__exportStar(require("./pagination-limit-field"),exports);__exportStar(require("./combo-box-field"),exports);__exportStar(require("./country-field"),exports);__exportStar(require("./state-field"),exports);__exportStar(require("./date-range-field"),exports);__exportStar(require("./date-picker-field"),exports);__exportStar(require("./date-time-picker-field"),exports);__exportStar(require("./otp-field"),exports);__exportStar(require("./password-field"),exports);__exportStar(require("./file-upload-field"),exports);__exportStar(require("./radio-group-field"),exports);__exportStar(require("./textarea-field"),exports);
|
|
@@ -1,96 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InputField = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const autosize_textarea_1 = require("../../../components/ui/autosize-textarea");
|
|
6
|
-
const form_1 = require("../../../components/ui/form");
|
|
7
|
-
const input_1 = require("../../../components/ui/input");
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
/**
|
|
10
|
-
* Fan one node out to several refs. React hands a node to ONE ref, so a
|
|
11
|
-
* consumer ref and react-hook-form's `field.ref` cannot both be passed
|
|
12
|
-
* directly — one silently wins. Only used when the consumer actually supplied
|
|
13
|
-
* a ref, so a field without one keeps `field.ref`'s own identity and React
|
|
14
|
-
* never re-attaches it.
|
|
15
|
-
*/
|
|
16
|
-
function fanOutRef(...refs) {
|
|
17
|
-
return (node) => {
|
|
18
|
-
const cleanups = [];
|
|
19
|
-
for (const ref of refs) {
|
|
20
|
-
if (typeof ref === 'function') {
|
|
21
|
-
const cleanup = ref(node);
|
|
22
|
-
cleanups.push(typeof cleanup === 'function' ? cleanup : () => ref(null));
|
|
23
|
-
}
|
|
24
|
-
else if (ref) {
|
|
25
|
-
;
|
|
26
|
-
ref.current = node;
|
|
27
|
-
cleanups.push(() => {
|
|
28
|
-
;
|
|
29
|
-
ref.current = null;
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return () => cleanups.forEach((cleanup) => cleanup());
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
const InputField = ({ className, type, label, tooltip, labelExtra, placeholder, description, startAdornment, endAdornment, required, readOnly, minHeight, maxHeight, textArea, defaultValue, value, onChange, min, max, step, maxLength, autoComplete, inputMode, pattern, autoFocus, ref, 'aria-invalid': ariaInvalid, ...others }) => {
|
|
37
|
-
// OR with the form's error, expressed through the Slot merge rather than by
|
|
38
|
-
// reading the form: FormControl already injects `aria-invalid={!!error}`, and
|
|
39
|
-
// a child prop only wins that merge when the KEY is present. So emit the key
|
|
40
|
-
// only for an explicit `true`, and let FormControl answer for every other
|
|
41
|
-
// case. `true || error` is true; `false || error` is whatever the form says,
|
|
42
|
-
// which is the whole point — an explicit `false` cannot mute a live error.
|
|
43
|
-
// With no `control` there is no error to OR against, so FormControl injects
|
|
44
|
-
// `false` and today's behaviour is unchanged.
|
|
45
|
-
const ariaInvalidProp = ariaInvalid ? { 'aria-invalid': true } : undefined;
|
|
46
|
-
const formRef = (0, react_1.useRef)(undefined);
|
|
47
|
-
const composedRef = (0, react_1.useMemo)(() => ref ? fanOutRef((node) => formRef.current?.(node), ref) : ref,
|
|
48
|
-
// `others.name` belongs here, and leaving it out is not a lint nit.
|
|
49
|
-
// react-hook-form hands a fresh `field.ref` for every name, and that ref
|
|
50
|
-
// only receives the element when React reattaches, which it does only when
|
|
51
|
-
// this callback's identity changes. Memoised on `ref` alone, one identity
|
|
52
|
-
// survived a name change, the new field never got its element, and
|
|
53
|
-
// `form.setFocus(newName)` then found nothing to focus and said nothing.
|
|
54
|
-
[ref, others.name]);
|
|
55
|
-
const renderItem = (binding) => ((0, jsx_runtime_1.jsxs)(form_1.FormItem, { required: required, children: [label && ((0, jsx_runtime_1.jsx)(form_1.FormLabel, { extra: tooltip ? (0, jsx_runtime_1.jsx)(form_1.FormTooltip, { children: tooltip }) : labelExtra, children: label })), (0, jsx_runtime_1.jsx)(form_1.FormControl, { children: textArea ? ((0, jsx_runtime_1.jsx)(autosize_textarea_1.AutosizeTextarea, { className: className, placeholder: placeholder, readOnly: readOnly, minHeight: minHeight, maxHeight: maxHeight, maxLength: maxLength, autoComplete: autoComplete, inputMode: inputMode, autoFocus: autoFocus, "data-testid": others['data-testid'], ...ariaInvalidProp, ...binding })) : ((0, jsx_runtime_1.jsx)(input_1.Input, { className: className, type: type, placeholder: placeholder, readOnly: readOnly, startAdornment: startAdornment, endAdornment: endAdornment,
|
|
56
|
-
// Bounds belong to the single-line control only: `min`/`max`/`step`
|
|
57
|
-
// mean nothing on a textarea and would render as invalid markup.
|
|
58
|
-
min: min, max: max, step: step, maxLength: maxLength, autoComplete: autoComplete, inputMode: inputMode,
|
|
59
|
-
// Single-line only: `<textarea pattern>` is not a thing.
|
|
60
|
-
pattern: pattern, autoFocus: autoFocus, "data-testid": others['data-testid'], ...ariaInvalidProp, ...binding })) }), (0, jsx_runtime_1.jsx)(form_1.FormMessage, {}), description && (0, jsx_runtime_1.jsx)(form_1.FormDescription, { children: description })] }));
|
|
61
|
-
if (!others.control) {
|
|
62
|
-
return renderItem({
|
|
63
|
-
name: others.name,
|
|
64
|
-
disabled: others.disabled,
|
|
65
|
-
// Controlled when the caller holds the value, uncontrolled when it only
|
|
66
|
-
// seeds one — supplying both is what React warns about.
|
|
67
|
-
...(value !== undefined ? { value } : { defaultValue }),
|
|
68
|
-
onChange: (e) => onChange?.(e),
|
|
69
|
-
// Nothing else claims the node on this branch, so the consumer ref goes
|
|
70
|
-
// straight through. Without it there was no node to focus at all.
|
|
71
|
-
ref: ref
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return ((0, jsx_runtime_1.jsx)(form_1.FormField, { ...others, name: others.name,
|
|
75
|
-
// The seed goes through react-hook-form, never straight to the DOM: a
|
|
76
|
-
// value painted on the box only makes the field LOOK filled while the
|
|
77
|
-
// form still submits nothing for that name. Controller seeds its own
|
|
78
|
-
// state from this, so `field.value` carries the seed on both branches.
|
|
79
|
-
defaultValue: defaultValue, render: ({ field }) => {
|
|
80
|
-
formRef.current = field.ref;
|
|
81
|
-
return renderItem({
|
|
82
|
-
...field,
|
|
83
|
-
// Controlled from mount. react-hook-form hands `undefined` for any
|
|
84
|
-
// name the form declares no default for; React then mounts the box
|
|
85
|
-
// uncontrolled and flips it on the first keystroke, losing that
|
|
86
|
-
// character.
|
|
87
|
-
value: field.value ?? '',
|
|
88
|
-
onChange: (e) => {
|
|
89
|
-
field.onChange(e);
|
|
90
|
-
onChange?.(e);
|
|
91
|
-
},
|
|
92
|
-
ref: (ref ? composedRef : field.ref)
|
|
93
|
-
});
|
|
94
|
-
} }));
|
|
95
|
-
};
|
|
96
|
-
exports.InputField = InputField;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.InputField=void 0;const jsx_runtime_1=require("react/jsx-runtime");const autosize_textarea_1=require("../../../components/ui/autosize-textarea");const form_1=require("../../../components/ui/form");const input_1=require("../../../components/ui/input");const react_1=require("react");function fanOutRef(...o){return u=>{const r=[];for(const n of o){if(typeof n==="function"){const i=n(u);r.push(typeof i==="function"?i:()=>n(null))}else if(n){;n.current=u;r.push(()=>{;n.current=null})}}return()=>r.forEach(n=>n())}}const InputField=({className:o,type:u,label:r,tooltip:n,labelExtra:i,placeholder:s,description:c,startAdornment:v,endAdornment:g,required:y,readOnly:d,minHeight:C,maxHeight:M,textArea:R,defaultValue:m,value:p,onChange:l,min:z,max:A,step:O,maxLength:x,autoComplete:f,inputMode:j,pattern:b,autoFocus:F,ref:a,"aria-invalid":H,...t})=>{const _=H?{"aria-invalid":true}:void 0;const h=(0,react_1.useRef)(void 0);const L=(0,react_1.useMemo)(()=>a?fanOutRef(e=>h.current?.(e),a):a,[a,t.name]);const I=e=>(0,jsx_runtime_1.jsxs)(form_1.FormItem,{required:y,children:[r&&(0,jsx_runtime_1.jsx)(form_1.FormLabel,{extra:n?(0,jsx_runtime_1.jsx)(form_1.FormTooltip,{children:n}):i,children:r}),(0,jsx_runtime_1.jsx)(form_1.FormControl,{children:R?(0,jsx_runtime_1.jsx)(autosize_textarea_1.AutosizeTextarea,{className:o,placeholder:s,readOnly:d,minHeight:C,maxHeight:M,maxLength:x,autoComplete:f,inputMode:j,autoFocus:F,"data-testid":t["data-testid"],..._,...e}):(0,jsx_runtime_1.jsx)(input_1.Input,{className:o,type:u,placeholder:s,readOnly:d,startAdornment:v,endAdornment:g,min:z,max:A,step:O,maxLength:x,autoComplete:f,inputMode:j,pattern:b,autoFocus:F,"data-testid":t["data-testid"],..._,...e})}),(0,jsx_runtime_1.jsx)(form_1.FormMessage,{}),c&&(0,jsx_runtime_1.jsx)(form_1.FormDescription,{children:c})]});if(!t.control){return I({name:t.name,disabled:t.disabled,...p!==void 0?{value:p}:{defaultValue:m},onChange:e=>l?.(e),ref:a})}return(0,jsx_runtime_1.jsx)(form_1.FormField,{...t,name:t.name,defaultValue:m,render:({field:e})=>{h.current=e.ref;return I({...e,value:e.value??"",onChange:q=>{e.onChange(q);l?.(q)},ref:a?L:e.ref})}})};exports.InputField=InputField;
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OtpField = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const form_1 = require("../../../components/ui/form");
|
|
6
|
-
const otp_input_1 = require("../../../components/ui/otp-input");
|
|
7
|
-
const OtpField = ({ name, label, tooltip, labelExtra, description, maxLength = 6, pattern, separator = false, ...others }) => {
|
|
8
|
-
const midpoint = Math.floor(maxLength / 2);
|
|
9
|
-
const renderSlots = () => {
|
|
10
|
-
if (separator && maxLength > 1) {
|
|
11
|
-
const firstGroup = Array.from({ length: midpoint }, (_, i) => ((0, jsx_runtime_1.jsx)(otp_input_1.InputOTPSlot, { index: i }, i)));
|
|
12
|
-
const secondGroup = Array.from({ length: maxLength - midpoint }, (_, i) => (0, jsx_runtime_1.jsx)(otp_input_1.InputOTPSlot, { index: midpoint + i }, midpoint + i));
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(otp_input_1.InputOTPGroup, { children: firstGroup }), (0, jsx_runtime_1.jsx)(otp_input_1.InputOTPSeparator, {}), (0, jsx_runtime_1.jsx)(otp_input_1.InputOTPGroup, { children: secondGroup })] }));
|
|
14
|
-
}
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)(otp_input_1.InputOTPGroup, { children: Array.from({ length: maxLength }, (_, i) => ((0, jsx_runtime_1.jsx)(otp_input_1.InputOTPSlot, { index: i }, i))) }));
|
|
16
|
-
};
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)(form_1.FormField, { ...others, name: name, render: ({ field }) => ((0, jsx_runtime_1.jsxs)(form_1.FormItem, { required: others.required, children: [label && ((0, jsx_runtime_1.jsx)(form_1.FormLabel, { extra: tooltip ? (0, jsx_runtime_1.jsx)(form_1.FormTooltip, { children: tooltip }) : labelExtra, children: label })), (0, jsx_runtime_1.jsx)(form_1.FormControl, { children: (0, jsx_runtime_1.jsx)(otp_input_1.InputOTP, { maxLength: maxLength, pattern: pattern, value: field.value ?? '', onChange: field.onChange, onBlur: field.onBlur, ref: field.ref, name: field.name, disabled: others.disabled, "data-testid": others['data-testid'], children: renderSlots() }) }), (0, jsx_runtime_1.jsx)(form_1.FormMessage, {}), description && (0, jsx_runtime_1.jsx)(form_1.FormDescription, { children: description })] })) }));
|
|
18
|
-
};
|
|
19
|
-
exports.OtpField = OtpField;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.OtpField=void 0;const jsx_runtime_1=require("react/jsx-runtime");const form_1=require("../../../components/ui/form");const otp_input_1=require("../../../components/ui/otp-input");const OtpField=({name:p,label:u,tooltip:i,labelExtra:l,description:d,maxLength:e=6,pattern:c,separator:a=false,...t})=>{const o=Math.floor(e/2);const x=()=>{if(a&&e>1){const r=Array.from({length:o},(j,n)=>(0,jsx_runtime_1.jsx)(otp_input_1.InputOTPSlot,{index:n},n));const s=Array.from({length:e-o},(j,n)=>(0,jsx_runtime_1.jsx)(otp_input_1.InputOTPSlot,{index:o+n},o+n));return(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(otp_input_1.InputOTPGroup,{children:r}),(0,jsx_runtime_1.jsx)(otp_input_1.InputOTPSeparator,{}),(0,jsx_runtime_1.jsx)(otp_input_1.InputOTPGroup,{children:s})]})}return(0,jsx_runtime_1.jsx)(otp_input_1.InputOTPGroup,{children:Array.from({length:e},(r,s)=>(0,jsx_runtime_1.jsx)(otp_input_1.InputOTPSlot,{index:s},s))})};return(0,jsx_runtime_1.jsx)(form_1.FormField,{...t,name:p,render:({field:r})=>(0,jsx_runtime_1.jsxs)(form_1.FormItem,{required:t.required,children:[u&&(0,jsx_runtime_1.jsx)(form_1.FormLabel,{extra:i?(0,jsx_runtime_1.jsx)(form_1.FormTooltip,{children:i}):l,children:u}),(0,jsx_runtime_1.jsx)(form_1.FormControl,{children:(0,jsx_runtime_1.jsx)(otp_input_1.InputOTP,{maxLength:e,pattern:c,value:r.value??"",onChange:r.onChange,onBlur:r.onBlur,ref:r.ref,name:r.name,disabled:t.disabled,"data-testid":t["data-testid"],children:x()})}),(0,jsx_runtime_1.jsx)(form_1.FormMessage,{}),d&&(0,jsx_runtime_1.jsx)(form_1.FormDescription,{children:d})]})})};exports.OtpField=OtpField;
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PaginationLimitField = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const select_field_1 = require("../select-field");
|
|
6
|
-
const select_1 = require("../../../components/ui/select");
|
|
7
|
-
const PaginationLimitField = ({ options = [10, 50, 100], label = 'Items per page', control, ['data-testid']: dataTestId }) => {
|
|
8
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-muted-foreground text-sm font-medium whitespace-nowrap", children: label }), (0, jsx_runtime_1.jsx)(select_field_1.SelectField, { name: "limit", control: control, "data-testid": dataTestId, children: options.map((pageSize) => ((0, jsx_runtime_1.jsx)(select_1.SelectItem, { value: String(pageSize), children: pageSize }, pageSize))) })] }));
|
|
9
|
-
};
|
|
10
|
-
exports.PaginationLimitField = PaginationLimitField;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PaginationLimitField=void 0;const jsx_runtime_1=require("react/jsx-runtime");const select_field_1=require("../select-field");const select_1=require("../../../components/ui/select");const PaginationLimitField=({options:t=[10,50,100],label:i="Items per page",control:s,["data-testid"]:r})=>{return(0,jsx_runtime_1.jsxs)("div",{className:"flex items-center gap-4",children:[(0,jsx_runtime_1.jsx)("p",{className:"text-muted-foreground text-sm font-medium whitespace-nowrap",children:i}),(0,jsx_runtime_1.jsx)(select_field_1.SelectField,{name:"limit",control:s,"data-testid":r,children:t.map(e=>(0,jsx_runtime_1.jsx)(select_1.SelectItem,{value:String(e),children:e},e))})]})};exports.PaginationLimitField=PaginationLimitField;
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PasswordField = PasswordField;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const form_1 = require("../../../components/ui/form");
|
|
10
|
-
const input_1 = require("../../../components/ui/input");
|
|
11
|
-
const lucide_react_1 = require("lucide-react");
|
|
12
|
-
const icon_button_1 = require("../../../components/ui/icon-button");
|
|
13
|
-
function PasswordField({ name, label, tooltip, placeholder, control, required = false, disabled = false, 'data-testid': dataTestId, showPasswordLabel = 'Show password', hidePasswordLabel = 'Hide password' }) {
|
|
14
|
-
const [show, setShow] = react_1.default.useState(false);
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)(form_1.FormField, { control: control, name: name, render: ({ field }) => ((0, jsx_runtime_1.jsxs)(form_1.FormItem, { required: required, children: [(0, jsx_runtime_1.jsx)(form_1.FormLabel, { extra: tooltip ? (0, jsx_runtime_1.jsx)(form_1.FormTooltip, { children: tooltip }) : undefined, children: label }), (0, jsx_runtime_1.jsx)(form_1.FormControl, { children: (0, jsx_runtime_1.jsx)(input_1.Input, { ...field, type: show ? 'text' : 'password', placeholder: placeholder, endAdornment: (0, jsx_runtime_1.jsx)(input_1.InputAdornment, { position: "end", children: (0, jsx_runtime_1.jsx)(icon_button_1.IconButton, { type: "button", variant: "outline", rounded: true, "aria-label": show ? hidePasswordLabel : showPasswordLabel, onClick: () => setShow(!show), children: show ? (0, jsx_runtime_1.jsx)(lucide_react_1.EyeOff, { "aria-hidden": true }) : (0, jsx_runtime_1.jsx)(lucide_react_1.Eye, { "aria-hidden": true }) }) }), disabled: disabled, "data-testid": dataTestId }) }), (0, jsx_runtime_1.jsx)(form_1.FormMessage, {})] })) }));
|
|
16
|
-
}
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{"default":e}};Object.defineProperty(exports,"__esModule",{value:true});exports.PasswordField=PasswordField;const jsx_runtime_1=require("react/jsx-runtime");const react_1=__importDefault(require("react"));const form_1=require("../../../components/ui/form");const input_1=require("../../../components/ui/input");const lucide_react_1=require("lucide-react");const icon_button_1=require("../../../components/ui/icon-button");function PasswordField({name:e,label:n,tooltip:r,placeholder:o,control:s,required:i=false,disabled:u=false,"data-testid":d,showPasswordLabel:a="Show password",hidePasswordLabel:c="Hide password"}){const[t,l]=react_1.default.useState(false);return(0,jsx_runtime_1.jsx)(form_1.FormField,{control:s,name:e,render:({field:p})=>(0,jsx_runtime_1.jsxs)(form_1.FormItem,{required:i,children:[(0,jsx_runtime_1.jsx)(form_1.FormLabel,{extra:r?(0,jsx_runtime_1.jsx)(form_1.FormTooltip,{children:r}):void 0,children:n}),(0,jsx_runtime_1.jsx)(form_1.FormControl,{children:(0,jsx_runtime_1.jsx)(input_1.Input,{...p,type:t?"text":"password",placeholder:o,endAdornment:(0,jsx_runtime_1.jsx)(input_1.InputAdornment,{position:"end",children:(0,jsx_runtime_1.jsx)(icon_button_1.IconButton,{type:"button",variant:"outline",rounded:true,"aria-label":t?c:a,onClick:()=>l(!t),children:t?(0,jsx_runtime_1.jsx)(lucide_react_1.EyeOff,{"aria-hidden":true}):(0,jsx_runtime_1.jsx)(lucide_react_1.Eye,{"aria-hidden":true})})}),disabled:u,"data-testid":d})}),(0,jsx_runtime_1.jsx)(form_1.FormMessage,{})]})})}
|
|
@@ -1,36 +1 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.RadioGroupField = void 0;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const form_1 = require("../../../components/ui/form");
|
|
8
|
-
const label_1 = require("../../../components/ui/label");
|
|
9
|
-
const radio_group_1 = require("../../../components/ui/radio-group");
|
|
10
|
-
const renderable_label_1 = require("../../../components/form/renderable-label");
|
|
11
|
-
const RadioGroupField = ({ control, name, options, label, description, tooltip, required, disabled, 'aria-label': ariaLabelProp }) => {
|
|
12
|
-
const showLabel = (0, renderable_label_1.hasRenderableLabel)(label);
|
|
13
|
-
// An empty or whitespace-only aria-label is worse than none: it names the
|
|
14
|
-
// control "". Drop it so the attribute never reaches the DOM.
|
|
15
|
-
const ariaLabel = ariaLabelProp?.trim() ? ariaLabelProp : undefined;
|
|
16
|
-
// `FormLabel` names its control through `htmlFor`, which only works on a
|
|
17
|
-
// labelable element — and the Radix radiogroup root is a plain div. So the
|
|
18
|
-
// visible label reached nobody: a screen-reader user landing on the group
|
|
19
|
-
// heard the options and no field name. The group points BACK at the label
|
|
20
|
-
// instead, via aria-labelledby on a stable generated id.
|
|
21
|
-
const labelId = (0, react_1.useId)();
|
|
22
|
-
// The type cannot rule out `label=""`, so this is the only signal a developer
|
|
23
|
-
// gets that the control shipped nameless.
|
|
24
|
-
if (process.env.NODE_ENV !== 'production' && !showLabel && !ariaLabel) {
|
|
25
|
-
console.error(`RadioGroupField "${name}" has no accessible name: pass a non-empty label or aria-label.`);
|
|
26
|
-
}
|
|
27
|
-
// `setFocus(name)` / focus-on-error needs a ref to something focusable. The
|
|
28
|
-
// RadioGroup root is a plain div, so the ref goes on the first option a user
|
|
29
|
-
// could actually reach — a disabled radio is not focusable.
|
|
30
|
-
const focusTargetIndex = options.findIndex((option) => !option.disabled);
|
|
31
|
-
return ((0, jsx_runtime_1.jsx)(form_1.FormField, { control: control, name: name, render: ({ field }) => ((0, jsx_runtime_1.jsxs)(form_1.FormItem, { required: required, children: [showLabel && ((0, jsx_runtime_1.jsx)(form_1.FormLabel, { id: labelId, extra: tooltip ? (0, jsx_runtime_1.jsx)(form_1.FormTooltip, { children: tooltip }) : undefined, children: label })), (0, jsx_runtime_1.jsx)(form_1.FormControl, { children: (0, jsx_runtime_1.jsx)(radio_group_1.RadioGroup, { name: field.name, value: field.value ?? '', onValueChange: field.onChange, onBlur: field.onBlur, disabled: disabled, "aria-labelledby": showLabel ? labelId : undefined, "aria-label": showLabel ? undefined : ariaLabel, className: "gap-2", children: options.map((option, index) => {
|
|
32
|
-
const id = `${name}-${option.value}`;
|
|
33
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(radio_group_1.RadioGroupItem, { ref: index === focusTargetIndex ? field.ref : undefined, value: option.value, id: id, disabled: option.disabled }), (0, jsx_runtime_1.jsx)(label_1.Label, { htmlFor: id, className: "font-normal", children: option.label })] }, option.value));
|
|
34
|
-
}) }) }), (0, jsx_runtime_1.jsx)(form_1.FormMessage, {}), description && (0, jsx_runtime_1.jsx)(form_1.FormDescription, { children: description })] })) }));
|
|
35
|
-
};
|
|
36
|
-
exports.RadioGroupField = RadioGroupField;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.RadioGroupField=void 0;const jsx_runtime_1=require("react/jsx-runtime");const react_1=require("react");const form_1=require("../../../components/ui/form");const label_1=require("../../../components/ui/label");const radio_group_1=require("../../../components/ui/radio-group");const renderable_label_1=require("../../../components/form/renderable-label");const RadioGroupField=({control:m,name:n,options:l,label:o,description:s,tooltip:d,required:b,disabled:x,"aria-label":i})=>{const a=(0,renderable_label_1.hasRenderableLabel)(o);const u=i?.trim()?i:void 0;const c=(0,react_1.useId)();if(process.env.NODE_ENV!=="production"&&!a&&!u){console.error(`RadioGroupField "${n}" has no accessible name: pass a non-empty label or aria-label.`)}const p=l.findIndex(e=>!e.disabled);return(0,jsx_runtime_1.jsx)(form_1.FormField,{control:m,name:n,render:({field:e})=>(0,jsx_runtime_1.jsxs)(form_1.FormItem,{required:b,children:[a&&(0,jsx_runtime_1.jsx)(form_1.FormLabel,{id:c,extra:d?(0,jsx_runtime_1.jsx)(form_1.FormTooltip,{children:d}):void 0,children:o}),(0,jsx_runtime_1.jsx)(form_1.FormControl,{children:(0,jsx_runtime_1.jsx)(radio_group_1.RadioGroup,{name:e.name,value:e.value??"",onValueChange:e.onChange,onBlur:e.onBlur,disabled:x,"aria-labelledby":a?c:void 0,"aria-label":a?void 0:u,className:"gap-2",children:l.map((r,h)=>{const t=`${n}-${r.value}`;return(0,jsx_runtime_1.jsxs)("div",{className:"flex items-center gap-2",children:[(0,jsx_runtime_1.jsx)(radio_group_1.RadioGroupItem,{ref:h===p?e.ref:void 0,value:r.value,id:t,disabled:r.disabled}),(0,jsx_runtime_1.jsx)(label_1.Label,{htmlFor:t,className:"font-normal",children:r.label})]},r.value)})})}),(0,jsx_runtime_1.jsx)(form_1.FormMessage,{}),s&&(0,jsx_runtime_1.jsx)(form_1.FormDescription,{children:s})]})})};exports.RadioGroupField=RadioGroupField;
|
|
@@ -1,57 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasRenderableLabel = hasRenderableLabel;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
/**
|
|
6
|
-
* Does this label put readable content INSIDE the label element — i.e. does it
|
|
7
|
-
* give the control an accessible name?
|
|
8
|
-
*
|
|
9
|
-
* Ceiling, on purpose: a non-fragment element always counts, even an empty one.
|
|
10
|
-
* We cannot render a component to find out whether it emits text, so
|
|
11
|
-
* `label={<EmptyThing />}` is accepted. Fragments ARE unwrapped, since they add
|
|
12
|
-
* no markup of their own and `<></>` is a plausible way to say "no label".
|
|
13
|
-
*
|
|
14
|
-
* A PORTAL DOES NOT COUNT. It is the one node that renders its content
|
|
15
|
-
* somewhere else in the DOM — by definition outside the label subtree — so the
|
|
16
|
-
* label element itself stays empty and names nothing. The content is visible on
|
|
17
|
-
* screen, which is exactly what makes this worth guarding: it looks labelled
|
|
18
|
-
* and is silent to a screen reader. Pass `aria-label` when the visible text
|
|
19
|
-
* lives in a portal.
|
|
20
|
-
*
|
|
21
|
-
* BRANCH ORDER IS LOAD-BEARING — element before portal before collection:
|
|
22
|
-
* `Children.toArray` hands a portal straight back unchanged, so reaching the
|
|
23
|
-
* collection branch with one would recurse forever. The portal branch is the
|
|
24
|
-
* crash guard as much as the verdict. Every field in this directory shares this
|
|
25
|
-
* one copy precisely so that ordering cannot drift.
|
|
26
|
-
*/
|
|
27
|
-
function hasRenderableLabel(label) {
|
|
28
|
-
if (label === null || label === undefined || typeof label === 'boolean') {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
// Empty AND whitespace-only strings render a label box with nothing to
|
|
32
|
-
// announce, so both count as absent. A number (`0`) is a real label.
|
|
33
|
-
if (typeof label === 'string')
|
|
34
|
-
return label.trim() !== '';
|
|
35
|
-
if (typeof label === 'number' || typeof label === 'bigint')
|
|
36
|
-
return true;
|
|
37
|
-
if ((0, react_1.isValidElement)(label)) {
|
|
38
|
-
return label.type === react_1.Fragment
|
|
39
|
-
? hasRenderableLabel(label.props?.children ?? null)
|
|
40
|
-
: true;
|
|
41
|
-
}
|
|
42
|
-
// Portals and any other React-internal node that is not an element: their
|
|
43
|
-
// content lands outside this subtree (or is unknowable), so it cannot name
|
|
44
|
-
// the control. Must stay ABOVE the collection branch: isValidElement is false
|
|
45
|
-
// for a portal and Children.toArray hands the identical node straight back,
|
|
46
|
-
// so recursing on it would never terminate.
|
|
47
|
-
if (typeof label === 'object' && '$$typeof' in label)
|
|
48
|
-
return false;
|
|
49
|
-
const children = react_1.Children.toArray(label);
|
|
50
|
-
// Belt for anything else toArray cannot break down: no progress left to make,
|
|
51
|
-
// and nothing we can confirm renders in place, so treat it as absent rather
|
|
52
|
-
// than recurse forever.
|
|
53
|
-
if (children.length === 1 && children[0] === label)
|
|
54
|
-
return false;
|
|
55
|
-
// Arrays and other iterables: renderable only if some child is.
|
|
56
|
-
return children.some((child) => hasRenderableLabel(child));
|
|
57
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.hasRenderableLabel=hasRenderableLabel;const react_1=require("react");function hasRenderableLabel(e){if(e===null||e===void 0||typeof e==="boolean"){return false}if(typeof e==="string")return e.trim()!=="";if(typeof e==="number"||typeof e==="bigint")return true;if((0,react_1.isValidElement)(e)){return e.type===react_1.Fragment?hasRenderableLabel(e.props?.children??null):true}if(typeof e==="object"&&"$$typeof"in e)return false;const r=react_1.Children.toArray(e);if(r.length===1&&r[0]===e)return false;return r.some(t=>hasRenderableLabel(t))}
|
|
@@ -1,68 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SelectField = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const form_1 = require("../../../components/ui/form");
|
|
6
|
-
const multiple_select_1 = require("../../../components/ui/multiple-select");
|
|
7
|
-
const select_1 = require("../../../components/ui/select");
|
|
8
|
-
const utils_1 = require("../../../lib/utils");
|
|
9
|
-
const SelectField = ({ name, label, tooltip, labelExtra, required, placeholder, description, disabled, readOnly, multi, control, value, children, emptyMessage = 'No options found.', leadingIcon, className, onChange, ...others }) => {
|
|
10
|
-
// The props union already pairs `multi` with the callback shape that branch
|
|
11
|
-
// emits, but destructuring an intersection loses that correlation — TS sees
|
|
12
|
-
// two unrelated callbacks. Both branches report through this one seam, each
|
|
13
|
-
// with the payload its own union member declared.
|
|
14
|
-
const emitChange = onChange;
|
|
15
|
-
/**
|
|
16
|
-
* ⛔ THE GLYPH AND THE VALUE ARE ONE FLEX CHILD, NEVER TWO.
|
|
17
|
-
*
|
|
18
|
-
* `.select-trigger` is `flex w-full items-center justify-between`, so a
|
|
19
|
-
* third child makes it split the free space into TWO gaps: on any trigger
|
|
20
|
-
* wider than its content — which is every filter bar — the selected value
|
|
21
|
-
* drifted to the middle of the box instead of sitting beside the glyph.
|
|
22
|
-
* Wrapped, the trigger is back to two children, content and chevron,
|
|
23
|
-
* whatever the caller passes.
|
|
24
|
-
*
|
|
25
|
-
* `min-w-0` keeps the value truncating: the wrapper is the flex item now,
|
|
26
|
-
* and a flex item never shrinks below its own min-content width. The
|
|
27
|
-
* trigger's `VALUE_OVERFLOW_CLASS` reaches through it by descendant
|
|
28
|
-
* selector.
|
|
29
|
-
*
|
|
30
|
-
* No `gap`: the prop's contract is that spacing is the caller's (the Tracer
|
|
31
|
-
* filter bars carry their own `mr-2`), and a kit gap would double with it.
|
|
32
|
-
*
|
|
33
|
-
* The MULTI trigger needs none of this — it already renders its children
|
|
34
|
-
* inside one `flex grow flex-wrap` box, so the icon already shares a parent
|
|
35
|
-
* with the value and the trigger root already has exactly two children.
|
|
36
|
-
* Wrapping there would put the selected-value badges in a non-wrapping row
|
|
37
|
-
* and stop the trigger growing to a second line.
|
|
38
|
-
*/
|
|
39
|
-
const withLeadingIcon = (value) => leadingIcon ? ((0, jsx_runtime_1.jsxs)("span", { className: "flex min-w-0 items-center", children: [leadingIcon, value] })) : (value);
|
|
40
|
-
const renderItem = (field) => {
|
|
41
|
-
return ((0, jsx_runtime_1.jsxs)(form_1.FormItem, { required: required, className: className, children: [label && ((0, jsx_runtime_1.jsx)(form_1.FormLabel, { extra: tooltip ? (0, jsx_runtime_1.jsx)(form_1.FormTooltip, { children: tooltip }) : labelExtra, children: label })), multi ? ((0, jsx_runtime_1.jsxs)(multiple_select_1.MultipleSelect, { onValueChange: (value) => {
|
|
42
|
-
field.onChange(value);
|
|
43
|
-
emitChange?.(value);
|
|
44
|
-
}, disabled: disabled, ...field, children: [(0, jsx_runtime_1.jsxs)(multiple_select_1.MultipleSelectTrigger, { readOnly: readOnly, children: [leadingIcon, (0, jsx_runtime_1.jsx)(multiple_select_1.MultipleSelectValue, { placeholder: placeholder })] }), (0, jsx_runtime_1.jsx)(multiple_select_1.MultipleSelectContent, { children: children })] })) : ((0, jsx_runtime_1.jsxs)(select_1.Select, { onValueChange: (value) => {
|
|
45
|
-
field.onChange(value);
|
|
46
|
-
emitChange?.(value);
|
|
47
|
-
}, value: field.value, disabled: disabled, open: readOnly ? false : undefined, onOpenChange: readOnly ? () => { } : undefined, children: [(0, jsx_runtime_1.jsx)(form_1.FormControl, { children: (0, jsx_runtime_1.jsx)(select_1.SelectTrigger, { className: (0, utils_1.cn)(disabled && 'bg-shadcn-100'), readOnly: readOnly, "data-testid": others['data-testid'], children: withLeadingIcon((0, jsx_runtime_1.jsx)(select_1.SelectValue, { placeholder: placeholder })) }) }), (0, jsx_runtime_1.jsxs)(select_1.SelectContent, { children: [(0, jsx_runtime_1.jsx)(select_1.SelectEmpty, { children: emptyMessage }), children] })] })), (0, jsx_runtime_1.jsx)(form_1.FormMessage, {}), description && (0, jsx_runtime_1.jsx)(form_1.FormDescription, { children: description })] }));
|
|
48
|
-
};
|
|
49
|
-
if (!control) {
|
|
50
|
-
// `value` undefined leaves Radix to keep its own state, so an uncontrolled
|
|
51
|
-
// standalone select still opens and picks; `onChange` reports either way.
|
|
52
|
-
// The caller's own `onChange` is invoked by the body, so this is a no-op.
|
|
53
|
-
return renderItem({
|
|
54
|
-
name,
|
|
55
|
-
value,
|
|
56
|
-
onChange: () => { },
|
|
57
|
-
onBlur: () => { },
|
|
58
|
-
ref: () => { },
|
|
59
|
-
disabled
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
return ((0, jsx_runtime_1.jsx)(form_1.FormField, { name: name, control: control, ...others,
|
|
63
|
-
// An unset field falls back to the EMPTY value of its own shape: `''`
|
|
64
|
-
// for the single select, `[]` for the multi one. Falling back to `''`
|
|
65
|
-
// for both handed MultipleSelect a string it silently discarded.
|
|
66
|
-
render: ({ field }) => renderItem({ ...field, value: field.value ?? (multi ? [] : '') }) }));
|
|
67
|
-
};
|
|
68
|
-
exports.SelectField = SelectField;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SelectField=void 0;const jsx_runtime_1=require("react/jsx-runtime");const form_1=require("../../../components/ui/form");const multiple_select_1=require("../../../components/ui/multiple-select");const select_1=require("../../../components/ui/select");const utils_1=require("../../../lib/utils");const SelectField=({name:l,label:c,tooltip:o,labelExtra:p,required:g,placeholder:i,description:u,disabled:n,readOnly:s,multi:a,control:d,value:S,children:m,emptyMessage:F="No options found.",leadingIcon:r,className:C,onChange:_,...x})=>{const h=_;const f=e=>r?(0,jsx_runtime_1.jsxs)("span",{className:"flex min-w-0 items-center",children:[r,e]}):e;const j=e=>{return(0,jsx_runtime_1.jsxs)(form_1.FormItem,{required:g,className:C,children:[c&&(0,jsx_runtime_1.jsx)(form_1.FormLabel,{extra:o?(0,jsx_runtime_1.jsx)(form_1.FormTooltip,{children:o}):p,children:c}),a?(0,jsx_runtime_1.jsxs)(multiple_select_1.MultipleSelect,{onValueChange:t=>{e.onChange(t);h?.(t)},disabled:n,...e,children:[(0,jsx_runtime_1.jsxs)(multiple_select_1.MultipleSelectTrigger,{readOnly:s,children:[r,(0,jsx_runtime_1.jsx)(multiple_select_1.MultipleSelectValue,{placeholder:i})]}),(0,jsx_runtime_1.jsx)(multiple_select_1.MultipleSelectContent,{children:m})]}):(0,jsx_runtime_1.jsxs)(select_1.Select,{onValueChange:t=>{e.onChange(t);h?.(t)},value:e.value,disabled:n,open:s?false:void 0,onOpenChange:s?()=>{}:void 0,children:[(0,jsx_runtime_1.jsx)(form_1.FormControl,{children:(0,jsx_runtime_1.jsx)(select_1.SelectTrigger,{className:(0,utils_1.cn)(n&&"bg-shadcn-100"),readOnly:s,"data-testid":x["data-testid"],children:f((0,jsx_runtime_1.jsx)(select_1.SelectValue,{placeholder:i}))})}),(0,jsx_runtime_1.jsxs)(select_1.SelectContent,{children:[(0,jsx_runtime_1.jsx)(select_1.SelectEmpty,{children:F}),m]})]}),(0,jsx_runtime_1.jsx)(form_1.FormMessage,{}),u&&(0,jsx_runtime_1.jsx)(form_1.FormDescription,{children:u})]})};if(!d){return j({name:l,value:S,onChange:()=>{},onBlur:()=>{},ref:()=>{},disabled:n})}return(0,jsx_runtime_1.jsx)(form_1.FormField,{name:l,control:d,...x,render:({field:e})=>j({...e,value:e.value??(a?[]:"")})})};exports.SelectField=SelectField;
|