@saasbase-io/core-elements 1.10.0 → 1.12.0
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/components/renderers/_updated/field/_confirm-field.d.ts +250 -0
- package/dist/components/renderers/_updated/field/field.stories/confirm-field.stories.d.ts +15 -0
- package/dist/components/renderers/_updated/field/field.types.d.ts +9 -0
- package/dist/components/renderers/_updated/field/index.d.ts +3 -1
- package/dist/components/renderers/_updated/form/_form-submit.d.ts +102 -0
- package/dist/components/renderers/_updated/form/form.stories/form-submit.stories.d.ts +11 -0
- package/dist/components/renderers/_updated/form/form.types.d.ts +15 -1
- package/dist/components/renderers/_updated/form/index.d.ts +3 -1
- package/dist/components/renderers/_updated/sb-gap.d.ts +1 -1
- package/dist/components/wrappers/sb-authenticated/sb-authenticated.d.ts +1 -1
- package/dist/index.js +647 -555
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3787 -3301
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { LitElement } from '../../../../../node_modules/lit';
|
|
2
|
+
import { ConfirmFieldContent, ConfirmFieldProps, ConfirmFieldVariant } from './field.types';
|
|
3
|
+
/**
|
|
4
|
+
* A self-validating confirm password field for auth widget forms.
|
|
5
|
+
* @element sb-confirm-field
|
|
6
|
+
*
|
|
7
|
+
* @part confirm-field (rtg-field)
|
|
8
|
+
* @part confirm-field-content (rtg-field-content): label + description wrapper
|
|
9
|
+
* @part confirm-field-label (rtg-field-label)
|
|
10
|
+
* @part confirm-field-mark (span): decorative marker with text or `"*"` in label
|
|
11
|
+
* @part confirm-field-description (rtg-field-description)
|
|
12
|
+
* @part confirm-field-input (rtg-input/rtg-password-input)
|
|
13
|
+
* @part confirm-field-error (rtg-field-error)
|
|
14
|
+
*
|
|
15
|
+
* @fires sb-confirm-field:validate
|
|
16
|
+
* { id, parentId, name, value, pairSelector, pairValue, valid, type, message }
|
|
17
|
+
* - id: inputId
|
|
18
|
+
* - parentId: rootId
|
|
19
|
+
* - type: "required" | "format" | "success" | "minlength" | "maxlength"
|
|
20
|
+
*/
|
|
21
|
+
export declare class SbConfirmField extends LitElement implements ConfirmFieldProps {
|
|
22
|
+
private static readonly _ROOT;
|
|
23
|
+
private static readonly _CONTENT;
|
|
24
|
+
private static readonly _LABEL;
|
|
25
|
+
private static readonly _MARK;
|
|
26
|
+
private static readonly _DESCRIPTION;
|
|
27
|
+
private static readonly _INPUT;
|
|
28
|
+
private static readonly _ERROR;
|
|
29
|
+
/**
|
|
30
|
+
* The stable CSS part names exposed for external targeting.
|
|
31
|
+
*/
|
|
32
|
+
static get parts(): {
|
|
33
|
+
root: string;
|
|
34
|
+
content: string;
|
|
35
|
+
label: string;
|
|
36
|
+
mark: string;
|
|
37
|
+
description: string;
|
|
38
|
+
input: string;
|
|
39
|
+
error: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The name of the custom event fired on validate.
|
|
43
|
+
*/
|
|
44
|
+
static get validateEventName(): string;
|
|
45
|
+
/**
|
|
46
|
+
* A unique value used as a substring in the generated part/child IDs, when
|
|
47
|
+
* the `child-id` prop is not provided.
|
|
48
|
+
*/
|
|
49
|
+
seed: string;
|
|
50
|
+
/**
|
|
51
|
+
* The `id` value given to the root child/part and used as the base of other
|
|
52
|
+
* child/part IDs.
|
|
53
|
+
*/
|
|
54
|
+
childId?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The `id` value given to the input child/part to override the auto-generated
|
|
57
|
+
* input ID, derived from the `rootId`.
|
|
58
|
+
*/
|
|
59
|
+
fieldId?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The `name` prop of the input part, used by the parent form.
|
|
62
|
+
*/
|
|
63
|
+
name: string;
|
|
64
|
+
/**
|
|
65
|
+
* The variant of the confirm field input, where `"toggle"` renders a
|
|
66
|
+
* hide/show button addon in the input element.
|
|
67
|
+
*/
|
|
68
|
+
variant: ConfirmFieldVariant;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the label and description are grouped together above the input, or
|
|
71
|
+
* split up with the input in-between them.
|
|
72
|
+
*/
|
|
73
|
+
content: ConfirmFieldContent;
|
|
74
|
+
/**
|
|
75
|
+
* A CSS selector for the paired `sb-password-field`.
|
|
76
|
+
*/
|
|
77
|
+
pair: string;
|
|
78
|
+
/**
|
|
79
|
+
* The text content of the field label.
|
|
80
|
+
*/
|
|
81
|
+
label: string;
|
|
82
|
+
/**
|
|
83
|
+
* The text used as the input placeholder.
|
|
84
|
+
*/
|
|
85
|
+
placeholder?: string;
|
|
86
|
+
/**
|
|
87
|
+
* The text content of the field description.
|
|
88
|
+
*/
|
|
89
|
+
description?: string;
|
|
90
|
+
/**
|
|
91
|
+
* The text rendered in the field label as a custom mark.
|
|
92
|
+
*/
|
|
93
|
+
mark?: string;
|
|
94
|
+
/**
|
|
95
|
+
* When provided with `required`, a caret mark is rendered in the field label.
|
|
96
|
+
*/
|
|
97
|
+
caret?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Whether the field is in a disabled state.
|
|
100
|
+
*/
|
|
101
|
+
disabled?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* When provided, the parent form cannot be submitted without this field.
|
|
104
|
+
*/
|
|
105
|
+
required?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Error message shown when the field is required but empty upon submission.
|
|
108
|
+
*/
|
|
109
|
+
requiredError: string;
|
|
110
|
+
/**
|
|
111
|
+
* Error message shown when the confirm value does not match the `pair`
|
|
112
|
+
* password field's value.
|
|
113
|
+
*/
|
|
114
|
+
matchError: string;
|
|
115
|
+
/**
|
|
116
|
+
* Indicates that the field is in an invalid state.
|
|
117
|
+
*/
|
|
118
|
+
private _invalid;
|
|
119
|
+
/**
|
|
120
|
+
* The error message rendered in field error when in an invalid state.
|
|
121
|
+
*/
|
|
122
|
+
private _error;
|
|
123
|
+
/**
|
|
124
|
+
* The current value of the confirm input.
|
|
125
|
+
*/
|
|
126
|
+
private _value;
|
|
127
|
+
/**
|
|
128
|
+
* Reference to the nearest `form` ancestor.
|
|
129
|
+
*/
|
|
130
|
+
private _form;
|
|
131
|
+
/**
|
|
132
|
+
* Overrides default behavior to render into light DOM.
|
|
133
|
+
*/
|
|
134
|
+
protected createRenderRoot(): this;
|
|
135
|
+
/**
|
|
136
|
+
* The `id` of the root element. Equal to `childId` when provided, otherwise
|
|
137
|
+
* derived from the component's part name and `seed`.
|
|
138
|
+
*/
|
|
139
|
+
get rootId(): string;
|
|
140
|
+
/**
|
|
141
|
+
* The `id` of the field content element, derived from `rootId` with the
|
|
142
|
+
* content part name appended.
|
|
143
|
+
*/
|
|
144
|
+
get contentId(): string;
|
|
145
|
+
/**
|
|
146
|
+
* The `id` of the field label element, derived from `rootId` with the label
|
|
147
|
+
* part name appended.
|
|
148
|
+
*/
|
|
149
|
+
get labelId(): string;
|
|
150
|
+
/**
|
|
151
|
+
* The `id` of the field description element, derived from `rootId` with the
|
|
152
|
+
* description part name appended.
|
|
153
|
+
*/
|
|
154
|
+
get descriptionId(): string;
|
|
155
|
+
/**
|
|
156
|
+
* The `id` of the mark element, derived from `rootId` with the mark part name
|
|
157
|
+
* appended.
|
|
158
|
+
*/
|
|
159
|
+
get markId(): string;
|
|
160
|
+
/**
|
|
161
|
+
* The `id` of the input element, equal to `fieldId` when provided, otherwise
|
|
162
|
+
* derived from `rootId` with the input part name appended.
|
|
163
|
+
*/
|
|
164
|
+
get inputId(): string;
|
|
165
|
+
/**
|
|
166
|
+
* The `id` of the field error element, derived from `rootId` with the error
|
|
167
|
+
* part name appended.
|
|
168
|
+
*/
|
|
169
|
+
get errorId(): string;
|
|
170
|
+
/**
|
|
171
|
+
* Adds the input, form submit, and form reset event listeners.
|
|
172
|
+
*/
|
|
173
|
+
connectedCallback(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Removes the input, form submit, and form reset event listeners.
|
|
176
|
+
*/
|
|
177
|
+
disconnectedCallback(): void;
|
|
178
|
+
/**
|
|
179
|
+
* The public validate method that calls the private `_validate()` method for
|
|
180
|
+
* manual, external validation.
|
|
181
|
+
*/
|
|
182
|
+
validate(): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Returns the paired password field's value or an empty string if the pair
|
|
185
|
+
* cannot be found.
|
|
186
|
+
*/
|
|
187
|
+
private _pairValue;
|
|
188
|
+
/**
|
|
189
|
+
* Defines and dispatches the validate event.
|
|
190
|
+
*/
|
|
191
|
+
private _dispatchValidate;
|
|
192
|
+
/**
|
|
193
|
+
* Handles the required condition validation, accepting empty non-required
|
|
194
|
+
* fields and non-empty required fields, otherwise dispatching and displaying
|
|
195
|
+
* the required error.
|
|
196
|
+
*/
|
|
197
|
+
private _validateRequired;
|
|
198
|
+
/**
|
|
199
|
+
* Handles the match condition validation, obtaining the paired field's value,
|
|
200
|
+
* comparing it to the confirm field's value, dispatching and displaying the
|
|
201
|
+
* match error if the values do not match.
|
|
202
|
+
*/
|
|
203
|
+
private _validateMatch;
|
|
204
|
+
/**
|
|
205
|
+
* Resets the `_invalid` and `_error` private props and dispatches the
|
|
206
|
+
* validate event, indicating a successfully validated and valid confirm.
|
|
207
|
+
*/
|
|
208
|
+
private _doValidateSuccess;
|
|
209
|
+
/**
|
|
210
|
+
* Handles validation and dispatches the success event if the required,
|
|
211
|
+
* length, and format conditions are met.
|
|
212
|
+
*/
|
|
213
|
+
private _validate;
|
|
214
|
+
/**
|
|
215
|
+
* Handles the input event, updating the private `_value` prop.
|
|
216
|
+
*/
|
|
217
|
+
private _handleInput;
|
|
218
|
+
/**
|
|
219
|
+
* Handles the form submit event, running the `_validate()` method and
|
|
220
|
+
* preventing the default submission behavior if invalid.
|
|
221
|
+
*/
|
|
222
|
+
private _handleFormSubmit;
|
|
223
|
+
/**
|
|
224
|
+
* Handles the form reset event, resetting the input element's `value` as well
|
|
225
|
+
* as the confirm field's private props: `_value`, `_invalid`, and `_error`.
|
|
226
|
+
*/
|
|
227
|
+
private _handleFormReset;
|
|
228
|
+
/**
|
|
229
|
+
* Conditionally returns the mark template for the field label. When `caret`
|
|
230
|
+
* and `required` are provided, the mark becomes an asterisk. When `mark` is
|
|
231
|
+
* provided, its value is rendered inside the element.
|
|
232
|
+
* If both a caret and custom text mark have their conditions met, the custom
|
|
233
|
+
* mark will be prioritised and rendered instead of the asterisk.
|
|
234
|
+
*/
|
|
235
|
+
private _renderMark;
|
|
236
|
+
/**
|
|
237
|
+
* Returns the field label template with the label text and optional mark.
|
|
238
|
+
*/
|
|
239
|
+
private _renderLabel;
|
|
240
|
+
/**
|
|
241
|
+
* Returns the field description template if `description` is defined.
|
|
242
|
+
*/
|
|
243
|
+
private _renderDescription;
|
|
244
|
+
/**
|
|
245
|
+
* Returns the field error template with the `_error` message if the
|
|
246
|
+
* `_invalid` state is `true`.
|
|
247
|
+
*/
|
|
248
|
+
private _renderError;
|
|
249
|
+
render(): import('../../../../../node_modules/lit-html').TemplateResult<1>;
|
|
250
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/web-components-vite';
|
|
2
|
+
declare const meta: Meta;
|
|
3
|
+
export default meta;
|
|
4
|
+
type Story = StoryObj;
|
|
5
|
+
export declare const Basic: Story;
|
|
6
|
+
export declare const Label: Story;
|
|
7
|
+
export declare const Placeholder: Story;
|
|
8
|
+
export declare const Description: Story;
|
|
9
|
+
export declare const Variant: Story;
|
|
10
|
+
export declare const Content: Story;
|
|
11
|
+
export declare const Disabled: Story;
|
|
12
|
+
export declare const Caret: Story;
|
|
13
|
+
export declare const Mark: Story;
|
|
14
|
+
export declare const Validate: Story;
|
|
15
|
+
export declare const Form: Story;
|
|
@@ -57,4 +57,13 @@ export type PasswordFieldProps = Omit<BaseFieldPropsWithLength, "content"> & {
|
|
|
57
57
|
content: PasswordFieldContent;
|
|
58
58
|
rules: PasswordFieldRule[];
|
|
59
59
|
};
|
|
60
|
+
export type ConfirmFieldValidateType = Exclude<BaseFieldValidateType, "format"> | "match";
|
|
61
|
+
export type ConfirmFieldVariant = PasswordFieldVariant;
|
|
62
|
+
export type ConfirmFieldContent = BaseFieldContent;
|
|
63
|
+
export type ConfirmFieldProps = Omit<BaseFieldProps, "content" | "formatError"> & {
|
|
64
|
+
variant: ConfirmFieldVariant;
|
|
65
|
+
content: ConfirmFieldContent;
|
|
66
|
+
pair: string;
|
|
67
|
+
matchError: string;
|
|
68
|
+
};
|
|
60
69
|
export {};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { SbConfirmField } from './_confirm-field';
|
|
1
2
|
import { SbEmailField } from './_email-field';
|
|
2
3
|
import { SbPasswordField } from './_password-field';
|
|
3
4
|
import { SbPhoneField } from './_phone-field';
|
|
4
5
|
import { SbUsernameField } from './_username-field';
|
|
5
|
-
export { SbEmailField, SbPasswordField, SbPhoneField, SbUsernameField };
|
|
6
|
+
export { SbConfirmField, SbEmailField, SbPasswordField, SbPhoneField, SbUsernameField, };
|
|
6
7
|
declare global {
|
|
7
8
|
interface HTMLElementTagNameMap {
|
|
8
9
|
"sb-email-field": SbEmailField;
|
|
9
10
|
"sb-phone-field": SbPhoneField;
|
|
10
11
|
"sb-username-field": SbUsernameField;
|
|
11
12
|
"sb-password-field": SbPasswordField;
|
|
13
|
+
"sb-confirm-field": SbConfirmField;
|
|
12
14
|
}
|
|
13
15
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { LitElement } from '../../../../../node_modules/lit';
|
|
2
|
+
import { FormSubmitProps, FormSubmitSize, FormSubmitSpinnerAlign, FormSubmitVariant } from './form.types';
|
|
3
|
+
/**
|
|
4
|
+
* A submit button for auth widget forms.
|
|
5
|
+
* @element sb-form-submit
|
|
6
|
+
*
|
|
7
|
+
* @part form-submit (rtg-button)
|
|
8
|
+
* @part form-submit-spinner (rtg-spinner): loading indicator
|
|
9
|
+
*
|
|
10
|
+
* @fires sb-form-submit:click { id, event }
|
|
11
|
+
*/
|
|
12
|
+
export declare class SbFormSubmit extends LitElement implements FormSubmitProps {
|
|
13
|
+
private static readonly _ROOT;
|
|
14
|
+
private static readonly _SPINNER;
|
|
15
|
+
/**
|
|
16
|
+
* The stable CSS part names exposed for external targeting.
|
|
17
|
+
*/
|
|
18
|
+
static get parts(): {
|
|
19
|
+
root: string;
|
|
20
|
+
spinner: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The name of the custom event fired on click.
|
|
24
|
+
*/
|
|
25
|
+
static get clickEventName(): string;
|
|
26
|
+
/**
|
|
27
|
+
* A unique substring for fallback part IDs generated.
|
|
28
|
+
*/
|
|
29
|
+
seed: string;
|
|
30
|
+
/**
|
|
31
|
+
* The `id` of the root part and the base of sub-part IDs.
|
|
32
|
+
*/
|
|
33
|
+
childId?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The visual variant of the button.
|
|
36
|
+
*/
|
|
37
|
+
variant: FormSubmitVariant;
|
|
38
|
+
/**
|
|
39
|
+
* The size of the button.
|
|
40
|
+
*/
|
|
41
|
+
size: FormSubmitSize;
|
|
42
|
+
/**
|
|
43
|
+
* The text used as the button label.
|
|
44
|
+
*/
|
|
45
|
+
label: string;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the loading spinner should be rendered before or after the label.
|
|
48
|
+
*/
|
|
49
|
+
spinnerAlign: FormSubmitSpinnerAlign;
|
|
50
|
+
/**
|
|
51
|
+
* When provided, the button reflects a disabled state.
|
|
52
|
+
*/
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* When provided, the button reflects a loading state.
|
|
56
|
+
*/
|
|
57
|
+
loading?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The event name as defined in the loginflow auth service.
|
|
60
|
+
*/
|
|
61
|
+
event?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the button is in a loading state.
|
|
64
|
+
*/
|
|
65
|
+
private _loading;
|
|
66
|
+
/**
|
|
67
|
+
* Overrides default behavior to render into light DOM.
|
|
68
|
+
*/
|
|
69
|
+
protected createRenderRoot(): this;
|
|
70
|
+
/**
|
|
71
|
+
* The `id` of the root element. Equal to `childId` when provided, otherwise
|
|
72
|
+
* derived from the component's part name and `seed`.
|
|
73
|
+
*/
|
|
74
|
+
get rootId(): string;
|
|
75
|
+
/**
|
|
76
|
+
* The `id` of the spinner element, derived from `rootId` with the spinner
|
|
77
|
+
* part name appended.
|
|
78
|
+
*/
|
|
79
|
+
get spinnerId(): string;
|
|
80
|
+
/**
|
|
81
|
+
* The loading state, derived from the private `_loading` and `loading` prop.
|
|
82
|
+
*/
|
|
83
|
+
get isLoading(): boolean | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Adds the click event listener.
|
|
86
|
+
*/
|
|
87
|
+
connectedCallback(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Removes the click event listener.
|
|
90
|
+
*/
|
|
91
|
+
disconnectedCallback(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Handles the click event, preventing execution when disabled/loading, and
|
|
94
|
+
* firing the click event.
|
|
95
|
+
*/
|
|
96
|
+
private _handleClick;
|
|
97
|
+
/**
|
|
98
|
+
* Returns the loading spinner template.
|
|
99
|
+
*/
|
|
100
|
+
private _renderSpinner;
|
|
101
|
+
render(): import('../../../../../node_modules/lit-html').TemplateResult<1>;
|
|
102
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/web-components-vite';
|
|
2
|
+
declare const meta: Meta;
|
|
3
|
+
export default meta;
|
|
4
|
+
type Story = StoryObj;
|
|
5
|
+
export declare const Basic: Story;
|
|
6
|
+
export declare const Variant: Story;
|
|
7
|
+
export declare const Size: Story;
|
|
8
|
+
export declare const Label: Story;
|
|
9
|
+
export declare const Disabled: Story;
|
|
10
|
+
export declare const Loading: Story;
|
|
11
|
+
export declare const SpinnerAlign: Story;
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import { RtgButtonBasicSize, RtgButtonBasicVariant } from '../../../../types';
|
|
1
|
+
import { IconAlign, RtgButtonBasicSize, RtgButtonBasicVariant } from '../../../../types';
|
|
2
|
+
export type FormSubmitVariant = RtgButtonBasicVariant;
|
|
3
|
+
export type FormSubmitSize = RtgButtonBasicSize;
|
|
4
|
+
export type FormSubmitSpinnerAlign = IconAlign;
|
|
5
|
+
export type FormSubmitProps = {
|
|
6
|
+
seed: string;
|
|
7
|
+
childId?: string;
|
|
8
|
+
variant: FormSubmitVariant;
|
|
9
|
+
size: FormSubmitSize;
|
|
10
|
+
label: string;
|
|
11
|
+
spinnerAlign: FormSubmitSpinnerAlign;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
event?: string;
|
|
15
|
+
};
|
|
2
16
|
export type SbFormSeparatorProps = {
|
|
3
17
|
seed: string;
|
|
4
18
|
childId?: string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { SbFormSeparator } from './_form-separator';
|
|
2
|
+
import { SbFormSubmit } from './_form-submit';
|
|
2
3
|
import { SbFormSwitch } from './_form-switch';
|
|
3
|
-
export { SbFormSeparator, SbFormSwitch };
|
|
4
|
+
export { SbFormSeparator, SbFormSubmit, SbFormSwitch };
|
|
4
5
|
declare global {
|
|
5
6
|
interface HTMLElementTagNameMap {
|
|
7
|
+
"sb-form-submit": SbFormSubmit;
|
|
6
8
|
"sb-form-separator": SbFormSeparator;
|
|
7
9
|
"sb-form-switch": SbFormSwitch;
|
|
8
10
|
}
|
|
@@ -10,7 +10,7 @@ export declare class SbAuthenticated extends LitElement {
|
|
|
10
10
|
* Defaults to environment variable, can be overridden via property.
|
|
11
11
|
*/
|
|
12
12
|
redirectUrl: string;
|
|
13
|
-
env
|
|
13
|
+
env: EnvConfig | null;
|
|
14
14
|
auth?: AuthState;
|
|
15
15
|
render(): import('../../../../node_modules/lit-html').TemplateResult<1> | typeof nothing;
|
|
16
16
|
}
|