@rockshin/tao-ui 0.0.42 → 0.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/component-manifest.json +34 -17
- package/dist/components/alert/alert.css +1 -0
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/calendar/calendar.css +10 -60
- package/dist/components/calendar/calendar.js +46 -43
- package/dist/components/card/card.css +1 -1
- package/dist/components/carousel/carousel.css +1 -0
- package/dist/components/carousel/carousel.js +62 -7
- package/dist/components/collapse/collapse-panels.d.ts +4 -0
- package/dist/components/collapse/collapse-panels.js +413 -0
- package/dist/components/collapse/collapse.css +199 -0
- package/dist/components/collapse/collapse.d.ts +77 -0
- package/dist/components/{collapsible/collapsible.js → collapse/collapse.js} +26 -10
- package/dist/components/color-picker/color-picker.css +8 -42
- package/dist/components/color-picker/color-picker.js +220 -145
- package/dist/components/date-picker/date-picker.css +18 -56
- package/dist/components/date-picker/date-picker.d.ts +2 -0
- package/dist/components/date-picker/date-picker.js +11 -6
- package/dist/components/date-picker/presets.js +5 -2
- package/dist/components/date-picker/range-picker.d.ts +2 -0
- package/dist/components/date-picker/range-picker.js +3 -1
- package/dist/components/form/form-item.js +1 -0
- package/dist/components/form/form.css +15 -0
- package/dist/components/form/form.js +1 -0
- package/dist/components/form-field/form-field-view.d.ts +3 -1
- package/dist/components/form-field/form-field-view.js +109 -84
- package/dist/components/input/base-input.d.ts +25 -0
- package/dist/components/input/base-input.js +104 -0
- package/dist/components/input/input-shared.css +75 -0
- package/dist/components/input/input-shared.d.ts +59 -0
- package/dist/components/input/input-shared.js +152 -0
- package/dist/components/input/input.css +99 -4
- package/dist/components/input/input.d.ts +12 -16
- package/dist/components/input/input.js +11 -154
- package/dist/components/input/otp.d.ts +29 -0
- package/dist/components/input/otp.js +335 -0
- package/dist/components/input/password.d.ts +12 -0
- package/dist/components/input/password.js +117 -0
- package/dist/components/input/search.d.ts +16 -0
- package/dist/components/input/search.js +99 -0
- package/dist/components/input-number/input-number.d.ts +2 -2
- package/dist/components/input-number/input-number.js +2 -2
- package/dist/components/list/list-pagination.css +5 -5
- package/dist/components/list/list-pagination.js +1 -0
- package/dist/components/mentions/mentions.css +7 -0
- package/dist/components/modal/modal.css +1 -0
- package/dist/components/radio/radio.d.ts +1 -1
- package/dist/components/radio/radio.js +78 -73
- package/dist/components/select/mobile-select.css +1 -16
- package/dist/components/select/mobile-select.d.ts +2 -1
- package/dist/components/select/mobile-select.js +68 -63
- package/dist/components/select/select-types.d.ts +2 -0
- package/dist/components/select/select.css +19 -0
- package/dist/components/select/select.js +31 -17
- package/dist/components/spinner/spinner.css +1 -1
- package/dist/components/steps/steps.css +53 -3
- package/dist/components/table/table.css +0 -5
- package/dist/components/table/table.js +21 -22
- package/dist/components/textarea/textarea.css +20 -0
- package/dist/components/textarea/textarea.d.ts +12 -6
- package/dist/components/textarea/textarea.js +120 -219
- package/dist/components/time-picker/time-picker.css +7 -0
- package/dist/components/tree/tree-check.d.ts +1 -0
- package/dist/components/tree/tree-check.js +36 -0
- package/dist/components/tree/tree.css +13 -18
- package/dist/components/tree/tree.js +2 -3
- package/dist/components/tree-select/select-engine.css +7 -0
- package/dist/components/tree-select/tree-select.js +2 -3
- package/dist/components/upload/upload.css +0 -11
- package/dist/components/upload/upload.js +13 -3
- package/dist/docs/component-docs.js +2 -2
- package/dist/docs/components/{collapsible.doc.d.ts → collapse.doc.d.ts} +1 -1
- package/dist/docs/components/collapse.doc.js +47 -0
- package/dist/docs/components/input.doc.js +11 -4
- package/dist/docs/components/textarea.doc.js +4 -2
- package/dist/entries/collapse.d.ts +3 -0
- package/dist/entries/{collapsible.js → collapse.js} +1 -1
- package/dist/entries/input.d.ts +1 -1
- package/dist/entries/textarea.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/provider/locale.d.ts +6 -0
- package/dist/provider/locale.js +10 -0
- package/dist/provider/tao-provider.js +1 -0
- package/dist/theme/control.css +2 -2
- package/dist/theme/theme.css +3 -1
- package/dist/theme/tokens.d.ts +2 -2
- package/dist/theme/tokens.js +1 -0
- package/dist/utils/field-label.d.ts +4 -0
- package/dist/utils/field-label.js +7 -0
- package/llms.txt +18 -15
- package/package.json +7 -4
- package/dist/components/collapsible/collapsible.css +0 -49
- package/dist/components/collapsible/collapsible.d.ts +0 -39
- package/dist/docs/components/collapsible.doc.js +0 -39
- package/dist/entries/collapsible.d.ts +0 -3
|
@@ -80,12 +80,27 @@ input[data-tao-picker-input]::placeholder, [data-tao-picker-placeholder] {
|
|
|
80
80
|
color: var(--tao-color-text-tertiary);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
[data-tao-picker-icons][data-tao-clearable] [data-tao-picker-
|
|
83
|
+
[data-tao-picker-icons][data-tao-clearable] [data-tao-picker-suffix] {
|
|
84
84
|
display: none;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
@media (hover: hover) and (pointer: fine) {
|
|
88
|
+
[data-tao-picker-icons][data-tao-clearable] {
|
|
89
|
+
display: grid;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
[data-tao-picker-icons][data-tao-clearable] > * {
|
|
93
|
+
grid-area: 1 / 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
:is([data-tao-picker-trigger], [data-tao-range-trigger]):not(:hover) [data-tao-picker-clear]:not(:focus-visible) {
|
|
97
|
+
opacity: 0;
|
|
98
|
+
pointer-events: none;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
:is([data-tao-picker-trigger], [data-tao-range-trigger]):not(:hover) [data-tao-picker-icons][data-tao-clearable]:not(:has(:focus-visible)) [data-tao-picker-suffix] {
|
|
102
|
+
display: flex;
|
|
103
|
+
}
|
|
89
104
|
}
|
|
90
105
|
|
|
91
106
|
[data-tao-picker-clear] {
|
|
@@ -513,27 +528,6 @@ button[data-tao-time-cell][data-tao-selected] {
|
|
|
513
528
|
display: flex;
|
|
514
529
|
}
|
|
515
530
|
|
|
516
|
-
button[data-tao-preset-btn] {
|
|
517
|
-
border: var(--tao-line-width) solid var(--tao-color-border);
|
|
518
|
-
border-radius: var(--tao-radius-sm);
|
|
519
|
-
font-family: var(--tao-font-family);
|
|
520
|
-
font-size: var(--tao-font-size-xs);
|
|
521
|
-
color: var(--tao-color-text-secondary);
|
|
522
|
-
cursor: pointer;
|
|
523
|
-
appearance: none;
|
|
524
|
-
transition: border-color var(--tao-motion-duration-fast) ease-out,
|
|
525
|
-
color var(--tao-motion-duration-fast) ease-out;
|
|
526
|
-
background: none;
|
|
527
|
-
outline: none;
|
|
528
|
-
margin: 0;
|
|
529
|
-
padding: 2px 8px;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
button[data-tao-preset-btn]:hover {
|
|
533
|
-
border-color: var(--tao-primary);
|
|
534
|
-
color: var(--tao-primary);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
531
|
[data-tao-picker-footer] {
|
|
538
532
|
justify-content: flex-end;
|
|
539
533
|
gap: var(--tao-padding-xs);
|
|
@@ -544,38 +538,6 @@ button[data-tao-preset-btn]:hover {
|
|
|
544
538
|
display: flex;
|
|
545
539
|
}
|
|
546
540
|
|
|
547
|
-
button[data-tao-picker-footer-btn] {
|
|
548
|
-
border: var(--tao-line-width) solid var(--tao-color-border);
|
|
549
|
-
border-radius: var(--tao-radius-sm);
|
|
550
|
-
font-family: var(--tao-font-family);
|
|
551
|
-
font-size: var(--tao-font-size-xs);
|
|
552
|
-
color: var(--tao-color-text-secondary);
|
|
553
|
-
cursor: pointer;
|
|
554
|
-
appearance: none;
|
|
555
|
-
transition: background-color var(--tao-motion-duration-fast) ease-out,
|
|
556
|
-
border-color var(--tao-motion-duration-fast) ease-out,
|
|
557
|
-
color var(--tao-motion-duration-fast) ease-out;
|
|
558
|
-
background: none;
|
|
559
|
-
outline: none;
|
|
560
|
-
margin: 0;
|
|
561
|
-
padding: 4px 12px;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
button[data-tao-picker-footer-btn]:hover {
|
|
565
|
-
border-color: var(--tao-primary);
|
|
566
|
-
color: var(--tao-primary);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
button[data-tao-picker-footer-btn][data-tao-primary] {
|
|
570
|
-
background: var(--tao-primary);
|
|
571
|
-
border-color: var(--tao-primary);
|
|
572
|
-
color: #fff;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
button[data-tao-picker-footer-btn][data-tao-primary]:hover {
|
|
576
|
-
background: var(--tao-primary-hover);
|
|
577
|
-
}
|
|
578
|
-
|
|
579
541
|
[data-tao-range-trigger] {
|
|
580
542
|
width: 100%;
|
|
581
543
|
font-family: var(--tao-font-family);
|
|
@@ -28,6 +28,8 @@ export interface DatePickerProps extends Pick<AriaAttributes, 'aria-label' | 'ar
|
|
|
28
28
|
status?: TaoStatus;
|
|
29
29
|
ref?: Ref<PickerRef>;
|
|
30
30
|
mobile?: boolean;
|
|
31
|
+
/** Mobile drawer title. Defaults to the Form.Item/FormField label, then locale text. */
|
|
32
|
+
mobileTitle?: ReactNode;
|
|
31
33
|
open?: boolean;
|
|
32
34
|
onOpenChange?: (open: boolean) => void;
|
|
33
35
|
className?: string;
|
|
@@ -5,6 +5,8 @@ import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
|
5
5
|
import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { TaoPortalScope, useTaoConfig } from "../../provider/tao-provider.js";
|
|
7
7
|
import { useIsMobile } from "../../utils/breakpoint.js";
|
|
8
|
+
import { useMobileTitle } from "../../utils/field-label.js";
|
|
9
|
+
import { Button } from "../button/button.js";
|
|
8
10
|
import { cx } from "../../utils/semantic.js";
|
|
9
11
|
import { Drawer } from "../drawer/drawer.js";
|
|
10
12
|
import { CalendarGrid } from "./calendar/calendar-grid.js";
|
|
@@ -44,7 +46,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
44
46
|
]);
|
|
45
47
|
const fmt = formatProp ?? getDefaultFormat(picker, showTime);
|
|
46
48
|
const defaultPlaceholder = placeholder ?? fmt;
|
|
47
|
-
const drawerTitle = showTime ? ctx.locale.dateTime :
|
|
49
|
+
const drawerTitle = useMobileTitle(props.mobileTitle, showTime ? ctx.locale.dateTime : ctx.locale.selectDate);
|
|
48
50
|
const isDateBlocked = useCallback((date)=>{
|
|
49
51
|
const granularity = 'date' === picker ? 'day' : picker;
|
|
50
52
|
return !date.isValid() || Boolean(disabledDate?.(date)) || null != minDate && date.isBefore(minDate, granularity) || null != maxDate && date.isAfter(maxDate, granularity);
|
|
@@ -301,14 +303,17 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
301
303
|
className: classNames?.footer,
|
|
302
304
|
style: styles?.footer,
|
|
303
305
|
children: [
|
|
304
|
-
/*#__PURE__*/ jsx(
|
|
305
|
-
|
|
306
|
+
/*#__PURE__*/ jsx(Button, {
|
|
307
|
+
variant: "secondary",
|
|
308
|
+
size: "small",
|
|
309
|
+
disabled: false,
|
|
306
310
|
"data-tao-picker-footer-btn": "",
|
|
307
311
|
onClick: handleNow,
|
|
308
312
|
children: ctx.locale.now
|
|
309
313
|
}),
|
|
310
|
-
/*#__PURE__*/ jsx(
|
|
311
|
-
|
|
314
|
+
/*#__PURE__*/ jsx(Button, {
|
|
315
|
+
size: "small",
|
|
316
|
+
disabled: false,
|
|
312
317
|
"data-tao-picker-footer-btn": "",
|
|
313
318
|
"data-tao-primary": "",
|
|
314
319
|
onClick: handleOk,
|
|
@@ -482,7 +487,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
482
487
|
children: /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_popover_c8444160.Content, {
|
|
483
488
|
id: popupId,
|
|
484
489
|
ref: popupRef,
|
|
485
|
-
"aria-label": props['aria-label'] ??
|
|
490
|
+
"aria-label": props['aria-label'] ?? (showTime ? ctx.locale.dateTime : defaultPlaceholder),
|
|
486
491
|
"data-tao-picker-dropdown": "",
|
|
487
492
|
sideOffset: 4,
|
|
488
493
|
align: "start",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { Button } from "../button/button.js";
|
|
3
4
|
function Presets(t0) {
|
|
4
5
|
const $ = c(7);
|
|
5
6
|
const { items, onSelect } = t0;
|
|
@@ -8,8 +9,10 @@ function Presets(t0) {
|
|
|
8
9
|
if ($[0] !== items || $[1] !== onSelect) {
|
|
9
10
|
let t2;
|
|
10
11
|
if ($[3] !== onSelect) {
|
|
11
|
-
t2 = (item)=>/*#__PURE__*/ jsx(
|
|
12
|
-
|
|
12
|
+
t2 = (item)=>/*#__PURE__*/ jsx(Button, {
|
|
13
|
+
variant: "secondary",
|
|
14
|
+
size: "small",
|
|
15
|
+
disabled: false,
|
|
13
16
|
"data-tao-preset-btn": "",
|
|
14
17
|
onClick: ()=>onSelect(item.value),
|
|
15
18
|
children: item.label
|
|
@@ -27,6 +27,8 @@ export interface RangePickerProps extends Pick<AriaAttributes, 'aria-label' | 'a
|
|
|
27
27
|
status?: TaoStatus;
|
|
28
28
|
ref?: Ref<PickerRef>;
|
|
29
29
|
mobile?: boolean;
|
|
30
|
+
/** Mobile drawer title. Defaults to the Form.Item/FormField label, then locale text. */
|
|
31
|
+
mobileTitle?: ReactNode;
|
|
30
32
|
open?: boolean;
|
|
31
33
|
onOpenChange?: (open: boolean) => void;
|
|
32
34
|
className?: string;
|
|
@@ -5,6 +5,7 @@ import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
|
5
5
|
import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useRef, useState } from "react";
|
|
6
6
|
import { TaoPortalScope, useTaoConfig } from "../../provider/tao-provider.js";
|
|
7
7
|
import { useIsMobile } from "../../utils/breakpoint.js";
|
|
8
|
+
import { useMobileTitle } from "../../utils/field-label.js";
|
|
8
9
|
import { cx } from "../../utils/semantic.js";
|
|
9
10
|
import { Drawer } from "../drawer/drawer.js";
|
|
10
11
|
import { CalendarGrid } from "./calendar/calendar-grid.js";
|
|
@@ -20,6 +21,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
20
21
|
const [keyboardFocusRequested, setKeyboardFocusRequested] = useState(false);
|
|
21
22
|
const returnFocusRef = useRef(null);
|
|
22
23
|
const ctx = useTaoConfig();
|
|
24
|
+
const drawerTitle = useMobileTitle(props.mobileTitle, ctx.locale.dateRange);
|
|
23
25
|
const placeholder = placeholderProp ?? [
|
|
24
26
|
ctx.locale.startDate,
|
|
25
27
|
ctx.locale.endDate
|
|
@@ -620,7 +622,7 @@ const range_picker_RangePicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
620
622
|
open: isOpen,
|
|
621
623
|
onClose: ()=>setOpen(false),
|
|
622
624
|
placement: "bottom",
|
|
623
|
-
title:
|
|
625
|
+
title: drawerTitle,
|
|
624
626
|
height: "85vh",
|
|
625
627
|
children: panelContent
|
|
626
628
|
})
|
|
@@ -39,6 +39,7 @@ function FormItem(t0) {
|
|
|
39
39
|
};
|
|
40
40
|
if (noStyle) return /*#__PURE__*/ isValidElement(content) && controlProps ? /*#__PURE__*/ cloneElement(content, controlProps) : content;
|
|
41
41
|
return /*#__PURE__*/ jsx(FormFieldView, {
|
|
42
|
+
formItem: true,
|
|
42
43
|
label: label,
|
|
43
44
|
htmlFor: htmlFor,
|
|
44
45
|
required: requiredMark,
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
[data-tao-form] > [data-tao-form-item] {
|
|
2
|
+
margin-block-end: var(--tao-form-field-item-gap, var(--tao-padding-md));
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[data-tao-form-message] {
|
|
6
|
+
min-block-size: 1lh;
|
|
7
|
+
font-size: var(--tao-form-field-error-font-size, var(--tao-font-size-xs));
|
|
8
|
+
line-height: var(--tao-line-height-sm);
|
|
9
|
+
margin-block-start: var(--tao-padding-xxs);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
[data-tao-form-message] > [data-tao-form-error], [data-tao-form-message] > [data-tao-form-description] {
|
|
13
|
+
margin-block: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
1
16
|
[data-tao-form-field][data-tao-layout="horizontal"] {
|
|
2
17
|
align-items: flex-start;
|
|
3
18
|
gap: var(--tao-padding-sm);
|
|
@@ -2,6 +2,8 @@ import { type CSSProperties, type ReactNode } from 'react';
|
|
|
2
2
|
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
|
|
3
3
|
export type FormFieldLayout = 'vertical' | 'horizontal';
|
|
4
4
|
export interface FormFieldViewProps {
|
|
5
|
+
/** Identifies Form.Item without changing standalone FormField spacing. */
|
|
6
|
+
formItem?: boolean;
|
|
5
7
|
label?: ReactNode;
|
|
6
8
|
htmlFor?: string;
|
|
7
9
|
required?: boolean;
|
|
@@ -27,4 +29,4 @@ export interface FormFieldViewProps {
|
|
|
27
29
|
* with the aria wiring (describedby/errormessage/invalid/required) applied
|
|
28
30
|
* to the child control. Not part of the public API.
|
|
29
31
|
*/
|
|
30
|
-
export declare function FormFieldView({ label, htmlFor, required, error, warning, description, layout, controlProps, children, className, style, classNames, styles, }: FormFieldViewProps): import("react").JSX.Element;
|
|
32
|
+
export declare function FormFieldView({ formItem, label, htmlFor, required, error, warning, description, layout, controlProps, children, className, style, classNames, styles, }: FormFieldViewProps): import("react").JSX.Element;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { cloneElement, isValidElement, useId } from "react";
|
|
4
|
+
import { FieldLabelContext } from "../../utils/field-label.js";
|
|
4
5
|
import { cx } from "../../utils/semantic.js";
|
|
5
6
|
function FormFieldView(t0) {
|
|
6
|
-
const $ = c(
|
|
7
|
-
const { label, htmlFor, required, error, warning, description, layout: t1, controlProps, children, className, style, classNames, styles } = t0;
|
|
7
|
+
const $ = c(54);
|
|
8
|
+
const { formItem, label, htmlFor, required, error, warning, description, layout: t1, controlProps, children, className, style, classNames, styles } = t0;
|
|
8
9
|
const layout = void 0 === t1 ? "vertical" : t1;
|
|
9
10
|
const generatedId = useId();
|
|
10
11
|
const child = /*#__PURE__*/ isValidElement(children) ? children : null;
|
|
@@ -51,29 +52,59 @@ function FormFieldView(t0) {
|
|
|
51
52
|
$[14] = t4;
|
|
52
53
|
} else t4 = $[14];
|
|
53
54
|
const control = t4;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
let t5;
|
|
56
|
+
if ($[15] !== classNames?.description || $[16] !== classNames?.error || $[17] !== description || $[18] !== descriptionId || $[19] !== error || $[20] !== errorId || $[21] !== styles?.description || $[22] !== styles?.error || $[23] !== warning) {
|
|
57
|
+
t5 = error ? /*#__PURE__*/ jsx("p", {
|
|
58
|
+
className: classNames?.error,
|
|
59
|
+
style: styles?.error,
|
|
60
|
+
"data-tao-form-error": "",
|
|
61
|
+
"data-tao-status": warning ? "warning" : void 0,
|
|
62
|
+
id: errorId,
|
|
63
|
+
role: "alert",
|
|
64
|
+
children: error
|
|
65
|
+
}) : description ? /*#__PURE__*/ jsx("p", {
|
|
66
|
+
className: classNames?.description,
|
|
67
|
+
style: styles?.description,
|
|
68
|
+
"data-tao-form-description": "",
|
|
69
|
+
id: descriptionId,
|
|
70
|
+
children: description
|
|
71
|
+
}) : null;
|
|
72
|
+
$[15] = classNames?.description;
|
|
73
|
+
$[16] = classNames?.error;
|
|
74
|
+
$[17] = description;
|
|
75
|
+
$[18] = descriptionId;
|
|
76
|
+
$[19] = error;
|
|
77
|
+
$[20] = errorId;
|
|
78
|
+
$[21] = styles?.description;
|
|
79
|
+
$[22] = styles?.error;
|
|
80
|
+
$[23] = warning;
|
|
81
|
+
$[24] = t5;
|
|
82
|
+
} else t5 = $[24];
|
|
83
|
+
const message = t5;
|
|
84
|
+
const t6 = classNames?.root;
|
|
85
|
+
let t7;
|
|
86
|
+
if ($[25] !== className || $[26] !== t6) {
|
|
87
|
+
t7 = cx(t6, className);
|
|
88
|
+
$[25] = className;
|
|
89
|
+
$[26] = t6;
|
|
90
|
+
$[27] = t7;
|
|
91
|
+
} else t7 = $[27];
|
|
92
|
+
const t8 = styles?.root;
|
|
93
|
+
let t9;
|
|
94
|
+
if ($[28] !== style || $[29] !== t8) {
|
|
95
|
+
t9 = {
|
|
96
|
+
...t8,
|
|
67
97
|
...style
|
|
68
98
|
};
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
72
|
-
} else
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
99
|
+
$[28] = style;
|
|
100
|
+
$[29] = t8;
|
|
101
|
+
$[30] = t9;
|
|
102
|
+
} else t9 = $[30];
|
|
103
|
+
const t10 = formItem ? "" : void 0;
|
|
104
|
+
const t11 = "horizontal" === layout ? "horizontal" : void 0;
|
|
105
|
+
let t12;
|
|
106
|
+
if ($[31] !== classNames?.label || $[32] !== controlId || $[33] !== label || $[34] !== labelId || $[35] !== required || $[36] !== styles?.label) {
|
|
107
|
+
t12 = null != label && /*#__PURE__*/ jsxs("label", {
|
|
77
108
|
id: labelId,
|
|
78
109
|
htmlFor: controlId,
|
|
79
110
|
className: classNames?.label,
|
|
@@ -88,74 +119,68 @@ function FormFieldView(t0) {
|
|
|
88
119
|
})
|
|
89
120
|
]
|
|
90
121
|
});
|
|
91
|
-
$[
|
|
92
|
-
$[
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
} else
|
|
99
|
-
let
|
|
100
|
-
if ($[
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
"data-tao-form-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
$[34] = styles?.description;
|
|
123
|
-
$[35] = styles?.error;
|
|
124
|
-
$[36] = warning;
|
|
125
|
-
$[37] = t11;
|
|
126
|
-
} else t11 = $[37];
|
|
127
|
-
let t12;
|
|
128
|
-
if ($[38] !== control || $[39] !== t11) {
|
|
129
|
-
t12 = /*#__PURE__*/ jsxs("div", {
|
|
122
|
+
$[31] = classNames?.label;
|
|
123
|
+
$[32] = controlId;
|
|
124
|
+
$[33] = label;
|
|
125
|
+
$[34] = labelId;
|
|
126
|
+
$[35] = required;
|
|
127
|
+
$[36] = styles?.label;
|
|
128
|
+
$[37] = t12;
|
|
129
|
+
} else t12 = $[37];
|
|
130
|
+
let t13;
|
|
131
|
+
if ($[38] !== control || $[39] !== label) {
|
|
132
|
+
t13 = /*#__PURE__*/ jsx(FieldLabelContext.Provider, {
|
|
133
|
+
value: label,
|
|
134
|
+
children: control
|
|
135
|
+
});
|
|
136
|
+
$[38] = control;
|
|
137
|
+
$[39] = label;
|
|
138
|
+
$[40] = t13;
|
|
139
|
+
} else t13 = $[40];
|
|
140
|
+
let t14;
|
|
141
|
+
if ($[41] !== formItem || $[42] !== message) {
|
|
142
|
+
t14 = formItem ? /*#__PURE__*/ jsx("div", {
|
|
143
|
+
"data-tao-form-message": "",
|
|
144
|
+
children: message
|
|
145
|
+
}) : message;
|
|
146
|
+
$[41] = formItem;
|
|
147
|
+
$[42] = message;
|
|
148
|
+
$[43] = t14;
|
|
149
|
+
} else t14 = $[43];
|
|
150
|
+
let t15;
|
|
151
|
+
if ($[44] !== t13 || $[45] !== t14) {
|
|
152
|
+
t15 = /*#__PURE__*/ jsxs("div", {
|
|
130
153
|
"data-tao-form-control": "",
|
|
131
154
|
children: [
|
|
132
|
-
|
|
133
|
-
|
|
155
|
+
t13,
|
|
156
|
+
t14
|
|
134
157
|
]
|
|
135
158
|
});
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
} else
|
|
140
|
-
let
|
|
141
|
-
if ($[
|
|
142
|
-
|
|
143
|
-
className:
|
|
144
|
-
style:
|
|
159
|
+
$[44] = t13;
|
|
160
|
+
$[45] = t14;
|
|
161
|
+
$[46] = t15;
|
|
162
|
+
} else t15 = $[46];
|
|
163
|
+
let t16;
|
|
164
|
+
if ($[47] !== t10 || $[48] !== t11 || $[49] !== t12 || $[50] !== t15 || $[51] !== t7 || $[52] !== t9) {
|
|
165
|
+
t16 = /*#__PURE__*/ jsxs("div", {
|
|
166
|
+
className: t7,
|
|
167
|
+
style: t9,
|
|
145
168
|
"data-tao-form-field": "",
|
|
146
|
-
"data-tao-
|
|
169
|
+
"data-tao-form-item": t10,
|
|
170
|
+
"data-tao-layout": t11,
|
|
147
171
|
children: [
|
|
148
|
-
|
|
149
|
-
|
|
172
|
+
t12,
|
|
173
|
+
t15
|
|
150
174
|
]
|
|
151
175
|
});
|
|
152
|
-
$[
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
|
|
159
|
-
|
|
176
|
+
$[47] = t10;
|
|
177
|
+
$[48] = t11;
|
|
178
|
+
$[49] = t12;
|
|
179
|
+
$[50] = t15;
|
|
180
|
+
$[51] = t7;
|
|
181
|
+
$[52] = t9;
|
|
182
|
+
$[53] = t16;
|
|
183
|
+
} else t16 = $[53];
|
|
184
|
+
return t16;
|
|
160
185
|
}
|
|
161
186
|
export { FormFieldView };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type InputHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { type TaoSize, type TaoStatus } from '../../provider/tao-provider.js';
|
|
3
|
+
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
|
|
4
|
+
import './input.css';
|
|
5
|
+
import { type InputFocusOptions, type InputSemanticValue, type InputVariant, type TextControlProps } from './input-shared.js';
|
|
6
|
+
export type InputSemanticPart = 'root' | 'input' | 'prefix' | 'suffix' | 'clear' | 'count' | 'addonBefore' | 'addonAfter';
|
|
7
|
+
export type InputRef = HTMLInputElement & {
|
|
8
|
+
input: HTMLInputElement;
|
|
9
|
+
nativeElement: HTMLDivElement;
|
|
10
|
+
focus: (options?: InputFocusOptions) => void;
|
|
11
|
+
};
|
|
12
|
+
export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'>, TextControlProps<HTMLInputElement> {
|
|
13
|
+
size?: TaoSize;
|
|
14
|
+
variant?: InputVariant;
|
|
15
|
+
prefix?: ReactNode;
|
|
16
|
+
suffix?: ReactNode;
|
|
17
|
+
/** Attached content before the input. Prefer composition for complex controls. */
|
|
18
|
+
addonBefore?: ReactNode;
|
|
19
|
+
addonAfter?: ReactNode;
|
|
20
|
+
error?: boolean;
|
|
21
|
+
status?: TaoStatus;
|
|
22
|
+
classNames?: InputSemanticValue<SemanticClassNames<InputSemanticPart>, InputProps>;
|
|
23
|
+
styles?: InputSemanticValue<SemanticStyles<InputSemanticPart>, InputProps>;
|
|
24
|
+
}
|
|
25
|
+
export declare const BaseInput: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useRef } from "react";
|
|
3
|
+
import { useTaoConfig } from "../../provider/tao-provider.js";
|
|
4
|
+
import { cx } from "../../utils/semantic.js";
|
|
5
|
+
import "./input.css";
|
|
6
|
+
import { InputClear, useTextControl, useTextControlRef } from "./input-shared.js";
|
|
7
|
+
const BaseInput = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
8
|
+
const { size, variant, prefix, suffix, error, status, disabled, className, style, classNames: customClassNames, styles: customStyles, allowClear, onClear, showCount, count, onPressEnter, addonBefore, addonAfter, onChange, onKeyDown, onCompositionStart, onCompositionEnd, value, defaultValue, ...rest } = props;
|
|
9
|
+
const classNames = 'function' == typeof customClassNames ? customClassNames({
|
|
10
|
+
props
|
|
11
|
+
}) : customClassNames;
|
|
12
|
+
const styles = 'function' == typeof customStyles ? customStyles({
|
|
13
|
+
props
|
|
14
|
+
}) : customStyles;
|
|
15
|
+
const innerRef = useRef(null);
|
|
16
|
+
const rootRef = useRef(null);
|
|
17
|
+
const field = useTextControl(props, innerRef);
|
|
18
|
+
useTextControlRef(ref, innerRef, rootRef);
|
|
19
|
+
const ctx = useTaoConfig();
|
|
20
|
+
const resolvedSize = size ?? ctx.size;
|
|
21
|
+
const resolvedVariant = variant ?? ctx.variant;
|
|
22
|
+
const resolvedDisabled = disabled ?? ctx.disabled;
|
|
23
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
24
|
+
ref: rootRef,
|
|
25
|
+
className: cx(classNames?.root, className),
|
|
26
|
+
style: {
|
|
27
|
+
...styles?.root,
|
|
28
|
+
...style
|
|
29
|
+
},
|
|
30
|
+
"data-tao-control": "",
|
|
31
|
+
"data-tao-input": "",
|
|
32
|
+
"data-tao-size": resolvedSize,
|
|
33
|
+
"data-tao-variant": resolvedVariant,
|
|
34
|
+
"data-tao-error": 'error' === status || error || void 0,
|
|
35
|
+
"data-tao-warning": 'warning' === status || void 0,
|
|
36
|
+
"data-disabled": resolvedDisabled || void 0,
|
|
37
|
+
children: [
|
|
38
|
+
null != addonBefore && /*#__PURE__*/ jsx("span", {
|
|
39
|
+
"data-tao-input-addon": "",
|
|
40
|
+
className: classNames?.addonBefore,
|
|
41
|
+
style: styles?.addonBefore,
|
|
42
|
+
children: addonBefore
|
|
43
|
+
}),
|
|
44
|
+
null != prefix && /*#__PURE__*/ jsx("span", {
|
|
45
|
+
className: classNames?.prefix,
|
|
46
|
+
style: styles?.prefix,
|
|
47
|
+
"data-tao-prefix": "",
|
|
48
|
+
children: prefix
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ jsx("input", {
|
|
51
|
+
...rest,
|
|
52
|
+
value: field.value,
|
|
53
|
+
ref: innerRef,
|
|
54
|
+
className: classNames?.input,
|
|
55
|
+
style: styles?.input,
|
|
56
|
+
disabled: resolvedDisabled,
|
|
57
|
+
"aria-invalid": 'error' === status || error ? true : rest['aria-invalid'],
|
|
58
|
+
onChange: field.change,
|
|
59
|
+
onKeyDown: (event)=>{
|
|
60
|
+
onKeyDown?.(event);
|
|
61
|
+
if ('Enter' === event.key && !event.defaultPrevented && !field.composing.current && !event.nativeEvent.isComposing && 229 !== event.keyCode) onPressEnter?.(event);
|
|
62
|
+
},
|
|
63
|
+
onCompositionStart: (event_0)=>{
|
|
64
|
+
field.composing.current = true;
|
|
65
|
+
onCompositionStart?.(event_0);
|
|
66
|
+
},
|
|
67
|
+
onCompositionEnd: (event_1)=>{
|
|
68
|
+
field.composing.current = false;
|
|
69
|
+
if (field.normalize(event_1.currentTarget.value) !== event_1.currentTarget.value) field.change({
|
|
70
|
+
...event_1,
|
|
71
|
+
target: event_1.currentTarget
|
|
72
|
+
});
|
|
73
|
+
onCompositionEnd?.(event_1);
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
allowClear && field.value && !resolvedDisabled && !rest.readOnly && /*#__PURE__*/ jsx(InputClear, {
|
|
77
|
+
config: allowClear,
|
|
78
|
+
onClick: field.clear,
|
|
79
|
+
className: classNames?.clear,
|
|
80
|
+
style: styles?.clear
|
|
81
|
+
}),
|
|
82
|
+
null != suffix && /*#__PURE__*/ jsx("span", {
|
|
83
|
+
className: classNames?.suffix,
|
|
84
|
+
style: styles?.suffix,
|
|
85
|
+
"data-tao-suffix": "",
|
|
86
|
+
children: suffix
|
|
87
|
+
}),
|
|
88
|
+
null != field.counter && /*#__PURE__*/ jsx("span", {
|
|
89
|
+
"data-tao-input-count": "",
|
|
90
|
+
"data-tao-exceeded": field.exceeded || void 0,
|
|
91
|
+
className: classNames?.count,
|
|
92
|
+
style: styles?.count,
|
|
93
|
+
children: field.counter
|
|
94
|
+
}),
|
|
95
|
+
null != addonAfter && /*#__PURE__*/ jsx("span", {
|
|
96
|
+
"data-tao-input-addon": "",
|
|
97
|
+
className: classNames?.addonAfter,
|
|
98
|
+
style: styles?.addonAfter,
|
|
99
|
+
children: addonAfter
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
export { BaseInput };
|