@cscfi/csc-ui 4.0.0-rc.3 → 4.0.0-rc.5
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/csc-ui.js +12632 -11979
- package/dist/custom-elements.json +204 -28
- package/dist/docs/c-button/usage.md +93 -14
- package/dist/docs/c-color-picker/usage.md +2 -1
- package/dist/docs/c-date-picker/usage.md +2 -1
- package/dist/docs/c-file-upload/usage.md +3 -3
- package/dist/docs/c-icon-button/usage.md +19 -8
- package/dist/docs/c-otp-input/usage.md +4 -1
- package/dist/docs/c-radio-group/usage.md +3 -1
- package/dist/docs/c-slider/usage.md +2 -2
- package/dist/docs/c-text-field/usage.md +53 -1
- package/dist/styles/css/tailwind-theme.css +6 -0
- package/dist/styles/css/tokens.css +107 -96
- package/dist/vscode.css-custom-data.json +2 -2
- package/dist/vscode.html-custom-data.json +88 -16
- package/dist/web-types.json +118 -34
- package/dist-types/components/c-autocomplete/CAutocomplete.vue.d.ts +2 -1
- package/dist-types/components/c-button/CButton.vue.d.ts +23 -5
- package/dist-types/components/c-button/injectButtonStyles.d.ts +1 -0
- package/dist-types/components/c-button-group/CButtonGroup.vue.d.ts +8 -0
- package/dist-types/components/c-checkbox/CCheckbox.vue.d.ts +3 -3
- package/dist-types/components/c-color-picker/CColorPicker.vue.d.ts +2 -1
- package/dist-types/components/c-date-picker/CDatePicker.vue.d.ts +2 -1
- package/dist-types/components/c-icon-button/CIconButton.vue.d.ts +18 -2
- package/dist-types/components/c-list-item/CListItem.vue.d.ts +1 -1
- package/dist-types/components/c-number-field/CNumberField.vue.d.ts +2 -1
- package/dist-types/components/c-otp-input/COtpInput.vue.d.ts +7 -0
- package/dist-types/components/c-radio-group/CRadioGroup.vue.d.ts +8 -0
- package/dist-types/components/c-select/CSelect.vue.d.ts +2 -1
- package/dist-types/components/c-side-navigation-item/CSideNavigationItem.vue.d.ts +1 -1
- package/dist-types/components/c-slider/CSlider.vue.d.ts +2 -3
- package/dist-types/components/c-sub-navigation-item/CSubNavigationItem.vue.d.ts +1 -1
- package/dist-types/components/c-switch/CSwitch.vue.d.ts +8 -0
- package/dist-types/components/c-text-field/CTextField.vue.d.ts +3 -2
- package/dist-types/components/c-text-field/injectTextFieldStyles.d.ts +1 -0
- package/dist-types/components/c-time-picker/CTimePicker.vue.d.ts +2 -1
- package/dist-types/components/c-tree-select/CTreeSelect.vue.d.ts +1 -1
- package/dist-types/index.d.ts +2 -2
- package/dist-types/registry.d.ts +7 -0
- package/dist-types/shared/appDefaults.d.ts +8 -1
- package/dist-types/shared/buttonVariant.d.ts +5 -0
- package/dist-types/shared/defineElement.d.ts +5 -1
- package/dist-types/shared/implicitSubmission.d.ts +31 -0
- package/dist-types/shared/useElementInternals.d.ts +7 -0
- package/dist-types/shared/useFormAssociation.d.ts +88 -0
- package/dist-types/shared/useHostStates.d.ts +5 -4
- package/dist-types/shared/useTypedField.d.ts +7 -0
- package/dist-types/shared/valueEvents.d.ts +6 -0
- package/dist-types/tag-name-map.d.ts +75 -28
- package/package.json +3 -2
|
@@ -9,6 +9,12 @@ export type CIconButtonAppearance = 'filled' | 'ghost' | 'outlined' | 'text';
|
|
|
9
9
|
* compact buttons; omitting the attribute renders the default size.
|
|
10
10
|
*/
|
|
11
11
|
export type CIconButtonSize = 'default' | 'small' | 'x-small';
|
|
12
|
+
/**
|
|
13
|
+
* The colour an icon button takes — `c-button`'s variants: `primary` (unless
|
|
14
|
+
* set) and `secondary`, the brand families, or a status colour — `success`,
|
|
15
|
+
* `info`, `warning` and `danger`, a destructive action in the error colour.
|
|
16
|
+
*/
|
|
17
|
+
export type CIconButtonVariant = 'danger' | 'info' | 'primary' | 'secondary' | 'success' | 'warning';
|
|
12
18
|
interface CIconButtonProps {
|
|
13
19
|
/**
|
|
14
20
|
* The button's look: `filled` (unless set) for the main action; `outlined`
|
|
@@ -22,8 +28,9 @@ interface CIconButtonProps {
|
|
|
22
28
|
*/
|
|
23
29
|
badge?: null | number | string;
|
|
24
30
|
/**
|
|
25
|
-
* Danger look for a destructive action: the
|
|
26
|
-
*
|
|
31
|
+
* Danger look for a destructive action: the error colour.
|
|
32
|
+
*
|
|
33
|
+
* @deprecated Use `variant="danger"`.
|
|
27
34
|
*/
|
|
28
35
|
danger?: boolean;
|
|
29
36
|
/**
|
|
@@ -70,6 +77,14 @@ interface CIconButtonProps {
|
|
|
70
77
|
* @deprecated Use `appearance="text"`.
|
|
71
78
|
*/
|
|
72
79
|
text?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The button's colour, in every appearance: `primary` unless set (or
|
|
82
|
+
* changed app-wide), `secondary`, `success`, `info`, `warning`, or `danger`
|
|
83
|
+
* for a destructive action.
|
|
84
|
+
*
|
|
85
|
+
* @defaultable 'primary'
|
|
86
|
+
*/
|
|
87
|
+
variant?: CIconButtonVariant;
|
|
73
88
|
}
|
|
74
89
|
declare const _default: typeof __VLS_export;
|
|
75
90
|
export default _default;
|
|
@@ -78,6 +93,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<CIconB
|
|
|
78
93
|
text: boolean;
|
|
79
94
|
outlined: boolean;
|
|
80
95
|
size: CIconButtonSize;
|
|
96
|
+
variant: CIconButtonVariant;
|
|
81
97
|
disabled: boolean;
|
|
82
98
|
loading: boolean;
|
|
83
99
|
appearance: CIconButtonAppearance;
|
|
@@ -49,9 +49,9 @@ type __VLS_Slots = {} & {
|
|
|
49
49
|
};
|
|
50
50
|
declare const __VLS_base: import("vue").DefineComponent<CListItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CListItemProps> & Readonly<{}>, {
|
|
51
51
|
disabled: boolean;
|
|
52
|
+
active: boolean;
|
|
52
53
|
href: string;
|
|
53
54
|
target: string;
|
|
54
|
-
active: boolean;
|
|
55
55
|
disabledByParent: boolean;
|
|
56
56
|
hoverable: boolean;
|
|
57
57
|
ripple: boolean;
|
|
@@ -41,6 +41,12 @@ interface COtpInputProps {
|
|
|
41
41
|
* Number of digits in the code, one box each
|
|
42
42
|
*/
|
|
43
43
|
length?: number;
|
|
44
|
+
/**
|
|
45
|
+
* The name the code submits under in a native `<form>`, as typed so far
|
|
46
|
+
*
|
|
47
|
+
* @freeform
|
|
48
|
+
*/
|
|
49
|
+
name?: string;
|
|
44
50
|
/**
|
|
45
51
|
* Set as required — shows the required marker on the label
|
|
46
52
|
*/
|
|
@@ -63,6 +69,7 @@ declare const __VLS_base: import("vue").DefineComponent<COtpInputProps, {
|
|
|
63
69
|
label: string;
|
|
64
70
|
invalid: boolean;
|
|
65
71
|
length: number;
|
|
72
|
+
name: string;
|
|
66
73
|
value: string;
|
|
67
74
|
hideDetails: boolean;
|
|
68
75
|
hideMessage: boolean;
|
|
@@ -41,6 +41,13 @@ interface CRadioGroupProps {
|
|
|
41
41
|
* @freeform
|
|
42
42
|
*/
|
|
43
43
|
label?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The name the picked radio's value submits under in a native `<form>`;
|
|
46
|
+
* nothing submits while no radio is picked
|
|
47
|
+
*
|
|
48
|
+
* @freeform
|
|
49
|
+
*/
|
|
50
|
+
name?: string;
|
|
44
51
|
/**
|
|
45
52
|
* Set as required
|
|
46
53
|
*/
|
|
@@ -62,6 +69,7 @@ declare const __VLS_base: import("vue").DefineComponent<CRadioGroupProps, {
|
|
|
62
69
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CRadioGroupProps> & Readonly<{}>, {
|
|
63
70
|
label: string;
|
|
64
71
|
invalid: boolean;
|
|
72
|
+
name: string;
|
|
65
73
|
value: null | string;
|
|
66
74
|
inline: boolean;
|
|
67
75
|
hideDetails: boolean;
|
|
@@ -59,9 +59,9 @@ declare const __VLS_base: import("vue").DefineComponent<CSideNavigationItemProps
|
|
|
59
59
|
expanded: boolean;
|
|
60
60
|
value: string;
|
|
61
61
|
loading: boolean;
|
|
62
|
+
active: boolean;
|
|
62
63
|
href: string;
|
|
63
64
|
target: string;
|
|
64
|
-
active: boolean;
|
|
65
65
|
collapsed: boolean;
|
|
66
66
|
current: boolean;
|
|
67
67
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -26,8 +26,7 @@ interface CSliderProps {
|
|
|
26
26
|
/** The smallest value. */
|
|
27
27
|
min?: number;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* form-associated, so it does not submit with a `<form>`.
|
|
29
|
+
* The name the value submits under in a native `<form>`
|
|
31
30
|
*
|
|
32
31
|
* @freeform
|
|
33
32
|
*/
|
|
@@ -62,8 +61,8 @@ declare const __VLS_export: import("vue").DefineComponent<CSliderProps, {
|
|
|
62
61
|
disabled: boolean;
|
|
63
62
|
max: number;
|
|
64
63
|
min: number;
|
|
65
|
-
disableTooltip: boolean;
|
|
66
64
|
labels: boolean;
|
|
65
|
+
disableTooltip: boolean;
|
|
67
66
|
segments: number;
|
|
68
67
|
tickLabels: boolean;
|
|
69
68
|
ticks: boolean;
|
|
@@ -52,9 +52,9 @@ type __VLS_Slots = {} & {
|
|
|
52
52
|
declare const __VLS_base: import("vue").DefineComponent<CSubNavigationItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CSubNavigationItemProps> & Readonly<{}>, {
|
|
53
53
|
value: string;
|
|
54
54
|
loading: boolean;
|
|
55
|
+
active: boolean;
|
|
55
56
|
href: string;
|
|
56
57
|
target: string;
|
|
57
|
-
active: boolean;
|
|
58
58
|
collapsed: boolean;
|
|
59
59
|
current: boolean;
|
|
60
60
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -26,6 +26,13 @@ interface CSwitchProps {
|
|
|
26
26
|
* saved. The switch ignores toggles meanwhile and is announced as busy
|
|
27
27
|
*/
|
|
28
28
|
loading?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The name the switch submits under in a native `<form>` while it is on:
|
|
31
|
+
* its `true-value`, or `on` when that is `true`
|
|
32
|
+
*
|
|
33
|
+
* @freeform
|
|
34
|
+
*/
|
|
35
|
+
name?: string;
|
|
29
36
|
/**
|
|
30
37
|
* Set as required — shows the required marker on the label
|
|
31
38
|
*/
|
|
@@ -49,6 +56,7 @@ declare const __VLS_base: import("vue").DefineComponent<CSwitchProps, {
|
|
|
49
56
|
focus: (options?: FocusOptions) => void;
|
|
50
57
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CSwitchProps> & Readonly<{}>, {
|
|
51
58
|
label: string;
|
|
59
|
+
name: string;
|
|
52
60
|
value: string | number | boolean;
|
|
53
61
|
disabled: boolean;
|
|
54
62
|
loading: boolean;
|
|
@@ -97,8 +97,7 @@ interface CTextFieldProps {
|
|
|
97
97
|
*/
|
|
98
98
|
min?: null | number;
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
101
|
-
* does not submit with a `<form>`.
|
|
100
|
+
* The name the text submits under in a native `<form>`
|
|
102
101
|
*
|
|
103
102
|
* @freeform
|
|
104
103
|
*/
|
|
@@ -194,6 +193,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<CTextF
|
|
|
194
193
|
trimWhitespace: boolean;
|
|
195
194
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
196
195
|
pre?: (props: {}) => any;
|
|
196
|
+
} & {
|
|
197
|
+
default?: (props: {}) => any;
|
|
197
198
|
} & {
|
|
198
199
|
post?: (props: {}) => any;
|
|
199
200
|
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ensureTextFieldStyles: () => void;
|
|
@@ -131,7 +131,8 @@ interface CTimePickerProps {
|
|
|
131
131
|
*/
|
|
132
132
|
minuteStep?: number;
|
|
133
133
|
/**
|
|
134
|
-
*
|
|
134
|
+
* The name the time submits under in a native `<form>`, as its ISO text;
|
|
135
|
+
* a `range` as one ISO 8601 interval, `start/end`
|
|
135
136
|
*
|
|
136
137
|
* @freeform
|
|
137
138
|
*/
|
package/dist-types/index.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ export type { CAlertType } from './components/c-alert/CAlert.vue';
|
|
|
3
3
|
export type { CAutocompleteFilter, CAutocompleteItem, CAutocompleteOption, CAutocompleteTexts, CAutocompleteValue, } from './components/c-autocomplete/CAutocomplete.vue';
|
|
4
4
|
export type { CBreadcrumbTexts } from './components/c-breadcrumb/CBreadcrumb.vue';
|
|
5
5
|
export type { CButtonGroupSize, CButtonGroupValue, } from './components/c-button-group/CButtonGroup.vue';
|
|
6
|
-
export type { CButtonAppearance, CButtonSize, CButtonType, } from './components/c-button/CButton.vue';
|
|
6
|
+
export type { CButtonAppearance, CButtonSize, CButtonType, CButtonVariant, } from './components/c-button/CButton.vue';
|
|
7
7
|
export type { CCardActionsAlign, CCardActionsJustify, } from './components/c-card-actions/CCardActions.vue';
|
|
8
8
|
export type { CColorPickerFormat, CColorPickerSwatch, CColorPickerTexts, CColorPickerValue, } from './components/c-color-picker/CColorPicker.vue';
|
|
9
9
|
export type { CDataTableAlign, CDataTableCellContent, CDataTableCellContext, CDataTableColumn, CDataTableColumnExpansion, CDataTableColumnPin, CDataTableExpandedContext, CDataTableFooterContext, CDataTableRow, CDataTableSelectionMode, CDataTableSort, CDataTableSortDirection, CDataTableTexts, } from './components/c-data-table/CDataTable.vue';
|
|
10
10
|
export type { CDatePickerDisabledDate, CDatePickerRange, CDatePickerText, CDatePickerTexts, CDatePickerType, CDatePickerValue, CDatePickerWeekday, } from './components/c-date-picker/CDatePicker.vue';
|
|
11
11
|
export type { CFileUploadContext, CFileUploadEntry, CFileUploadFunction, CFileUploadRejection, CFileUploadRejectReason, CFileUploadStatus, CFileUploadTexts, } from './components/c-file-upload/CFileUpload.vue';
|
|
12
|
-
export type { CIconButtonAppearance, CIconButtonSize, } from './components/c-icon-button/CIconButton.vue';
|
|
12
|
+
export type { CIconButtonAppearance, CIconButtonSize, CIconButtonVariant, } from './components/c-icon-button/CIconButton.vue';
|
|
13
13
|
export type { CLoginCardActionsAlign, CLoginCardActionsJustify, } from './components/c-login-card-actions/CLoginCardActions.vue';
|
|
14
14
|
export type { CLoginCardBlendMode } from './components/c-login-card/CLoginCard.vue';
|
|
15
15
|
export type { CMenuItemType } from './components/c-menu-item/CMenuItem.vue';
|
package/dist-types/registry.d.ts
CHANGED
|
@@ -5,5 +5,12 @@
|
|
|
5
5
|
* conformance suites enrol every tag from it.
|
|
6
6
|
*/
|
|
7
7
|
export declare const components: ReadonlyArray<readonly [string, unknown]>;
|
|
8
|
+
/**
|
|
9
|
+
* The tags whose elements take part in a native `<form>` (ADR-0084): every
|
|
10
|
+
* value control that is a form field — not c-file-upload, whose upload
|
|
11
|
+
* function carries its files, nor c-tabs, c-accordion, c-modal and
|
|
12
|
+
* c-pagination — and the buttons, without a value.
|
|
13
|
+
*/
|
|
14
|
+
export declare const formAssociatedTags: ReadonlySet<string>;
|
|
8
15
|
/** Every tag `defineCustomElements()` registers, internal ones included. */
|
|
9
16
|
export declare const registeredTags: ReadonlyArray<string>;
|
|
@@ -78,5 +78,12 @@ export declare function resetDefaults(tags?: CDefaultableTag[]): void;
|
|
|
78
78
|
* still beats an app-wide `hideDetails: true`.
|
|
79
79
|
*
|
|
80
80
|
* const hideMessageResolved = appDefault('hideMessage', false, 'hideDetails');
|
|
81
|
+
*
|
|
82
|
+
* A replaced prop of another shape names a mapper fourth: it receives that
|
|
83
|
+
* prop's own instance value (an attribute string or a property) and returns
|
|
84
|
+
* the new prop's value, or undefined to fall through. Such a prop is not
|
|
85
|
+
* defaultable, so only the instance layer reads it.
|
|
86
|
+
*
|
|
87
|
+
* const variantResolved = appDefault('variant', 'primary', 'danger', dangerAsVariant);
|
|
81
88
|
*/
|
|
82
|
-
export declare const useAppDefault: <T extends CDefaultableTag>(tag: T, props: object) => <K extends keyof Bucket<T> & string>(key: K, builtIn: Resolved<T, K>, replaces?:
|
|
89
|
+
export declare const useAppDefault: <T extends CDefaultableTag>(tag: T, props: object) => <K extends keyof Bucket<T> & string>(key: K, builtIn: Resolved<T, K>, replaces?: string, map?: (value: unknown) => Resolved<T, K> | undefined) => ComputedRef<Resolved<T, K>>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type Component } from 'vue';
|
|
2
2
|
export declare const hyphenate: (key: string) => string;
|
|
3
|
+
export interface DefineElementOptions {
|
|
4
|
+
/** Take part in a native `<form>` (ADR-0084). */
|
|
5
|
+
formAssociated?: boolean;
|
|
6
|
+
}
|
|
3
7
|
/**
|
|
4
8
|
* Register a Vue SFC as a custom element under `tag`, with the shared Tailwind
|
|
5
9
|
* utility stylesheet applied to its shadow root alongside the SFC's own styles.
|
|
@@ -18,4 +22,4 @@ export declare const hyphenate: (key: string) => string;
|
|
|
18
22
|
* No-op if `tag` is already defined — the docs may have registered the Stencil
|
|
19
23
|
* version first, or this function may be called twice.
|
|
20
24
|
*/
|
|
21
|
-
export declare function defineElement(tag: string, component: Component): void;
|
|
25
|
+
export declare function defineElement(tag: string, component: Component, { formAssociated }?: DefineElementOptions): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implicit submission (ADR-0084): Enter in a single-line text field submits
|
|
3
|
+
* its form, by the browser's rule — with `<c-button type="submit">` counted as
|
|
4
|
+
* a submit button, which the browser's own rule cannot see (its native button
|
|
5
|
+
* lives in a shadow root), and the csc-ui text fields counted as the fields
|
|
6
|
+
* that block a form without a button from submitting.
|
|
7
|
+
*
|
|
8
|
+
* The browser does none of this for a field whose input lives in a shadow
|
|
9
|
+
* root, so each text-entry field calls `submitOnEnter` from its own keydown.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Submit `form` as Enter in one of its text fields would: click its first
|
|
13
|
+
* submit button — through the button, so a disabled or loading one does
|
|
14
|
+
* nothing — or, without one, submit when it has only one text field.
|
|
15
|
+
*/
|
|
16
|
+
export declare const submitImplicitly: (form: HTMLFormElement) => void;
|
|
17
|
+
/**
|
|
18
|
+
* A text field's keydown: a plain Enter submits `form` once the event has
|
|
19
|
+
* finished dispatching, unless the page cancelled it, as the browser's own
|
|
20
|
+
* implicit submission is the keydown's default action.
|
|
21
|
+
*/
|
|
22
|
+
export declare const submitOnEnter: (event: KeyboardEvent, form: HTMLFormElement | null) => void;
|
|
23
|
+
/**
|
|
24
|
+
* The keydown of a page's own input inside a csc-ui field (c-text-field's
|
|
25
|
+
* slotted input, ADR-0083): the browser runs its own implicit submission
|
|
26
|
+
* there, blind to `<c-button type="submit">`, so a plain Enter that the page
|
|
27
|
+
* has not cancelled by the end of its dispatch is cancelled here and
|
|
28
|
+
* submitted by this rule instead. A listener that stops the event first
|
|
29
|
+
* leaves the browser's own submission in place.
|
|
30
|
+
*/
|
|
31
|
+
export declare const submitOnEnterInstead: (event: KeyboardEvent, form: HTMLFormElement | null) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single path to the host's internals — custom states (`useHostStates`,
|
|
3
|
+
* ADR-0035) and form association (`useFormAssociation`, ADR-0084) both go
|
|
4
|
+
* through it. `null` where internals are unavailable (SSR, an ancient
|
|
5
|
+
* browser): callers degrade to a silent no-op.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useElementInternals: () => ElementInternals | null;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Form association (ADR-0084): a value control takes part in a native
|
|
4
|
+
* `<form>` the way a built-in control does — its value submits under its
|
|
5
|
+
* `name`, `form.reset()` returns it to its authored default, a disabled
|
|
6
|
+
* `<fieldset>` disables it, and a validating form checks it.
|
|
7
|
+
*
|
|
8
|
+
* The element class is form-associated (`defineElement`'s `formAssociated`);
|
|
9
|
+
* the browser calls its form callbacks, which land here through
|
|
10
|
+
* `formCallbacks`. Everything degrades to a silent no-op where the element is
|
|
11
|
+
* not form-associated or internals are unavailable (SSR).
|
|
12
|
+
*/
|
|
13
|
+
/** The `value` and `checked` attributes as authored, before any upgrade. */
|
|
14
|
+
export interface AuthoredDefaults {
|
|
15
|
+
checked: boolean;
|
|
16
|
+
value: null | string;
|
|
17
|
+
}
|
|
18
|
+
export interface FormAssociation {
|
|
19
|
+
/** The form owner, or `null`. */
|
|
20
|
+
form(): HTMLFormElement | null;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the element is disabled from outside: a disabled `<fieldset>`
|
|
23
|
+
* around it, or a `disabled` attribute on the host.
|
|
24
|
+
*/
|
|
25
|
+
formDisabled: Readonly<Ref<boolean>>;
|
|
26
|
+
}
|
|
27
|
+
export interface FormAssociationOptions {
|
|
28
|
+
/** The entry name; nothing submits without one. */
|
|
29
|
+
name(): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Return the control to `authored` on `form.reset()`, through the model
|
|
32
|
+
* path (`emitModelInput`), so a bound model follows (ADR-0084).
|
|
33
|
+
*/
|
|
34
|
+
reset(authored: AuthoredDefaults): void;
|
|
35
|
+
/** The failed check now, or `null` when the control passes. */
|
|
36
|
+
validity?(): FormValidity | null;
|
|
37
|
+
/** The entry value now; read only while the control has a name. */
|
|
38
|
+
value(): FormEntryValue;
|
|
39
|
+
}
|
|
40
|
+
/** What a control submits: one entry, one per value, or nothing. */
|
|
41
|
+
export type FormEntryValue = null | readonly string[] | string;
|
|
42
|
+
/** A failed check: the flags, the bubble's text and the control it points at. */
|
|
43
|
+
export interface FormValidity {
|
|
44
|
+
anchor?: HTMLElement | null;
|
|
45
|
+
flags: ValidityStateFlags;
|
|
46
|
+
message: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The browser's form callbacks, as `defineElement` forwards them, and the
|
|
50
|
+
* authored-default capture it runs on connect.
|
|
51
|
+
*/
|
|
52
|
+
export declare const formCallbacks: {
|
|
53
|
+
/**
|
|
54
|
+
* Keep the authored `value` and `checked` before the element first
|
|
55
|
+
* upgrades: Vue's custom element writes every string, number or `true` prop
|
|
56
|
+
* back to its attribute (`_setProp`), so after that the attribute follows
|
|
57
|
+
* the value and no longer says what the markup — or a server render — set.
|
|
58
|
+
* A value bound as a property is not an attribute yet at this point.
|
|
59
|
+
*/
|
|
60
|
+
captureAuthored(host: HTMLElement): void;
|
|
61
|
+
disabled(host: HTMLElement, on: boolean): void;
|
|
62
|
+
reset(host: HTMLElement): void;
|
|
63
|
+
};
|
|
64
|
+
/** A constraint as a detached native control would hold it. */
|
|
65
|
+
export type NativeConstraint = 'select' | Partial<Pick<HTMLInputElement, 'max' | 'min' | 'name' | 'pattern' | 'required' | 'type' | 'value'>>;
|
|
66
|
+
/**
|
|
67
|
+
* The browser's own wording for a failed check, in its UI language, read off
|
|
68
|
+
* a detached native control holding the same constraint — so a csc-ui field's
|
|
69
|
+
* bubble reads as a native field's would: `{ required: true }` for a missing
|
|
70
|
+
* value, `{ pattern: 'a', value: 'b' }` for a format, `{ type: 'number', min:
|
|
71
|
+
* '5', value: '3' }` for a range, `'select'` for a list.
|
|
72
|
+
*/
|
|
73
|
+
export declare const nativeMessage: (constraint: NativeConstraint) => string;
|
|
74
|
+
/** The wording of a malformed value: a mask, a code, an unreadable date. */
|
|
75
|
+
export declare const formatMessage: () => string;
|
|
76
|
+
/**
|
|
77
|
+
* A native control's own failed check — `required`, a `type="email"`, `min` /
|
|
78
|
+
* `max` / `step` — as the host reports it, pointing at that control. `null`
|
|
79
|
+
* while it passes.
|
|
80
|
+
*/
|
|
81
|
+
export declare const validityOf: (control: HTMLInputElement | HTMLTextAreaElement | null | undefined) => FormValidity | null;
|
|
82
|
+
/**
|
|
83
|
+
* The form side of a value control. Call once from the component's setup;
|
|
84
|
+
* it hands the form what `value()` returns under `name()`, reports
|
|
85
|
+
* `validity()` (the browser skips a disabled element's), and runs `reset` on
|
|
86
|
+
* a form reset.
|
|
87
|
+
*/
|
|
88
|
+
export declare const useFormAssociation: (options: FormAssociationOptions) => FormAssociation;
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
* Each exposed state name is public API — curated like parts, documented with
|
|
18
18
|
* a `@cssstate` docblock tag so it lands in the manifest.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* `states` are unavailable (SSR,
|
|
23
|
-
* still renders and behaves, only the `:state()` selector surface
|
|
20
|
+
* The internals come from `useElementInternals`, which owns the element's one
|
|
21
|
+
* `attachInternals()` call. Everything degrades to a silent no-op where
|
|
22
|
+
* internals or `states` are unavailable (SSR, an ancient browser) — the
|
|
23
|
+
* component still renders and behaves, only the `:state()` selector surface
|
|
24
|
+
* is absent.
|
|
24
25
|
*/
|
|
25
26
|
export declare const useHostStates: () => ((name: string, on: boolean) => void);
|
|
@@ -39,12 +39,16 @@ export interface UseTypedFieldOptions {
|
|
|
39
39
|
codec: TypedFieldCodec;
|
|
40
40
|
/** The custom element host: the model events dispatch from it. */
|
|
41
41
|
host: HTMLElement | null;
|
|
42
|
+
/** Whether the panel is open: Enter in the field then submits no form. */
|
|
43
|
+
isOpen: () => boolean;
|
|
42
44
|
/** The field label (props.label). */
|
|
43
45
|
label: () => string;
|
|
44
46
|
/** Whether the label rests on top of the field (the resolved app default). */
|
|
45
47
|
labelOnTop: Readonly<Ref<boolean>>;
|
|
46
48
|
/** The typing mask derived from `pattern`; without one, typing is free. */
|
|
47
49
|
mask?: Readonly<Ref<MaskSlot[]>>;
|
|
50
|
+
/** The name the value submits under in a native `<form>` (props.name). */
|
|
51
|
+
name: () => string | undefined;
|
|
48
52
|
/** The end inputs' accessible names under `range`. */
|
|
49
53
|
names: () => {
|
|
50
54
|
end: string;
|
|
@@ -60,6 +64,8 @@ export interface UseTypedFieldOptions {
|
|
|
60
64
|
placeholder: () => string;
|
|
61
65
|
/** Whether the field holds a start and an end. */
|
|
62
66
|
range: Readonly<Ref<boolean>>;
|
|
67
|
+
/** Whether the form demands an answer (props.required). */
|
|
68
|
+
required: () => boolean;
|
|
63
69
|
/** What a committed range with its start after its end becomes: swapped, or kept as typed. */
|
|
64
70
|
reversed: 'keep' | 'swap';
|
|
65
71
|
/** The host's `value` prop. */
|
|
@@ -84,6 +90,7 @@ export declare const useTypedField: (options: UseTypedFieldOptions) => {
|
|
|
84
90
|
endText: Ref<string, string>;
|
|
85
91
|
field: import("vue").ShallowRef<HTMLElement | null, HTMLElement | null>;
|
|
86
92
|
focused: Ref<boolean, boolean>;
|
|
93
|
+
formDisabled: Readonly<Ref<boolean, boolean>>;
|
|
87
94
|
hasContent: import("vue").ComputedRef<boolean>;
|
|
88
95
|
hasText: import("vue").ComputedRef<boolean>;
|
|
89
96
|
inputLabel: (end: TypedFieldEnd) => string | undefined;
|
|
@@ -32,6 +32,12 @@ export declare const seedModelValue: (host: HTMLElement | null, value: unknown)
|
|
|
32
32
|
* native range input fires `input` per move and `change` on release.
|
|
33
33
|
*/
|
|
34
34
|
export declare const emitModelInput: (host: HTMLElement | null, value: unknown) => void;
|
|
35
|
+
/**
|
|
36
|
+
* A change a page's own input inside the control reports itself
|
|
37
|
+
* (c-text-field's slotted input, ADR-0083): its native `input` and `change`
|
|
38
|
+
* already bubble through the host, so only `update:value` joins them.
|
|
39
|
+
*/
|
|
40
|
+
export declare const emitModelUpdate: (host: HTMLElement | null, value: unknown) => void;
|
|
35
41
|
/** The `change` that commits what `emitModelInput` reported. */
|
|
36
42
|
export declare const emitModelSettled: (host: HTMLElement | null, value: unknown) => void;
|
|
37
43
|
/**
|