@saasbase-io/core-elements 1.16.0 → 1.18.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.
@@ -1,61 +1,77 @@
1
1
  import { LitElement } from '../../../../../node_modules/lit';
2
- import { FormSwitchButtonSize, FormSwitchButtonVariant, FormSwitchVariant, SbFormSwitchProps } from './form.types';
2
+ import { FormSwitchProps, FormSwitchSize, FormSwitchType, FormSwitchVariant } from './form.types';
3
3
  /**
4
- * Clickable element for switching between auth widgets.
4
+ * A button for switching between auth widgets.
5
5
  * @element sb-form-switch
6
6
  *
7
- * @slot form-switch (rtg-field-description/rtg-button)
8
- * @slot form-switch-link (a): 'clickable' part when variant is `"default"`
7
+ * @part form-switch (rtg-button)
8
+ * @part form-switch-wrapper (div): contains root and optional prompt
9
+ * @part form-switch-prompt (p): prompt text for `"default"` form switches
10
+ * @part form-swith-spinner (rtg-spinner): loading indicator
11
+ *
12
+ * @fires sb-form-switch:click { id, event }
9
13
  */
10
- export declare class SbFormSwitch extends LitElement implements SbFormSwitchProps {
14
+ export declare class SbFormSwitch extends LitElement implements FormSwitchProps {
11
15
  private static readonly _ROOT;
12
- private static readonly _LINK;
16
+ private static readonly _WRAPPER;
17
+ private static readonly _PROMPT;
18
+ private static readonly _SPINNER;
19
+ static readonly TAG: string;
20
+ static readonly CLICK_EVENT: string;
13
21
  /**
14
22
  * The stable CSS part names exposed for external targeting.
15
23
  */
16
24
  static get parts(): {
17
25
  root: string;
18
- link: string;
26
+ wrapper: string;
27
+ prompt: string;
28
+ spinner: string;
19
29
  };
20
30
  /**
21
- * A unique value used as a substring in the generated part/child IDs, when
22
- * the `child-id` prop is not provided.
31
+ * A unique substring for fallback part IDs generated.
23
32
  */
24
33
  seed: string;
25
34
  /**
26
- * The `id` value given to the root child/part and used as the base of other
27
- * child/part IDs.
35
+ * The `id` of the root part and the base of sub-part IDs.
28
36
  */
29
37
  childId?: string;
30
38
  /**
31
- * The variant of the form switch, determining whether a text-based link or
32
- * button element is rendered.
39
+ * Whether the form switch is a link button with optional prompt text, or a
40
+ * configurable button element.
41
+ */
42
+ type: FormSwitchType;
43
+ /**
44
+ * The visual variant of the (button) form switch.
33
45
  */
34
46
  variant: FormSwitchVariant;
35
47
  /**
36
- * The text used as the form switch link/button label.
48
+ * The size of the (button) form switch.
49
+ */
50
+ size: FormSwitchSize;
51
+ /**
52
+ * The text used as the form switch button label.
37
53
  */
38
54
  label: string;
39
55
  /**
40
- * Optional text which precedes the switch link in a `"default"` form switch.
56
+ * Optional text which precedes the button in a `"default"` form switch.
41
57
  */
42
58
  prompt?: string;
43
59
  /**
44
- * When provided, the switch element reflects a disabled state.
60
+ * When provided, the switch reflects a disabled state.
45
61
  */
46
62
  disabled?: boolean;
47
63
  /**
48
- * The visual variant of the form switch button.
64
+ * When provided, the switch reflects a loading state.
49
65
  */
50
- buttonVariant: FormSwitchButtonVariant;
66
+ loading?: boolean;
51
67
  /**
52
- * The size of the form switch button.
68
+ * The event name as defined in the loginflow auth service.
53
69
  */
54
- buttonSize: FormSwitchButtonSize;
70
+ event?: string;
55
71
  /**
56
- * The event identifier/name as defined in `auth-svc`.
72
+ * Whether the switch is in a loading state.
57
73
  */
58
- event?: string;
74
+ private _loading;
59
75
  /**
60
76
  * Overrides default behavior to render into light DOM.
61
77
  */
@@ -66,13 +82,41 @@ export declare class SbFormSwitch extends LitElement implements SbFormSwitchProp
66
82
  */
67
83
  get rootId(): string;
68
84
  /**
69
- * The `id` of the link anchor element. Always derived from `rootId` with the
70
- * link part segment appended.
85
+ * The `id` of the wrapper element, derived from `rootId` and the part name.
86
+ */
87
+ get wrapperId(): string;
88
+ /**
89
+ * The `id` of the prompt element, derived from `rootId` and the part name.
90
+ */
91
+ get promptId(): string;
92
+ /**
93
+ * The `id` of the spinner element, derived from `rootId` and the part name.
94
+ */
95
+ get spinnerId(): string;
96
+ /**
97
+ * The loading state, derived from the private `_loading` and `loading` prop.
98
+ */
99
+ get isLoading(): boolean | undefined;
100
+ /**
101
+ * Adds the click event listener.
102
+ */
103
+ connectedCallback(): void;
104
+ /**
105
+ * Removes the click event listener.
106
+ */
107
+ disconnectedCallback(): void;
108
+ /**
109
+ * Handles the click event, preventing execution when disabled/loading, firing
110
+ * the click event, and emitting to auth service.
111
+ */
112
+ private _handleClick;
113
+ /**
114
+ * Returns the prompt paragraph template for `"default"` form switches.
71
115
  */
72
- get linkId(): string;
116
+ private _renderPrompt;
73
117
  /**
74
- * Returns the link template for a `"default"` form switch.
118
+ * Returns the loading spinner template.
75
119
  */
76
- private _renderLink;
120
+ private _renderSpinner;
77
121
  render(): import('../../../../../node_modules/lit-html').TemplateResult<1>;
78
122
  }
@@ -3,8 +3,9 @@ declare const meta: Meta;
3
3
  export default meta;
4
4
  type Story = StoryObj;
5
5
  export declare const Basic: Story;
6
- export declare const Variant: Story;
6
+ export declare const Type: Story;
7
7
  export declare const Label: Story;
8
8
  export declare const Prompt: Story;
9
9
  export declare const Disabled: Story;
10
+ export declare const Loading: Story;
10
11
  export declare const Button: Story;
@@ -28,17 +28,18 @@ export type SbFormSeparatorProps = {
28
28
  childId?: string;
29
29
  content?: string;
30
30
  };
31
- export type FormSwitchVariant = "default" | "button";
32
- export type FormSwitchButtonVariant = RtgButtonBasicVariant;
33
- export type FormSwitchButtonSize = RtgButtonBasicSize;
34
- export type SbFormSwitchProps = {
31
+ export type FormSwitchType = "default" | "button";
32
+ export type FormSwitchVariant = RtgButtonBasicVariant;
33
+ export type FormSwitchSize = RtgButtonBasicSize;
34
+ export type FormSwitchProps = {
35
35
  seed: string;
36
36
  childId?: string;
37
+ type: FormSwitchType;
37
38
  variant: FormSwitchVariant;
39
+ size: FormSwitchSize;
38
40
  label: string;
39
41
  prompt?: string;
40
42
  disabled?: boolean;
41
- buttonVariant: FormSwitchButtonVariant;
42
- buttonSize: FormSwitchButtonSize;
43
+ loading?: boolean;
43
44
  event?: string;
44
45
  };