@rockshin/tao-ui 0.0.42 → 0.0.44
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 +8 -2
- package/component-manifest.json +37 -18
- 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/field-control.d.ts +6 -0
- package/dist/components/form/field-control.js +42 -0
- package/dist/components/form/form-context.d.ts +3 -0
- package/dist/components/form/form-item.d.ts +2 -1
- package/dist/components/form/form-item.js +56 -42
- package/dist/components/form/form.css +15 -0
- package/dist/components/form/form.d.ts +5 -5
- package/dist/components/form/form.js +87 -68
- package/dist/components/form/index.d.ts +1 -0
- package/dist/components/form/use-form.d.ts +16 -0
- package/dist/components/form/use-form.js +69 -0
- package/dist/components/form-field/form-field-view.d.ts +6 -2
- package/dist/components/form-field/form-field-view.js +116 -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/form.doc.js +3 -1
- 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/form.d.ts +2 -2
- package/dist/entries/input.d.ts +1 -1
- package/dist/entries/textarea.d.ts +1 -1
- package/dist/index.d.ts +5 -5
- 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 +19 -16
- package/package.json +10 -5
- 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
|
})
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
/** Register the actual control, including noStyle and Form.List fields. */
|
|
3
|
+
export declare function FieldControl({ name, children, }: {
|
|
4
|
+
name: (string | number)[];
|
|
5
|
+
children: ReactElement<Record<string, unknown>>;
|
|
6
|
+
}): ReactElement<Record<string, unknown>, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getNodeRef, supportNodeRef } from "@rc-component/util/es/ref";
|
|
2
|
+
import useLayoutEffect from "@rc-component/util/es/hooks/useLayoutEffect";
|
|
3
|
+
import { cloneElement, useId, useMemo } from "react";
|
|
4
|
+
import { mergeRefs } from "../../utils/refs.js";
|
|
5
|
+
import { useFormLayout } from "./form-context.js";
|
|
6
|
+
import { fieldKey } from "./use-form.js";
|
|
7
|
+
function FieldControl({ name, children }) {
|
|
8
|
+
const { fields } = useFormLayout();
|
|
9
|
+
const generatedId = useId();
|
|
10
|
+
const id = 'string' == typeof children.props.id ? children.props.id : `${generatedId}-control`;
|
|
11
|
+
const key = fieldKey(name);
|
|
12
|
+
const target = useMemo(()=>({
|
|
13
|
+
id,
|
|
14
|
+
instance: null
|
|
15
|
+
}), [
|
|
16
|
+
id
|
|
17
|
+
]);
|
|
18
|
+
const childRef = getNodeRef(children);
|
|
19
|
+
const ref = useMemo(()=>mergeRefs((instance)=>{
|
|
20
|
+
target.instance = instance;
|
|
21
|
+
}, childRef), [
|
|
22
|
+
target,
|
|
23
|
+
childRef
|
|
24
|
+
]);
|
|
25
|
+
useLayoutEffect(()=>{
|
|
26
|
+
fields?.set(key, target);
|
|
27
|
+
return ()=>{
|
|
28
|
+
fields?.delete(key);
|
|
29
|
+
};
|
|
30
|
+
}, [
|
|
31
|
+
fields,
|
|
32
|
+
key,
|
|
33
|
+
target
|
|
34
|
+
]);
|
|
35
|
+
return /*#__PURE__*/ cloneElement(children, {
|
|
36
|
+
id,
|
|
37
|
+
...supportNodeRef(children) ? {
|
|
38
|
+
ref
|
|
39
|
+
} : {}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export { FieldControl };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { FormFieldLayout } from '../form-field/form-field-view.js';
|
|
2
|
+
import type { FieldTarget, FormInstance } from './use-form.js';
|
|
2
3
|
export interface FormLayoutContextValue {
|
|
3
4
|
layout: FormFieldLayout;
|
|
5
|
+
form?: FormInstance;
|
|
6
|
+
fields?: Map<string, FieldTarget>;
|
|
4
7
|
}
|
|
5
8
|
/** Internal layout channel: Form → Form.Item. */
|
|
6
9
|
export declare const FormLayoutContext: import("react").Context<FormLayoutContextValue>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Meta, type NamePath, type Rule } from '@rc-component/form';
|
|
2
2
|
import { type CSSProperties, type ReactNode } from 'react';
|
|
3
3
|
import type { TaoStatus } from '../../provider/tao-provider.js';
|
|
4
4
|
import type { SemanticClassNames, SemanticStyles } from '../../utils/semantic.js';
|
|
5
|
+
import type { FormInstance } from './use-form.js';
|
|
5
6
|
export type FormItemSemanticPart = 'root' | 'label' | 'error' | 'description';
|
|
6
7
|
export type FormItemValidateStatus = TaoStatus;
|
|
7
8
|
export type FormItemChildren<Values = Record<string, unknown>> = ReactNode | ((control: Record<string, unknown>, meta: Meta, form: FormInstance<Values>) => ReactNode);
|
|
@@ -4,10 +4,11 @@ import { Field } from "@rc-component/form";
|
|
|
4
4
|
import { cloneElement, isValidElement } from "react";
|
|
5
5
|
import { FormFieldView } from "../form-field/form-field-view.js";
|
|
6
6
|
import { useFormLayout } from "./form-context.js";
|
|
7
|
+
import { FieldControl } from "./field-control.js";
|
|
7
8
|
function FormItem(t0) {
|
|
8
|
-
const $ = c(
|
|
9
|
+
const $ = c(41);
|
|
9
10
|
const { name, label, required, rules, help, extra, validateStatus, initialValue, valuePropName, getValueFromEvent, trigger, validateTrigger, noStyle, dependencies, shouldUpdate, normalize, preserve, messageVariables, validateFirst, htmlFor, className, style, classNames, styles, children } = t0;
|
|
10
|
-
const { layout } = useFormLayout();
|
|
11
|
+
const { layout, form: formInstance } = useFormLayout();
|
|
11
12
|
let t1;
|
|
12
13
|
if ($[0] !== required || $[1] !== rules) {
|
|
13
14
|
t1 = required ?? rules?.some(_temp) ?? false;
|
|
@@ -17,7 +18,7 @@ function FormItem(t0) {
|
|
|
17
18
|
} else t1 = $[2];
|
|
18
19
|
const requiredMark = t1;
|
|
19
20
|
let t2;
|
|
20
|
-
if ($[3] !== className || $[4] !== classNames || $[5] !== extra || $[6] !== help || $[7] !== htmlFor || $[8] !== label || $[9] !== layout || $[10] !==
|
|
21
|
+
if ($[3] !== className || $[4] !== classNames || $[5] !== extra || $[6] !== help || $[7] !== htmlFor || $[8] !== label || $[9] !== layout || $[10] !== name || $[11] !== noStyle || $[12] !== requiredMark || $[13] !== style || $[14] !== styles || $[15] !== validateStatus || $[16] !== valuePropName) {
|
|
21
22
|
t2 = (content, meta, control)=>{
|
|
22
23
|
const status = validateStatus ?? (meta?.errors.length ? "error" : meta?.warnings.length ? "warning" : void 0);
|
|
23
24
|
const message = help ?? meta?.errors[0] ?? meta?.warnings[0];
|
|
@@ -37,8 +38,15 @@ function FormItem(t0) {
|
|
|
37
38
|
...controlProps,
|
|
38
39
|
value: ""
|
|
39
40
|
};
|
|
40
|
-
if (noStyle)
|
|
41
|
+
if (noStyle) {
|
|
42
|
+
const child = /*#__PURE__*/ isValidElement(content) && controlProps ? /*#__PURE__*/ cloneElement(content, controlProps) : content;
|
|
43
|
+
return null != name && meta && /*#__PURE__*/ isValidElement(child) ? /*#__PURE__*/ jsx(FieldControl, {
|
|
44
|
+
name: meta.name,
|
|
45
|
+
children: child
|
|
46
|
+
}) : child;
|
|
47
|
+
}
|
|
41
48
|
return /*#__PURE__*/ jsx(FormFieldView, {
|
|
49
|
+
formItem: true,
|
|
42
50
|
label: label,
|
|
43
51
|
htmlFor: htmlFor,
|
|
44
52
|
required: requiredMark,
|
|
@@ -47,6 +55,10 @@ function FormItem(t0) {
|
|
|
47
55
|
description: descriptionSlot,
|
|
48
56
|
layout: layout,
|
|
49
57
|
controlProps: controlProps,
|
|
58
|
+
renderControl: null != name && meta ? (child_0)=>/*#__PURE__*/ jsx(FieldControl, {
|
|
59
|
+
name: meta.name,
|
|
60
|
+
children: child_0
|
|
61
|
+
}) : void 0,
|
|
50
62
|
className: className,
|
|
51
63
|
style: style,
|
|
52
64
|
classNames: classNames,
|
|
@@ -61,40 +73,42 @@ function FormItem(t0) {
|
|
|
61
73
|
$[7] = htmlFor;
|
|
62
74
|
$[8] = label;
|
|
63
75
|
$[9] = layout;
|
|
64
|
-
$[10] =
|
|
65
|
-
$[11] =
|
|
66
|
-
$[12] =
|
|
67
|
-
$[13] =
|
|
68
|
-
$[14] =
|
|
69
|
-
$[15] =
|
|
70
|
-
$[16] =
|
|
71
|
-
|
|
76
|
+
$[10] = name;
|
|
77
|
+
$[11] = noStyle;
|
|
78
|
+
$[12] = requiredMark;
|
|
79
|
+
$[13] = style;
|
|
80
|
+
$[14] = styles;
|
|
81
|
+
$[15] = validateStatus;
|
|
82
|
+
$[16] = valuePropName;
|
|
83
|
+
$[17] = t2;
|
|
84
|
+
} else t2 = $[17];
|
|
72
85
|
const renderShell = t2;
|
|
73
86
|
if (null == name && null == dependencies && null == shouldUpdate) {
|
|
74
87
|
const t3 = children;
|
|
75
88
|
let t4;
|
|
76
|
-
if ($[
|
|
89
|
+
if ($[18] !== renderShell || $[19] !== t3) {
|
|
77
90
|
t4 = renderShell(t3, void 0, null);
|
|
78
|
-
$[
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
} else t4 = $[
|
|
91
|
+
$[18] = renderShell;
|
|
92
|
+
$[19] = t3;
|
|
93
|
+
$[20] = t4;
|
|
94
|
+
} else t4 = $[20];
|
|
82
95
|
return t4;
|
|
83
96
|
}
|
|
84
97
|
const t3 = name ?? void 0;
|
|
85
98
|
let t4;
|
|
86
|
-
if ($[
|
|
87
|
-
t4 = (control_0, meta_0
|
|
88
|
-
const content_0 = "function" == typeof children ? children(control_0, meta_0,
|
|
99
|
+
if ($[21] !== children || $[22] !== formInstance || $[23] !== name || $[24] !== renderShell) {
|
|
100
|
+
t4 = (control_0, meta_0)=>{
|
|
101
|
+
const content_0 = "function" == typeof children ? children(control_0, meta_0, formInstance) : children;
|
|
89
102
|
return renderShell(content_0, meta_0, null != name ? control_0 : null);
|
|
90
103
|
};
|
|
91
|
-
$[
|
|
92
|
-
$[
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
|
|
104
|
+
$[21] = children;
|
|
105
|
+
$[22] = formInstance;
|
|
106
|
+
$[23] = name;
|
|
107
|
+
$[24] = renderShell;
|
|
108
|
+
$[25] = t4;
|
|
109
|
+
} else t4 = $[25];
|
|
96
110
|
let t5;
|
|
97
|
-
if ($[
|
|
111
|
+
if ($[26] !== dependencies || $[27] !== getValueFromEvent || $[28] !== initialValue || $[29] !== messageVariables || $[30] !== normalize || $[31] !== preserve || $[32] !== rules || $[33] !== shouldUpdate || $[34] !== t3 || $[35] !== t4 || $[36] !== trigger || $[37] !== validateFirst || $[38] !== validateTrigger || $[39] !== valuePropName) {
|
|
98
112
|
t5 = /*#__PURE__*/ jsx(Field, {
|
|
99
113
|
name: t3,
|
|
100
114
|
rules: rules,
|
|
@@ -111,22 +125,22 @@ function FormItem(t0) {
|
|
|
111
125
|
validateFirst: validateFirst,
|
|
112
126
|
children: t4
|
|
113
127
|
});
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
120
|
-
$[
|
|
121
|
-
$[
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
128
|
-
$[
|
|
129
|
-
} else t5 = $[
|
|
128
|
+
$[26] = dependencies;
|
|
129
|
+
$[27] = getValueFromEvent;
|
|
130
|
+
$[28] = initialValue;
|
|
131
|
+
$[29] = messageVariables;
|
|
132
|
+
$[30] = normalize;
|
|
133
|
+
$[31] = preserve;
|
|
134
|
+
$[32] = rules;
|
|
135
|
+
$[33] = shouldUpdate;
|
|
136
|
+
$[34] = t3;
|
|
137
|
+
$[35] = t4;
|
|
138
|
+
$[36] = trigger;
|
|
139
|
+
$[37] = validateFirst;
|
|
140
|
+
$[38] = validateTrigger;
|
|
141
|
+
$[39] = valuePropName;
|
|
142
|
+
$[40] = t5;
|
|
143
|
+
} else t5 = $[40];
|
|
130
144
|
return t5;
|
|
131
145
|
}
|
|
132
146
|
function _temp(rule) {
|
|
@@ -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);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { List, type FormProps as RcFormProps, useWatch } from '@rc-component/form';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
3
|
import { type TaoSize } from '../../provider/tao-provider.js';
|
|
4
4
|
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
|
|
5
5
|
import { FormItem, type FormItemProps } from './form-item.js';
|
|
6
|
+
import { type FormInstance, useForm } from './use-form.js';
|
|
6
7
|
import './form.css';
|
|
7
8
|
export type FormSemanticPart = 'root';
|
|
8
|
-
export interface FormProps<Values = Record<string, unknown>> extends Omit<RcFormProps<Values>, 'component'> {
|
|
9
|
+
export interface FormProps<Values = Record<string, unknown>> extends Omit<RcFormProps<Values>, 'component' | 'form'> {
|
|
10
|
+
form?: FormInstance<Values>;
|
|
9
11
|
/** Label/control arrangement inherited by Form.Item. Defaults to 'vertical'. */
|
|
10
12
|
layout?: 'vertical' | 'horizontal';
|
|
11
13
|
/** Cascades a control size to everything inside the form. */
|
|
@@ -17,9 +19,7 @@ export interface FormProps<Values = Record<string, unknown>> extends Omit<RcForm
|
|
|
17
19
|
styles?: SemanticStyles<FormSemanticPart>;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
|
-
* Returns the instance of the enclosing Form
|
|
21
|
-
* InternalFormInstance (a superset of FormInstance), same source antd's
|
|
22
|
-
* useFormInstance reads from.
|
|
22
|
+
* Returns the enhanced instance of the enclosing Form.
|
|
23
23
|
*/
|
|
24
24
|
declare function useFormInstance<Values = Record<string, unknown>>(): FormInstance<Values>;
|
|
25
25
|
export declare const Form: (<Values = Record<string, unknown>>(props: FormProps<Values> & {
|