@daffodil/storefront 0.0.0-PLACEHOLDER

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/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@daffodil/storefront",
3
+ "version": "0.0.0-PLACEHOLDER",
4
+ "nx": {
5
+ "targets": {
6
+ "build": {
7
+ "outputs": [
8
+ "{workspaceRoot}/dist/storefront"
9
+ ]
10
+ }
11
+ }
12
+ },
13
+ "peerDependencies": {
14
+ "@angular/common": "0.0.0-PLACEHOLDER",
15
+ "@angular/core": "0.0.0-PLACEHOLDER",
16
+ "@daffodil/design": "0.0.0-PLACEHOLDER"
17
+ },
18
+ "dependencies": {
19
+ "tslib": "^2.3.0"
20
+ },
21
+ "sideEffects": false,
22
+ "exports": {
23
+ "./scss/theme": {
24
+ "sass": "./scss/theme.scss"
25
+ },
26
+ "./package.json": {
27
+ "default": "./package.json"
28
+ },
29
+ ".": {
30
+ "types": "./index.d.ts",
31
+ "default": "./fesm2022/daffodil-storefront.mjs"
32
+ },
33
+ "./carousel": {
34
+ "types": "./carousel/index.d.ts",
35
+ "default": "./fesm2022/daffodil-storefront-carousel.mjs"
36
+ },
37
+ "./quantity-field": {
38
+ "types": "./quantity-field/index.d.ts",
39
+ "default": "./fesm2022/daffodil-storefront-quantity-field.mjs"
40
+ },
41
+ "./theme-toggle": {
42
+ "types": "./theme-toggle/index.d.ts",
43
+ "default": "./fesm2022/daffodil-storefront-theme-toggle.mjs"
44
+ }
45
+ },
46
+ "description": "High-level ecommerce UI components built on @daffodil/design for storefront applications. Part of the Daffodil ecommerce framework.",
47
+ "module": "fesm2022/daffodil-storefront.mjs",
48
+ "typings": "index.d.ts"
49
+ }
@@ -0,0 +1,61 @@
1
+ # Quantity Field
2
+ Quantity field is a form control element that switches between native select dropdown and input field based on the quantity value.
3
+
4
+ ## Overview
5
+ The quantity field is designed for cart items and product quantities. By default, it displays as a select dropdown for values 1-10 and switches to an input field when a value of 10 or higher is selected. This behavior is configurable.
6
+
7
+ It **cannot** be used by itself and must be contained within a [form field](/libs/design/form-field/README.md).
8
+
9
+ <daff-docs-example-viewer example="basic-quantity-field"></daff-docs-example-viewer>
10
+
11
+ ## Usage
12
+ To use quantity field, import `DAFF_SF_QUANTITY_FIELD_COMPONENTS` directly into your custom component:
13
+
14
+ ```ts
15
+ import { DAFF_SF_QUANTITY_FIELD_COMPONENTS } from '@daffodil/storefront/quantity-field';
16
+
17
+ @Component({
18
+ selector: 'custom-component',
19
+ templateUrl: './custom-component.component.html',
20
+ imports: [
21
+ DAFF_SF_QUANTITY_FIELD_COMPONENTS,
22
+ ],
23
+ })
24
+ export class CustomComponent {}
25
+ ```
26
+
27
+ ## Anatomy
28
+ Quantity field must be used inside `<daff-form-field>` to enable proper state management and provide enhanced UI features such as hints, error messages, prefixes, and suffixes. The form field component also ensures accessibility compliance. For more details, see the [form field documentation](/libs/design/form-field/README.md).
29
+
30
+ ### Basic structure
31
+ ```html
32
+ <daff-form-field>
33
+ <daff-form-label>Quantity</daff-form-label>
34
+ <daff-sf-quantity-field [formControl]="qtyControl"></daff-sf-quantity-field>
35
+ </daff-form-field>
36
+ ```
37
+
38
+ ## Features
39
+
40
+ ### Range limits
41
+ The default allowed range of numbers is 1 to 500. This can be changed by passing in the desired min and max values as inputs. Note that this does not validate the actual input. It merely informs the select which options it should generate and sets the input's min and max attributes. See [input#min](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#min) and [input#max](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#max) for more information.
42
+
43
+ <daff-docs-example-viewer example="custom-range-quantity-field"></daff-docs-example-viewer>
44
+
45
+ ## Hints
46
+ Hints provide additional context or instructions to help users complete the input field correctly. Use `<daff-hint>` within the form field to display helpful information below the input. Unlike error messages, hints are always visible and provide guidance rather than validation feedback.
47
+
48
+ ## States
49
+
50
+ ### Disabled
51
+ Quantity field can be disabled in two ways: using Angular's reactive forms with `FormControl` or with the native HTML `disabled` attribute.
52
+
53
+ <daff-docs-example-viewer example="disabled-quantity-field"></daff-docs-example-viewer>
54
+
55
+ ### Error
56
+ Quantity field supports validation and error messages through Angular's form validation system. Use `<daff-error-message>` within the form field to display context-specific error messages. Error messages automatically appear when the quantity field is invalid and has been touched or submitted.
57
+
58
+ ## Accessibility
59
+ When `<daff-form-label>` is used within `<daff-form-field>`, the label automatically associates with the input using the `for` and `id` attributes.
60
+
61
+ If a `<daff-form-label>` is not specified, use the `<label>` element to associate text with form elements explicitly. The `for` attribute of the label must exactly match the `id` of the form control.
@@ -0,0 +1,257 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
3
+ import { NgControl, UntypedFormControl, ControlValueAccessor } from '@angular/forms';
4
+ import { Subject } from 'rxjs';
5
+ import { DaffFormFieldControl, DaffFormFieldComponent } from '@daffodil/design/form-field';
6
+ import { DaffInputComponent } from '@daffodil/design/input';
7
+ import { DaffNativeSelectComponent } from '@daffodil/design/native-select';
8
+
9
+ declare class DaffSfQuantityInputComponent implements OnInit, OnDestroy {
10
+ ngControl: NgControl;
11
+ private changeDetectorRef;
12
+ input: DaffInputComponent;
13
+ /**
14
+ * Event emitted when the quantity input gains focus
15
+ */
16
+ focusChange: _angular_core.OutputEmitterRef<void>;
17
+ /**
18
+ * Event emitted when the quantity input loses focus
19
+ */
20
+ blurChange: _angular_core.OutputEmitterRef<void>;
21
+ /**
22
+ * Event emitted when the quantity input's value changes
23
+ */
24
+ valueChange: _angular_core.OutputEmitterRef<number>;
25
+ quantity: _angular_core.ModelSignal<number>;
26
+ /**
27
+ * The minimum number for the quantity input field
28
+ */
29
+ min: _angular_core.InputSignal<number>;
30
+ /**
31
+ * The maximum number for the quantity input field
32
+ */
33
+ max: _angular_core.InputSignal<number>;
34
+ /**
35
+ * @docs-private
36
+ */
37
+ get focused(): boolean;
38
+ /**
39
+ * A new control for the nested native input.
40
+ * We don't bind the native input directly to the inherited form control
41
+ * to avoid triggering updates on the input event.
42
+ * Instead, we listen for the change event and manually patch form control values.
43
+ */
44
+ _inputControl: UntypedFormControl;
45
+ _destroyed: Subject<unknown>;
46
+ get value(): number;
47
+ set value(value: number);
48
+ constructor(ngControl: NgControl, changeDetectorRef: ChangeDetectorRef);
49
+ /**
50
+ * @docs-private
51
+ */
52
+ ngOnInit(): void;
53
+ ngOnDestroy(): void;
54
+ focus(): void;
55
+ /**
56
+ * Callback function fired when the value changes.
57
+ * Used to pass the value back up to the ngControl.
58
+ */
59
+ onValueChange(event: Event): void;
60
+ private setInputDisabled;
61
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DaffSfQuantityInputComponent, [{ optional: true; }, null]>;
62
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<DaffSfQuantityInputComponent, "daff-sf-quantity-input", never, { "quantity": { "alias": "quantity"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; }, { "focusChange": "focusChange"; "blurChange": "blurChange"; "valueChange": "valueChange"; "quantity": "quantityChange"; }, never, never, true, never>;
63
+ }
64
+
65
+ declare class DaffSfQuantitySelectComponent {
66
+ select: DaffNativeSelectComponent;
67
+ /**
68
+ * A new control for the nested native select.
69
+ * We don't bind the native select directly to the inherited form control
70
+ * to avoid triggering updates on the input event.
71
+ * Instead, we listen for the change event and manually patch form control values.
72
+ */
73
+ _selectControl: UntypedFormControl;
74
+ /**
75
+ * The minimum number selectable. Defaults to 1.
76
+ */
77
+ min: _angular_core.InputSignal<number>;
78
+ /**
79
+ * The maximum number selectable. Defaults to 10.
80
+ */
81
+ max: _angular_core.InputSignal<number>;
82
+ /**
83
+ * Property used to determine whether or not the select is
84
+ * used in a situation where the `max` isn't a true max.
85
+ */
86
+ extendable: _angular_core.InputSignal<boolean>;
87
+ /**
88
+ * Event emitted when the quantity select gains focus
89
+ */
90
+ focusChange: _angular_core.OutputEmitterRef<void>;
91
+ /**
92
+ * Event emitted when the quantity select loses focus
93
+ */
94
+ blurChange: _angular_core.OutputEmitterRef<void>;
95
+ /**
96
+ * Event emitted when the quantiy select's value changes
97
+ */
98
+ valueChange: _angular_core.OutputEmitterRef<number>;
99
+ quantity: _angular_core.InputSignal<unknown>;
100
+ disabled: _angular_core.InputSignal<unknown>;
101
+ constructor();
102
+ /**
103
+ * An input for easily making options for the `select`.
104
+ */
105
+ valueArray: _angular_core.Signal<number[]>;
106
+ get focused(): boolean;
107
+ focus(): void;
108
+ /**
109
+ * @docs-private
110
+ *
111
+ * Callback function fired when the value changes.
112
+ * Used to pass the value back up to the ngControl.
113
+ */
114
+ onValueChange(event: Event): void;
115
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DaffSfQuantitySelectComponent, never>;
116
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<DaffSfQuantitySelectComponent, "daff-sf-quantity-select", never, { "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "extendable": { "alias": "extendable"; "required": false; "isSignal": true; }; "quantity": { "alias": "quantity"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "focusChange": "focusChange"; "blurChange": "blurChange"; "valueChange": "valueChange"; }, never, never, true, never>;
117
+ }
118
+
119
+ declare class DaffSfQuantityFieldComponent extends DaffFormFieldControl<number> implements ControlValueAccessor, DaffFormFieldControl<number>, OnInit {
120
+ ngControl: NgControl;
121
+ private cd;
122
+ private formField;
123
+ /**
124
+ * @docs-private
125
+ */
126
+ quantity: _angular_core.WritableSignal<number>;
127
+ /**
128
+ * @docs-private
129
+ */
130
+ _inputHasBeenShown: _angular_core.WritableSignal<boolean>;
131
+ /**
132
+ * @docs-private
133
+ */
134
+ _showInputField: _angular_core.Signal<boolean>;
135
+ /**
136
+ * @docs-private
137
+ */
138
+ _showSelectField: _angular_core.Signal<boolean>;
139
+ /** @docs-private */
140
+ get controlType(): "native-input" | "native-select";
141
+ /**
142
+ * @docs-private
143
+ */
144
+ input: _angular_core.Signal<DaffSfQuantityInputComponent>;
145
+ /**
146
+ * @docs-private
147
+ */
148
+ select: _angular_core.Signal<DaffSfQuantitySelectComponent>;
149
+ /**
150
+ * The minimum valid value of the quantity field.
151
+ * Must be greater than or equal to 1.
152
+ */
153
+ min: _angular_core.InputSignal<number>;
154
+ /**
155
+ * The maximum valid value of the quantity field.
156
+ * Must be greater than `min`.
157
+ */
158
+ max: _angular_core.InputSignal<number>;
159
+ /**
160
+ * The maximum number allowed before the field switches from a dropdown to an input.
161
+ * When the value reaches this number, an input field is shown instead of a select.
162
+ * Default is 10.
163
+ */
164
+ selectMax: _angular_core.InputSignal<number>;
165
+ /**
166
+ * @docs-private
167
+ *
168
+ * Implemented as part of DaffFormFieldControl.
169
+ */
170
+ get focused(): boolean;
171
+ private _disabled;
172
+ /**
173
+ * @docs-private
174
+ *
175
+ * Implemented as part of DaffFormFieldControl.
176
+ */
177
+ get disabled(): boolean;
178
+ set disabled(value: boolean);
179
+ private _required;
180
+ /**
181
+ * @docs-private
182
+ *
183
+ * Implemented as part of DaffFormFieldControl.
184
+ */
185
+ get required(): boolean;
186
+ set required(value: boolean);
187
+ _destroyed: Subject<boolean>;
188
+ /**
189
+ * @docs-private
190
+ *
191
+ * Returns the lesser of max and selectMax.
192
+ */
193
+ get _maxFloor(): number;
194
+ private _focusSetWhenSwitching;
195
+ constructor(ngControl: NgControl, cd: ChangeDetectorRef, formField: DaffFormFieldComponent);
196
+ /**
197
+ * @docs-private
198
+ */
199
+ ngOnInit(): void;
200
+ private onChange;
201
+ private onTouched;
202
+ /**
203
+ * @docs-private
204
+ */
205
+ writeValue(quantity: number): void;
206
+ /**
207
+ * @docs-private
208
+ */
209
+ registerOnChange(fn: (quantity: number) => void): void;
210
+ /**
211
+ * @docs-private
212
+ */
213
+ registerOnTouched(fn: any): void;
214
+ /**
215
+ * @docs-private
216
+ */
217
+ setDisabledState(isDisabled: boolean): void;
218
+ /**
219
+ * @docs-private
220
+ *
221
+ * Implemented as part of DaffFormFieldControl.
222
+ */
223
+ focus(): void;
224
+ /**
225
+ * @docs-private
226
+ *
227
+ * Called when child components gain focus
228
+ */
229
+ _onChildFocus(): void;
230
+ /**
231
+ * @docs-private
232
+ *
233
+ * Called when child components lose focus
234
+ */
235
+ _onChildBlur(): void;
236
+ /**
237
+ * @docs-private
238
+ *
239
+ * Called when child components change value
240
+ */
241
+ _onChildValueChange(value: number): void;
242
+ /**
243
+ * Implemented as part of DaffFormFieldControl.
244
+ */
245
+ get value(): number;
246
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DaffSfQuantityFieldComponent, [{ optional: true; self: true; }, null, { optional: true; }]>;
247
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<DaffSfQuantityFieldComponent, "daff-sf-quantity-field", never, { "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "selectMax": { "alias": "selectMax"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; }; "required": { "alias": "required"; "required": false; }; }, {}, never, never, true, never>;
248
+ static ngAcceptInputType_disabled: unknown;
249
+ static ngAcceptInputType_required: unknown;
250
+ }
251
+
252
+ /**
253
+ * @docs-private
254
+ */
255
+ declare const DAFF_SF_QUANTITY_FIELD_COMPONENTS: readonly [typeof DaffSfQuantityFieldComponent];
256
+
257
+ export { DAFF_SF_QUANTITY_FIELD_COMPONENTS, DaffSfQuantityFieldComponent };
@@ -0,0 +1,5 @@
1
+ @use '../carousel/src/carousel-theme' as carousel;
2
+
3
+ @mixin daff-sf-component-themes($theme) {
4
+ @include carousel.daff-sf-carousel-theme($theme);
5
+ }
@@ -0,0 +1,26 @@
1
+ # Theme Toggle
2
+ Theme toggle allows users to switch between light and dark themes.
3
+
4
+ ## Overview
5
+ Theme toggle persists the user's preference and integrates with `@daffodil/design`'s theming system.
6
+
7
+ <daff-docs-example-viewer example="basic-theme-toggle"></daff-docs-example-viewer>
8
+
9
+ ## Usage
10
+ To use theme toggle, import `DaffSfThemeToggleComponent` into your custom component:
11
+
12
+ ```ts
13
+ import { DaffSfThemeToggleComponent } from '@daffodil/storefront/theme-toggle';
14
+
15
+ @Component({
16
+ selector: 'custom-component',
17
+ templateUrl: './custom-component.component.html',
18
+ imports: [
19
+ DaffSfThemeToggleComponent,
20
+ ],
21
+ })
22
+ export class CustomComponent {}
23
+ ```
24
+
25
+ ## Accessibility
26
+ Theme toggle includes an `aria-label` that updates based on the current theme. It uses `aria-live="polite"` to announce theme changes to assistive technologies.
@@ -0,0 +1,24 @@
1
+ import * as _fortawesome_fontawesome_common_types from '@fortawesome/fontawesome-common-types';
2
+ import * as _angular_core from '@angular/core';
3
+ import { DaffTheme, DaffThemingService } from '@daffodil/design';
4
+
5
+ /**
6
+ * DaffSfThemeToggleComponent renders a button that toggles the active
7
+ * theme between light and dark.
8
+ */
9
+ declare class DaffSfThemeToggleComponent {
10
+ private themeService;
11
+ /** @docs-private */
12
+ theme: _angular_core.Signal<DaffTheme>;
13
+ /** @docs-private */
14
+ ariaLabel: _angular_core.Signal<"Switch to light mode" | "Switch to dark mode">;
15
+ /** @docs-private */
16
+ icon: _angular_core.Signal<_fortawesome_fontawesome_common_types.IconDefinition>;
17
+ constructor(themeService: DaffThemingService);
18
+ /** @docs-private */
19
+ toggleTheme(): void;
20
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DaffSfThemeToggleComponent, never>;
21
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<DaffSfThemeToggleComponent, "daff-sf-theme-toggle", never, {}, {}, never, never, true, never>;
22
+ }
23
+
24
+ export { DaffSfThemeToggleComponent };