@saasbase-io/core-elements 1.15.0 → 1.17.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.
@@ -26,6 +26,7 @@ export declare class SbConfirmField extends LitElement implements ConfirmFieldPr
26
26
  private static readonly _DESCRIPTION;
27
27
  private static readonly _INPUT;
28
28
  private static readonly _ERROR;
29
+ static readonly TAG: string;
29
30
  /**
30
31
  * The stable CSS part names exposed for external targeting.
31
32
  */
@@ -26,6 +26,7 @@ export declare class SbEmailField extends LitElement implements EmailFieldProps
26
26
  private static readonly _DESCRIPTION;
27
27
  private static readonly _INPUT;
28
28
  private static readonly _ERROR;
29
+ static readonly TAG: string;
29
30
  private static readonly _PATTERN;
30
31
  /**
31
32
  * The stable CSS part names exposed for external targeting.
@@ -26,6 +26,7 @@ export declare class SbIdentifierField extends LitElement implements IdentifierF
26
26
  private static readonly _DESCRIPTION;
27
27
  private static readonly _INPUT;
28
28
  private static readonly _ERROR;
29
+ static readonly TAG: string;
29
30
  /**
30
31
  * The stable CSS part names exposed for external targeting.
31
32
  */
@@ -26,6 +26,7 @@ export declare class SbPasswordField extends LitElement implements PasswordField
26
26
  private static readonly _DESCRIPTION;
27
27
  private static readonly _INPUT;
28
28
  private static readonly _ERROR;
29
+ static readonly TAG: string;
29
30
  private static readonly _PATTERNS;
30
31
  /**
31
32
  * The stable CSS part names exposed for external targeting.
@@ -26,6 +26,7 @@ export declare class SbPhoneField extends LitElement implements PhoneFieldProps
26
26
  private static readonly _DESCRIPTION;
27
27
  private static readonly _INPUT;
28
28
  private static readonly _ERROR;
29
+ static readonly TAG: string;
29
30
  private static readonly _PATTERN;
30
31
  /**
31
32
  * The stable CSS part names exposed for external targeting.
@@ -26,6 +26,7 @@ export declare class SbUsernameField extends LitElement implements UsernameField
26
26
  private static readonly _DESCRIPTION;
27
27
  private static readonly _INPUT;
28
28
  private static readonly _ERROR;
29
+ static readonly TAG: string;
29
30
  private static readonly _PATTERN;
30
31
  /**
31
32
  * The stable CSS part names exposed for external targeting.
@@ -12,6 +12,7 @@ import { FormSubmitProps, FormSubmitSize, FormSubmitSpinnerAlign, FormSubmitVari
12
12
  export declare class SbFormSubmit extends LitElement implements FormSubmitProps {
13
13
  private static readonly _ROOT;
14
14
  private static readonly _SPINNER;
15
+ static readonly TAG: string;
15
16
  /**
16
17
  * The stable CSS part names exposed for external targeting.
17
18
  */
