@rockshin/tao-ui 0.0.25 → 0.0.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/README.md +17 -6
- package/component-manifest.json +534 -6
- package/dist/components/alert/alert.css +120 -0
- package/dist/components/alert/alert.d.ts +20 -0
- package/dist/components/alert/alert.js +185 -0
- package/dist/components/button/button.css +19 -18
- package/dist/components/button/button.d.ts +8 -0
- package/dist/components/date-picker/date-picker.d.ts +1 -1
- package/dist/components/date-picker/date-picker.js +57 -43
- package/dist/components/date-picker/range-picker.js +68 -23
- package/dist/components/dropdown/dropdown.css +22 -1
- package/dist/components/dropdown/dropdown.js +4 -3
- package/dist/components/form/form-context.d.ts +7 -0
- package/dist/components/form/form-context.js +8 -0
- package/dist/components/form/form-item.d.ts +55 -0
- package/dist/components/form/form-item.js +131 -0
- package/dist/components/form/form.css +22 -0
- package/dist/components/form/form.d.ts +35 -0
- package/dist/components/form/form.js +125 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +1 -0
- package/dist/components/form-field/form-field-view.d.ts +30 -0
- package/dist/components/form-field/form-field-view.js +154 -0
- package/dist/components/form-field/form-field.d.ts +2 -2
- package/dist/components/form-field/form-field.js +29 -137
- package/dist/components/form-field/form.css +17 -7
- package/dist/components/input/input.css +6 -6
- package/dist/components/modal/confirm-dialog.js +14 -111
- package/dist/components/modal/modal.d.ts +7 -1
- package/dist/components/modal/modal.js +205 -195
- package/dist/components/popconfirm/popconfirm.css +44 -0
- package/dist/components/popconfirm/popconfirm.d.ts +41 -0
- package/dist/components/popconfirm/popconfirm.js +238 -0
- package/dist/components/popover/popover.css +105 -0
- package/dist/components/popover/popover.d.ts +41 -0
- package/dist/components/popover/popover.js +412 -0
- package/dist/components/select/mobile-select.js +9 -20
- package/dist/components/select/select-model.d.ts +7 -1
- package/dist/components/select/select-model.js +30 -7
- package/dist/components/select/select.js +49 -38
- package/dist/components/sonner/sonner.d.ts +2 -1
- package/dist/components/sonner/sonner.js +74 -81
- package/dist/components/status-icon/status-icon.d.ts +5 -0
- package/dist/components/status-icon/status-icon.js +77 -0
- package/dist/components/table/table-types.d.ts +7 -0
- package/dist/components/table/table.d.ts +1 -1
- package/dist/components/table/table.js +296 -283
- package/dist/components/tooltip/tooltip.css +93 -0
- package/dist/components/tooltip/tooltip.d.ts +33 -0
- package/dist/components/tooltip/tooltip.js +226 -0
- package/dist/docs/component-docs.js +11 -1
- package/dist/docs/components/alert.doc.d.ts +29 -0
- package/dist/docs/components/alert.doc.js +93 -0
- package/dist/docs/components/form.doc.d.ts +29 -0
- package/dist/docs/components/form.doc.js +71 -0
- package/dist/docs/components/modal.doc.d.ts +6 -0
- package/dist/docs/components/modal.doc.js +9 -1
- package/dist/docs/components/popconfirm.doc.d.ts +29 -0
- package/dist/docs/components/popconfirm.doc.js +132 -0
- package/dist/docs/components/popover.doc.d.ts +29 -0
- package/dist/docs/components/popover.doc.js +121 -0
- package/dist/docs/components/stack.doc.d.ts +6 -0
- package/dist/docs/components/stack.doc.js +23 -2
- package/dist/docs/components/table.doc.js +2 -1
- package/dist/docs/components/tao-provider.doc.js +11 -1
- package/dist/docs/components/tooltip.doc.d.ts +37 -0
- package/dist/docs/components/tooltip.doc.js +76 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +8 -1
- package/dist/layouts/stack/stack.d.ts +12 -3
- package/dist/layouts/stack/stack.js +60 -34
- package/dist/provider/tao-provider.d.ts +71 -0
- package/dist/provider/tao-provider.js +166 -120
- package/dist/theme/control.css +12 -12
- package/dist/theme/theme.css +23 -0
- package/dist/utils/breakpoint.d.ts +31 -0
- package/dist/utils/breakpoint.js +80 -0
- package/dist/utils/overlay.d.ts +19 -0
- package/dist/utils/overlay.js +41 -0
- package/llms.txt +68 -3
- package/package.json +6 -4
- package/dist/components/select/use-is-mobile.d.ts +0 -1
- package/dist/components/select/use-is-mobile.js +0 -27
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Field } from "@rc-component/form";
|
|
4
|
+
import { cloneElement, isValidElement } from "react";
|
|
5
|
+
import { FormFieldView } from "../form-field/form-field-view.js";
|
|
6
|
+
import { useFormLayout } from "./form-context.js";
|
|
7
|
+
function FormItem(t0) {
|
|
8
|
+
const $ = c(39);
|
|
9
|
+
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
|
+
let t1;
|
|
12
|
+
if ($[0] !== required || $[1] !== rules) {
|
|
13
|
+
t1 = required ?? rules?.some(_temp) ?? false;
|
|
14
|
+
$[0] = required;
|
|
15
|
+
$[1] = rules;
|
|
16
|
+
$[2] = t1;
|
|
17
|
+
} else t1 = $[2];
|
|
18
|
+
const requiredMark = t1;
|
|
19
|
+
let t2;
|
|
20
|
+
if ($[3] !== className || $[4] !== classNames || $[5] !== extra || $[6] !== help || $[7] !== htmlFor || $[8] !== label || $[9] !== layout || $[10] !== noStyle || $[11] !== requiredMark || $[12] !== style || $[13] !== styles || $[14] !== validateStatus || $[15] !== valuePropName) {
|
|
21
|
+
t2 = (content, meta, control)=>{
|
|
22
|
+
const status = validateStatus ?? (meta?.errors.length ? "error" : void 0);
|
|
23
|
+
const message = help ?? meta?.errors[0];
|
|
24
|
+
const showAsStatus = null != message && null != status;
|
|
25
|
+
const errorSlot = showAsStatus ? message : void 0;
|
|
26
|
+
const descriptionSlot = extra ?? (showAsStatus ? void 0 : message);
|
|
27
|
+
let controlProps = control ?? void 0;
|
|
28
|
+
if (controlProps && status && /*#__PURE__*/ isValidElement(content) && "string" != typeof content.type && null == content.props.status && null == content.props.error) controlProps = {
|
|
29
|
+
...controlProps,
|
|
30
|
+
status
|
|
31
|
+
};
|
|
32
|
+
if (controlProps && null == valuePropName && void 0 === controlProps.value) controlProps = {
|
|
33
|
+
...controlProps,
|
|
34
|
+
value: ""
|
|
35
|
+
};
|
|
36
|
+
if (noStyle) return /*#__PURE__*/ isValidElement(content) && controlProps ? /*#__PURE__*/ cloneElement(content, controlProps) : content;
|
|
37
|
+
return /*#__PURE__*/ jsx(FormFieldView, {
|
|
38
|
+
label: label,
|
|
39
|
+
htmlFor: htmlFor,
|
|
40
|
+
required: requiredMark,
|
|
41
|
+
error: errorSlot,
|
|
42
|
+
warning: "warning" === status,
|
|
43
|
+
description: descriptionSlot,
|
|
44
|
+
layout: layout,
|
|
45
|
+
controlProps: controlProps,
|
|
46
|
+
className: className,
|
|
47
|
+
style: style,
|
|
48
|
+
classNames: classNames,
|
|
49
|
+
styles: styles,
|
|
50
|
+
children: content
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
$[3] = className;
|
|
54
|
+
$[4] = classNames;
|
|
55
|
+
$[5] = extra;
|
|
56
|
+
$[6] = help;
|
|
57
|
+
$[7] = htmlFor;
|
|
58
|
+
$[8] = label;
|
|
59
|
+
$[9] = layout;
|
|
60
|
+
$[10] = noStyle;
|
|
61
|
+
$[11] = requiredMark;
|
|
62
|
+
$[12] = style;
|
|
63
|
+
$[13] = styles;
|
|
64
|
+
$[14] = validateStatus;
|
|
65
|
+
$[15] = valuePropName;
|
|
66
|
+
$[16] = t2;
|
|
67
|
+
} else t2 = $[16];
|
|
68
|
+
const renderShell = t2;
|
|
69
|
+
if (null == name && null == dependencies && null == shouldUpdate) {
|
|
70
|
+
const t3 = children;
|
|
71
|
+
let t4;
|
|
72
|
+
if ($[17] !== renderShell || $[18] !== t3) {
|
|
73
|
+
t4 = renderShell(t3, void 0, null);
|
|
74
|
+
$[17] = renderShell;
|
|
75
|
+
$[18] = t3;
|
|
76
|
+
$[19] = t4;
|
|
77
|
+
} else t4 = $[19];
|
|
78
|
+
return t4;
|
|
79
|
+
}
|
|
80
|
+
const t3 = name ?? void 0;
|
|
81
|
+
let t4;
|
|
82
|
+
if ($[20] !== children || $[21] !== name || $[22] !== renderShell) {
|
|
83
|
+
t4 = (control_0, meta_0, form)=>{
|
|
84
|
+
const content_0 = "function" == typeof children ? children(control_0, meta_0, form) : children;
|
|
85
|
+
return renderShell(content_0, meta_0, null != name ? control_0 : null);
|
|
86
|
+
};
|
|
87
|
+
$[20] = children;
|
|
88
|
+
$[21] = name;
|
|
89
|
+
$[22] = renderShell;
|
|
90
|
+
$[23] = t4;
|
|
91
|
+
} else t4 = $[23];
|
|
92
|
+
let t5;
|
|
93
|
+
if ($[24] !== dependencies || $[25] !== getValueFromEvent || $[26] !== initialValue || $[27] !== messageVariables || $[28] !== normalize || $[29] !== preserve || $[30] !== rules || $[31] !== shouldUpdate || $[32] !== t3 || $[33] !== t4 || $[34] !== trigger || $[35] !== validateFirst || $[36] !== validateTrigger || $[37] !== valuePropName) {
|
|
94
|
+
t5 = /*#__PURE__*/ jsx(Field, {
|
|
95
|
+
name: t3,
|
|
96
|
+
rules: rules,
|
|
97
|
+
initialValue: initialValue,
|
|
98
|
+
valuePropName: valuePropName,
|
|
99
|
+
getValueFromEvent: getValueFromEvent,
|
|
100
|
+
trigger: trigger,
|
|
101
|
+
validateTrigger: validateTrigger,
|
|
102
|
+
dependencies: dependencies,
|
|
103
|
+
shouldUpdate: shouldUpdate,
|
|
104
|
+
normalize: normalize,
|
|
105
|
+
preserve: preserve,
|
|
106
|
+
messageVariables: messageVariables,
|
|
107
|
+
validateFirst: validateFirst,
|
|
108
|
+
children: t4
|
|
109
|
+
});
|
|
110
|
+
$[24] = dependencies;
|
|
111
|
+
$[25] = getValueFromEvent;
|
|
112
|
+
$[26] = initialValue;
|
|
113
|
+
$[27] = messageVariables;
|
|
114
|
+
$[28] = normalize;
|
|
115
|
+
$[29] = preserve;
|
|
116
|
+
$[30] = rules;
|
|
117
|
+
$[31] = shouldUpdate;
|
|
118
|
+
$[32] = t3;
|
|
119
|
+
$[33] = t4;
|
|
120
|
+
$[34] = trigger;
|
|
121
|
+
$[35] = validateFirst;
|
|
122
|
+
$[36] = validateTrigger;
|
|
123
|
+
$[37] = valuePropName;
|
|
124
|
+
$[38] = t5;
|
|
125
|
+
} else t5 = $[38];
|
|
126
|
+
return t5;
|
|
127
|
+
}
|
|
128
|
+
function _temp(rule) {
|
|
129
|
+
return "object" == typeof rule && null != rule && "required" in rule && Boolean(rule.required);
|
|
130
|
+
}
|
|
131
|
+
export { FormItem };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[data-tao-form-field][data-tao-layout="horizontal"] {
|
|
2
|
+
align-items: flex-start;
|
|
3
|
+
gap: var(--tao-padding-sm);
|
|
4
|
+
flex-direction: row;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
[data-tao-form-field][data-tao-layout="horizontal"] [data-tao-form-label] {
|
|
8
|
+
text-align: end;
|
|
9
|
+
flex: 0 0 160px;
|
|
10
|
+
margin-block-end: 0;
|
|
11
|
+
padding-block-start: calc((
|
|
12
|
+
var(--tao-control-height) -
|
|
13
|
+
var(--tao-form-field-label-font-size, var(--tao-font-size-sm)) *
|
|
14
|
+
var(--tao-line-height-sm)
|
|
15
|
+
) /
|
|
16
|
+
2);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
[data-tao-form-field][data-tao-layout="horizontal"] [data-tao-form-control] {
|
|
20
|
+
flex: 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type FormInstance, List, type FormProps as RcFormProps, useForm, useWatch } from '@rc-component/form';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import { type TaoSize } from '../../provider/tao-provider';
|
|
4
|
+
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic';
|
|
5
|
+
import { FormItem, type FormItemProps } from './form-item';
|
|
6
|
+
import './form.css';
|
|
7
|
+
export type FormSemanticPart = 'root';
|
|
8
|
+
export interface FormProps<Values = Record<string, unknown>> extends Omit<RcFormProps<Values>, 'component'> {
|
|
9
|
+
/** Label/control arrangement inherited by Form.Item. Defaults to 'vertical'. */
|
|
10
|
+
layout?: 'vertical' | 'horizontal';
|
|
11
|
+
/** Cascades a control size to everything inside the form. */
|
|
12
|
+
size?: TaoSize;
|
|
13
|
+
/** Disables every tao-ui control inside the form (e.g. while submitting). */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
classNames?: SemanticClassNames<FormSemanticPart>;
|
|
17
|
+
styles?: SemanticStyles<FormSemanticPart>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns the instance of the enclosing Form — the rc FieldContext holds the
|
|
21
|
+
* InternalFormInstance (a superset of FormInstance), same source antd's
|
|
22
|
+
* useFormInstance reads from.
|
|
23
|
+
*/
|
|
24
|
+
declare function useFormInstance<Values = Record<string, unknown>>(): FormInstance<Values>;
|
|
25
|
+
export declare const Form: (<Values = Record<string, unknown>>(props: FormProps<Values> & {
|
|
26
|
+
ref?: React.Ref<FormInstance<Values>>;
|
|
27
|
+
}) => React.ReactElement) & {
|
|
28
|
+
Item: typeof FormItem;
|
|
29
|
+
List: typeof List;
|
|
30
|
+
Provider: import("react").FunctionComponent<import("@rc-component/form").FormProviderProps>;
|
|
31
|
+
useForm: typeof useForm;
|
|
32
|
+
useWatch: typeof useWatch;
|
|
33
|
+
useFormInstance: typeof useFormInstance;
|
|
34
|
+
};
|
|
35
|
+
export type { FormItemProps };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import _rc_component_form, { FieldContext, FormProvider, List, useForm, useWatch } from "@rc-component/form";
|
|
4
|
+
import { forwardRef, useContext } from "react";
|
|
5
|
+
import { TaoProvider } from "../../provider/tao-provider.js";
|
|
6
|
+
import { cx } from "../../utils/semantic.js";
|
|
7
|
+
import { FormLayoutContext } from "./form-context.js";
|
|
8
|
+
import { FormItem } from "./form-item.js";
|
|
9
|
+
import "./form.css";
|
|
10
|
+
function FormInner(t0, ref) {
|
|
11
|
+
const $ = c(31);
|
|
12
|
+
let children;
|
|
13
|
+
let className;
|
|
14
|
+
let classNames;
|
|
15
|
+
let disabled;
|
|
16
|
+
let rcProps;
|
|
17
|
+
let size;
|
|
18
|
+
let style;
|
|
19
|
+
let styles;
|
|
20
|
+
let t1;
|
|
21
|
+
if ($[0] !== t0) {
|
|
22
|
+
({ layout: t1, size, disabled, children, className, style, classNames, styles, ...rcProps } = t0);
|
|
23
|
+
$[0] = t0;
|
|
24
|
+
$[1] = children;
|
|
25
|
+
$[2] = className;
|
|
26
|
+
$[3] = classNames;
|
|
27
|
+
$[4] = disabled;
|
|
28
|
+
$[5] = rcProps;
|
|
29
|
+
$[6] = size;
|
|
30
|
+
$[7] = style;
|
|
31
|
+
$[8] = styles;
|
|
32
|
+
$[9] = t1;
|
|
33
|
+
} else {
|
|
34
|
+
children = $[1];
|
|
35
|
+
className = $[2];
|
|
36
|
+
classNames = $[3];
|
|
37
|
+
disabled = $[4];
|
|
38
|
+
rcProps = $[5];
|
|
39
|
+
size = $[6];
|
|
40
|
+
style = $[7];
|
|
41
|
+
styles = $[8];
|
|
42
|
+
t1 = $[9];
|
|
43
|
+
}
|
|
44
|
+
const layout = void 0 === t1 ? "vertical" : t1;
|
|
45
|
+
let t2;
|
|
46
|
+
if ($[10] !== layout) {
|
|
47
|
+
t2 = {
|
|
48
|
+
layout
|
|
49
|
+
};
|
|
50
|
+
$[10] = layout;
|
|
51
|
+
$[11] = t2;
|
|
52
|
+
} else t2 = $[11];
|
|
53
|
+
const layoutValue = t2;
|
|
54
|
+
const t3 = classNames?.root;
|
|
55
|
+
let t4;
|
|
56
|
+
if ($[12] !== className || $[13] !== t3) {
|
|
57
|
+
t4 = cx(t3, className);
|
|
58
|
+
$[12] = className;
|
|
59
|
+
$[13] = t3;
|
|
60
|
+
$[14] = t4;
|
|
61
|
+
} else t4 = $[14];
|
|
62
|
+
const t5 = styles?.root;
|
|
63
|
+
let t6;
|
|
64
|
+
if ($[15] !== style || $[16] !== t5) {
|
|
65
|
+
t6 = {
|
|
66
|
+
...t5,
|
|
67
|
+
...style
|
|
68
|
+
};
|
|
69
|
+
$[15] = style;
|
|
70
|
+
$[16] = t5;
|
|
71
|
+
$[17] = t6;
|
|
72
|
+
} else t6 = $[17];
|
|
73
|
+
let t7;
|
|
74
|
+
if ($[18] !== children || $[19] !== rcProps || $[20] !== ref || $[21] !== t4 || $[22] !== t6) {
|
|
75
|
+
t7 = /*#__PURE__*/ jsx(_rc_component_form, {
|
|
76
|
+
ref: ref,
|
|
77
|
+
className: t4,
|
|
78
|
+
style: t6,
|
|
79
|
+
...rcProps,
|
|
80
|
+
children: children
|
|
81
|
+
});
|
|
82
|
+
$[18] = children;
|
|
83
|
+
$[19] = rcProps;
|
|
84
|
+
$[20] = ref;
|
|
85
|
+
$[21] = t4;
|
|
86
|
+
$[22] = t6;
|
|
87
|
+
$[23] = t7;
|
|
88
|
+
} else t7 = $[23];
|
|
89
|
+
let t8;
|
|
90
|
+
if ($[24] !== disabled || $[25] !== size || $[26] !== t7) {
|
|
91
|
+
t8 = /*#__PURE__*/ jsx(TaoProvider, {
|
|
92
|
+
size: size,
|
|
93
|
+
disabled: disabled,
|
|
94
|
+
children: t7
|
|
95
|
+
});
|
|
96
|
+
$[24] = disabled;
|
|
97
|
+
$[25] = size;
|
|
98
|
+
$[26] = t7;
|
|
99
|
+
$[27] = t8;
|
|
100
|
+
} else t8 = $[27];
|
|
101
|
+
let t9;
|
|
102
|
+
if ($[28] !== layoutValue || $[29] !== t8) {
|
|
103
|
+
t9 = /*#__PURE__*/ jsx(FormLayoutContext.Provider, {
|
|
104
|
+
value: layoutValue,
|
|
105
|
+
children: t8
|
|
106
|
+
});
|
|
107
|
+
$[28] = layoutValue;
|
|
108
|
+
$[29] = t8;
|
|
109
|
+
$[30] = t9;
|
|
110
|
+
} else t9 = $[30];
|
|
111
|
+
return t9;
|
|
112
|
+
}
|
|
113
|
+
const ForwardedForm = /*#__PURE__*/ forwardRef(FormInner);
|
|
114
|
+
function useFormInstance() {
|
|
115
|
+
return useContext(FieldContext);
|
|
116
|
+
}
|
|
117
|
+
const Form = Object.assign(ForwardedForm, {
|
|
118
|
+
Item: FormItem,
|
|
119
|
+
List: List,
|
|
120
|
+
Provider: FormProvider,
|
|
121
|
+
useForm: useForm,
|
|
122
|
+
useWatch: useWatch,
|
|
123
|
+
useFormInstance: useFormInstance
|
|
124
|
+
});
|
|
125
|
+
export { Form };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Form } from "./form.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic';
|
|
3
|
+
export type FormFieldLayout = 'vertical' | 'horizontal';
|
|
4
|
+
export interface FormFieldViewProps {
|
|
5
|
+
label?: ReactNode;
|
|
6
|
+
htmlFor?: string;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
error?: ReactNode;
|
|
9
|
+
/** Render the message slot with warning styling instead of error. */
|
|
10
|
+
warning?: boolean;
|
|
11
|
+
description?: ReactNode;
|
|
12
|
+
layout?: FormFieldLayout;
|
|
13
|
+
/**
|
|
14
|
+
* Extra props cloned onto the single child control (e.g. Form.Item's
|
|
15
|
+
* `value`/`onChange`/`status`). View-owned id/aria attributes win.
|
|
16
|
+
*/
|
|
17
|
+
controlProps?: Record<string, unknown>;
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
className?: string;
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
classNames?: SemanticClassNames<'root' | 'label' | 'error' | 'description'>;
|
|
22
|
+
styles?: SemanticStyles<'root' | 'label' | 'error' | 'description'>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Shared presentational view behind FormField (standalone) and Form.Item
|
|
26
|
+
* (rc-form bound): label + required mark + control + error/description slots
|
|
27
|
+
* with the aria wiring (describedby/errormessage/invalid/required) applied
|
|
28
|
+
* to the child control. Not part of the public API.
|
|
29
|
+
*/
|
|
30
|
+
export declare function FormFieldView({ label, htmlFor, required, error, warning, description, layout, controlProps, children, className, style, classNames, styles, }: FormFieldViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { cloneElement, isValidElement, useId } from "react";
|
|
4
|
+
import { cx } from "../../utils/semantic.js";
|
|
5
|
+
function FormFieldView(t0) {
|
|
6
|
+
const $ = c(43);
|
|
7
|
+
const { label, htmlFor, required, error, warning, description, layout: t1, controlProps, children, className, style, classNames, styles } = t0;
|
|
8
|
+
const layout = void 0 === t1 ? "vertical" : t1;
|
|
9
|
+
const generatedId = useId();
|
|
10
|
+
const child = /*#__PURE__*/ isValidElement(children) ? children : null;
|
|
11
|
+
const childId = "string" == typeof child?.props.id ? child.props.id : void 0;
|
|
12
|
+
const controlId = htmlFor ?? childId ?? `${generatedId}-control`;
|
|
13
|
+
const descriptionId = `${generatedId}-description`;
|
|
14
|
+
const errorId = `${generatedId}-error`;
|
|
15
|
+
const childDescribedBy = "string" == typeof child?.props["aria-describedby"] ? child.props["aria-describedby"] : void 0;
|
|
16
|
+
const t2 = error ? errorId : description ? descriptionId : void 0;
|
|
17
|
+
let t3;
|
|
18
|
+
if ($[0] !== childDescribedBy || $[1] !== t2) {
|
|
19
|
+
t3 = [
|
|
20
|
+
childDescribedBy,
|
|
21
|
+
t2
|
|
22
|
+
].filter(Boolean);
|
|
23
|
+
$[0] = childDescribedBy;
|
|
24
|
+
$[1] = t2;
|
|
25
|
+
$[2] = t3;
|
|
26
|
+
} else t3 = $[2];
|
|
27
|
+
const describedBy = t3.join(" ");
|
|
28
|
+
let t4;
|
|
29
|
+
if ($[3] !== child || $[4] !== children || $[5] !== controlId || $[6] !== controlProps || $[7] !== describedBy || $[8] !== error || $[9] !== errorId || $[10] !== required) {
|
|
30
|
+
t4 = child ? /*#__PURE__*/ cloneElement(child, {
|
|
31
|
+
...controlProps,
|
|
32
|
+
id: controlId,
|
|
33
|
+
"aria-describedby": describedBy || void 0,
|
|
34
|
+
"aria-errormessage": error ? errorId : void 0,
|
|
35
|
+
"aria-invalid": error ? true : child.props["aria-invalid"],
|
|
36
|
+
"aria-required": required ? true : child.props["aria-required"]
|
|
37
|
+
}) : children;
|
|
38
|
+
$[3] = child;
|
|
39
|
+
$[4] = children;
|
|
40
|
+
$[5] = controlId;
|
|
41
|
+
$[6] = controlProps;
|
|
42
|
+
$[7] = describedBy;
|
|
43
|
+
$[8] = error;
|
|
44
|
+
$[9] = errorId;
|
|
45
|
+
$[10] = required;
|
|
46
|
+
$[11] = t4;
|
|
47
|
+
} else t4 = $[11];
|
|
48
|
+
const control = t4;
|
|
49
|
+
const t5 = classNames?.root;
|
|
50
|
+
let t6;
|
|
51
|
+
if ($[12] !== className || $[13] !== t5) {
|
|
52
|
+
t6 = cx(t5, className);
|
|
53
|
+
$[12] = className;
|
|
54
|
+
$[13] = t5;
|
|
55
|
+
$[14] = t6;
|
|
56
|
+
} else t6 = $[14];
|
|
57
|
+
const t7 = styles?.root;
|
|
58
|
+
let t8;
|
|
59
|
+
if ($[15] !== style || $[16] !== t7) {
|
|
60
|
+
t8 = {
|
|
61
|
+
...t7,
|
|
62
|
+
...style
|
|
63
|
+
};
|
|
64
|
+
$[15] = style;
|
|
65
|
+
$[16] = t7;
|
|
66
|
+
$[17] = t8;
|
|
67
|
+
} else t8 = $[17];
|
|
68
|
+
const t9 = "horizontal" === layout ? "horizontal" : void 0;
|
|
69
|
+
let t10;
|
|
70
|
+
if ($[18] !== classNames?.label || $[19] !== controlId || $[20] !== label || $[21] !== required || $[22] !== styles?.label) {
|
|
71
|
+
t10 = null != label && /*#__PURE__*/ jsxs("label", {
|
|
72
|
+
htmlFor: controlId,
|
|
73
|
+
className: classNames?.label,
|
|
74
|
+
style: styles?.label,
|
|
75
|
+
"data-tao-form-label": "",
|
|
76
|
+
children: [
|
|
77
|
+
label,
|
|
78
|
+
required && /*#__PURE__*/ jsx("span", {
|
|
79
|
+
"data-tao-required": "",
|
|
80
|
+
"aria-hidden": "true",
|
|
81
|
+
children: "*"
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
$[18] = classNames?.label;
|
|
86
|
+
$[19] = controlId;
|
|
87
|
+
$[20] = label;
|
|
88
|
+
$[21] = required;
|
|
89
|
+
$[22] = styles?.label;
|
|
90
|
+
$[23] = t10;
|
|
91
|
+
} else t10 = $[23];
|
|
92
|
+
let t11;
|
|
93
|
+
if ($[24] !== classNames?.description || $[25] !== classNames?.error || $[26] !== description || $[27] !== descriptionId || $[28] !== error || $[29] !== errorId || $[30] !== styles?.description || $[31] !== styles?.error || $[32] !== warning) {
|
|
94
|
+
t11 = error ? /*#__PURE__*/ jsx("p", {
|
|
95
|
+
className: classNames?.error,
|
|
96
|
+
style: styles?.error,
|
|
97
|
+
"data-tao-form-error": "",
|
|
98
|
+
"data-tao-status": warning ? "warning" : void 0,
|
|
99
|
+
id: errorId,
|
|
100
|
+
role: "alert",
|
|
101
|
+
children: error
|
|
102
|
+
}) : description ? /*#__PURE__*/ jsx("p", {
|
|
103
|
+
className: classNames?.description,
|
|
104
|
+
style: styles?.description,
|
|
105
|
+
"data-tao-form-description": "",
|
|
106
|
+
id: descriptionId,
|
|
107
|
+
children: description
|
|
108
|
+
}) : null;
|
|
109
|
+
$[24] = classNames?.description;
|
|
110
|
+
$[25] = classNames?.error;
|
|
111
|
+
$[26] = description;
|
|
112
|
+
$[27] = descriptionId;
|
|
113
|
+
$[28] = error;
|
|
114
|
+
$[29] = errorId;
|
|
115
|
+
$[30] = styles?.description;
|
|
116
|
+
$[31] = styles?.error;
|
|
117
|
+
$[32] = warning;
|
|
118
|
+
$[33] = t11;
|
|
119
|
+
} else t11 = $[33];
|
|
120
|
+
let t12;
|
|
121
|
+
if ($[34] !== control || $[35] !== t11) {
|
|
122
|
+
t12 = /*#__PURE__*/ jsxs("div", {
|
|
123
|
+
"data-tao-form-control": "",
|
|
124
|
+
children: [
|
|
125
|
+
control,
|
|
126
|
+
t11
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
$[34] = control;
|
|
130
|
+
$[35] = t11;
|
|
131
|
+
$[36] = t12;
|
|
132
|
+
} else t12 = $[36];
|
|
133
|
+
let t13;
|
|
134
|
+
if ($[37] !== t10 || $[38] !== t12 || $[39] !== t6 || $[40] !== t8 || $[41] !== t9) {
|
|
135
|
+
t13 = /*#__PURE__*/ jsxs("div", {
|
|
136
|
+
className: t6,
|
|
137
|
+
style: t8,
|
|
138
|
+
"data-tao-form-field": "",
|
|
139
|
+
"data-tao-layout": t9,
|
|
140
|
+
children: [
|
|
141
|
+
t10,
|
|
142
|
+
t12
|
|
143
|
+
]
|
|
144
|
+
});
|
|
145
|
+
$[37] = t10;
|
|
146
|
+
$[38] = t12;
|
|
147
|
+
$[39] = t6;
|
|
148
|
+
$[40] = t8;
|
|
149
|
+
$[41] = t9;
|
|
150
|
+
$[42] = t13;
|
|
151
|
+
} else t13 = $[42];
|
|
152
|
+
return t13;
|
|
153
|
+
}
|
|
154
|
+
export { FormFieldView };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import type { SemanticClassNames, SemanticStyles } from '../../utils/semantic';
|
|
3
3
|
import './form.css';
|
|
4
4
|
export type FormFieldSemanticPart = 'root' | 'label' | 'error' | 'description';
|
|
5
5
|
export interface FormFieldProps {
|