@@ -0,0 +1,130 @@
1
+ import { LitElement } from '../../../../../node_modules/lit';
2
+ import { FormOnReset, FormOnSubmit, FormProps } from './form.types';
3
+ /**
4
+ * A composable form container that orchestrates validation, collects form data,
5
+ * and handles auth service communications.
6
+ * @element sb-form
7
+ *
8
+ * @part form (form)
9
+ *
10
+ * @fires sb-form:success { id, data, event }
11
+ * @fires sb-form:error { id, data, event, message }
12
+ * @fires sb-form:reset { id }
13
+ */
14
+ export declare class SbForm extends LitElement implements FormProps {
15
+ private static readonly _ROOT;
16
+ static readonly TAG: string;
17
+ static readonly SUCCESS_EVENT: string;
18
+ static readonly ERROR_EVENT: string;
19
+ static readonly RESET_EVENT: string;
20
+ /**
21
+ * The stable CSS part names exposed for external targeting.
22
+ */
23
+ static get parts(): {
24
+ root: string;
25
+ };
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
+ * When provided, called with the collected form data and the auth event
36
+ * string instead of the default `Auth.processLoginflowEvent` call.
37
+ * Use this to plug in custom submission logic or to handle auth externally.
38
+ */
39
+ onSubmit?: FormOnSubmit;
40
+ /**
41
+ * Called after the native form reset event fires.
42
+ */
43
+ onReset?: FormOnReset;
44
+ /**
45
+ * Auth event string captured from the most recent `sb-form-submit:click`
46
+ * event. Cleared after each submission attempt.
47
+ */
48
+ private _pendingEvent?;
49
+ /**
50
+ * Guards against double-submission while an async auth call is in-flight.
51
+ */
52
+ private _loading;
53
+ /**
54
+ * Overrides default behavior to render into light DOM.
55
+ */
56
+ protected createRenderRoot(): this;
57
+ /**
58
+ * The `id` of the root element. Equal to `childId` when provided, otherwise
59
+ * derived from the component's part name and `seed`.
60
+ */
61
+ get rootId(): string;
62
+ /**
63
+ * The native `<form>` element rendered as the root part.
64
+ */
65
+ private get _form();
66
+ /**
67
+ * All `sb-*-field` descendants inside the form element.
68
+ */
69
+ private get _fields();
70
+ /**
71
+ * The first `sb-form-submit` descendant inside the form element.
72
+ */
73
+ private get _submit();
74
+ /**
75
+ * Subscribes to the `sb-form-submit:click` event so the auth event string
76
+ * is captured before the native form `submit` event fires.
77
+ */
78
+ connectedCallback(): void;
79
+ /**
80
+ * Removes the `sb-form-submit:click` listener.
81
+ */
82
+ disconnectedCallback(): void;
83
+ /**
84
+ * Moves initial children (authored inside `<sb-form>` in markup) into the
85
+ * rendered `<form>` element. The DOM move disconnects and reconnects each
86
+ * custom-element child, letting field elements re-run `connectedCallback`
87
+ * and find the native form ancestor via `this.closest("form")`.
88
+ */
89
+ protected firstUpdated(): void;
90
+ /**
91
+ * Captures the auth event string emitted by `sb-form-submit` before the
92
+ * native form submit fires.
93
+ */
94
+ private _handleSubmitClick;
95
+ /**
96
+ * Dispatches a bubbling, composed custom event from `sb-form`.
97
+ */
98
+ private _dispatch;
99
+ /**
100
+ * Applies or removes the loading state on every field element and the
101
+ * submit button. `wasDisabled` records the pre-loading state so that
102
+ * fields that were already disabled are not re-enabled when loading ends.
103
+ */
104
+ private _setLoading;
105
+ /**
106
+ * Handles the native form submit event:
107
+ *
108
+ * 1. Always prevents the default browser navigation.
109
+ * 2. Adds temporary listeners for every `sb-*-field:validate` event on
110
+ * `this`. These events bubble from field elements and carry `{ name,
111
+ * value, valid }` in their detail — the exact values each field uses
112
+ * for its own validation. The temporary listener builds the form-data
113
+ * object as a side effect of the validation calls in step 3.
114
+ * 3. Calls `field.validate()` on every `sb-*-field` via `Array.map` (not
115
+ * `Array.every`) so ALL fields are validated and ALL inline errors are
116
+ * shown even when multiple fields are invalid simultaneously.
117
+ * 4. Removes the temporary validate listeners.
118
+ * 5. Aborts if any field returned `false`.
119
+ * 6. Calls `onSubmit` if provided, bypassing the default auth flow.
120
+ * 7. Otherwise calls `Auth.processLoginflowEvent` with the captured auth
121
+ * event string and the collected data, managing loading state throughout.
122
+ */
123
+ private _handleSubmit;
124
+ /**
125
+ * Handles the native form reset event. Field elements handle their own
126
+ * internal state reset via their own form-reset listeners.
127
+ */
128
+ private _handleReset;
129
+ render(): import('../../../../../node_modules/lit-html').TemplateResult<1>;
130
+ }
@@ -0,0 +1,2 @@
1
+ export declare const FIELD_SELECTORS: string;
2
+ export declare const FIELD_VALIDATE_EVENTS: string[];
@@ -0,0 +1,7 @@
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 Demo: Story;
6
+ export declare const OnSubmit: Story;
7
+ export declare const Events: Story;
@@ -1,4 +1,14 @@
1
1
  import { IconAlign, RtgButtonBasicSize, RtgButtonBasicVariant } from '../../../../types';
2
+ import { SbConfirmField, SbEmailField, SbIdentifierField, SbPasswordField, SbPhoneField, SbUsernameField } from '../field';
3
+ export type FormOnSubmit = (data: Record<string, string>, event?: string) => void;
4
+ export type FormOnReset = (event: Event) => void;
5
+ export type FormProps = {
6
+ seed: string;
7
+ childId?: string;
8
+ onSubmit?: FormOnSubmit;
9
+ onReset?: FormOnReset;
10
+ };
11
+ export type Field = SbEmailField | SbPhoneField | SbUsernameField | SbIdentifierField | SbPasswordField | SbConfirmField;
2
12
  export type FormSubmitVariant = RtgButtonBasicVariant;
3
13
  export type FormSubmitSize = RtgButtonBasicSize;
4
14
  export type FormSubmitSpinnerAlign = IconAlign;
@@ -1,9 +1,11 @@
1
+ import { SbForm } from './_form';
1
2
  import { SbFormSeparator } from './_form-separator';
2
3
  import { SbFormSubmit } from './_form-submit';
3
4
  import { SbFormSwitch } from './_form-switch';
4
- export { SbFormSeparator, SbFormSubmit, SbFormSwitch };
5
+ export { SbForm, SbFormSeparator, SbFormSubmit, SbFormSwitch };
5
6
  declare global {
6
7
  interface HTMLElementTagNameMap {
8
+ "sb-form": SbForm;
7
9
  "sb-form-submit": SbFormSubmit;
8
10
  "sb-form-separator": SbFormSeparator;
9
11
  "sb-form-switch": SbFormSwitch;