@daffodil/design 0.90.0 → 0.92.3-rc.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/accordion/README.md +26 -38
- package/accordion/index.d.ts +9 -6
- package/article/README.md +66 -46
- package/article/index.d.ts +41 -0
- package/article/src/article-theme.scss +22 -0
- package/breadcrumb/README.md +6 -1
- package/breadcrumb/index.d.ts +65 -11
- package/breadcrumb/src/breadcrumb-theme.scss +1 -1
- package/button/README.md +36 -33
- package/button/index.d.ts +27 -6
- package/button/src/button/basic/button-theme.scss +4 -2
- package/button/src/button/button-base.scss +29 -6
- package/button/src/button/icon/icon-theme.scss +10 -6
- package/button/src/button/raised/raised-theme.scss +6 -4
- package/callout/README.md +15 -27
- package/card/README.md +36 -69
- package/card/index.d.ts +7 -41
- package/card/src/card-base-theme.scss +2 -5
- package/card/src/card-base.scss +2 -2
- package/checkbox/README.md +0 -0
- package/checkbox/index.d.ts +177 -0
- package/container/README.md +18 -23
- package/fesm2022/daffodil-design-accordion.mjs +34 -25
- package/fesm2022/daffodil-design-accordion.mjs.map +1 -1
- package/fesm2022/daffodil-design-article.mjs +283 -17
- package/fesm2022/daffodil-design-article.mjs.map +1 -1
- package/fesm2022/daffodil-design-breadcrumb.mjs +180 -28
- package/fesm2022/daffodil-design-breadcrumb.mjs.map +1 -1
- package/fesm2022/daffodil-design-button.mjs +90 -45
- package/fesm2022/daffodil-design-button.mjs.map +1 -1
- package/fesm2022/daffodil-design-callout.mjs +23 -23
- package/fesm2022/daffodil-design-callout.mjs.map +1 -1
- package/fesm2022/daffodil-design-card.mjs +43 -90
- package/fesm2022/daffodil-design-card.mjs.map +1 -1
- package/fesm2022/daffodil-design-checkbox.mjs +317 -0
- package/fesm2022/daffodil-design-checkbox.mjs.map +1 -0
- package/fesm2022/daffodil-design-container.mjs +8 -8
- package/fesm2022/daffodil-design-container.mjs.map +1 -1
- package/fesm2022/daffodil-design-form-field.mjs +56 -86
- package/fesm2022/daffodil-design-form-field.mjs.map +1 -1
- package/fesm2022/daffodil-design-form.mjs +62 -0
- package/fesm2022/daffodil-design-form.mjs.map +1 -0
- package/fesm2022/daffodil-design-hero.mjs +23 -23
- package/fesm2022/daffodil-design-hero.mjs.map +1 -1
- package/fesm2022/daffodil-design-image.mjs +19 -11
- package/fesm2022/daffodil-design-image.mjs.map +1 -1
- package/fesm2022/daffodil-design-input.mjs +18 -14
- package/fesm2022/daffodil-design-input.mjs.map +1 -1
- package/fesm2022/daffodil-design-link-set.mjs +25 -17
- package/fesm2022/daffodil-design-link-set.mjs.map +1 -1
- package/fesm2022/daffodil-design-list.mjs +16 -16
- package/fesm2022/daffodil-design-list.mjs.map +1 -1
- package/fesm2022/daffodil-design-loading-icon.mjs +8 -8
- package/fesm2022/daffodil-design-loading-icon.mjs.map +1 -1
- package/fesm2022/daffodil-design-media-gallery.mjs +13 -13
- package/fesm2022/daffodil-design-media-gallery.mjs.map +1 -1
- package/fesm2022/daffodil-design-menu.mjs +223 -60
- package/fesm2022/daffodil-design-menu.mjs.map +1 -1
- package/fesm2022/daffodil-design-modal.mjs +86 -83
- package/fesm2022/daffodil-design-modal.mjs.map +1 -1
- package/fesm2022/daffodil-design-native-select.mjs +47 -41
- package/fesm2022/daffodil-design-native-select.mjs.map +1 -1
- package/fesm2022/daffodil-design-navbar.mjs +25 -21
- package/fesm2022/daffodil-design-navbar.mjs.map +1 -1
- package/fesm2022/daffodil-design-notification.mjs +28 -64
- package/fesm2022/daffodil-design-notification.mjs.map +1 -1
- package/fesm2022/daffodil-design-paginator.mjs +11 -16
- package/fesm2022/daffodil-design-paginator.mjs.map +1 -1
- package/fesm2022/daffodil-design-progress-bar.mjs +10 -10
- package/fesm2022/daffodil-design-progress-bar.mjs.map +1 -1
- package/fesm2022/daffodil-design-quantity-field.mjs +19 -18
- package/fesm2022/daffodil-design-quantity-field.mjs.map +1 -1
- package/fesm2022/daffodil-design-radio.mjs +27 -56
- package/fesm2022/daffodil-design-radio.mjs.map +1 -1
- package/fesm2022/daffodil-design-select.mjs +6 -6
- package/fesm2022/daffodil-design-select.mjs.map +1 -1
- package/fesm2022/daffodil-design-sidebar.mjs +30 -60
- package/fesm2022/daffodil-design-sidebar.mjs.map +1 -1
- package/fesm2022/daffodil-design-spinner.mjs +99 -0
- package/fesm2022/daffodil-design-spinner.mjs.map +1 -0
- package/fesm2022/daffodil-design-switch.mjs +49 -106
- package/fesm2022/daffodil-design-switch.mjs.map +1 -1
- package/fesm2022/daffodil-design-tabs.mjs +35 -27
- package/fesm2022/daffodil-design-tabs.mjs.map +1 -1
- package/fesm2022/daffodil-design-tag.mjs +7 -7
- package/fesm2022/daffodil-design-tag.mjs.map +1 -1
- package/fesm2022/daffodil-design-text-snippet.mjs +6 -8
- package/fesm2022/daffodil-design-text-snippet.mjs.map +1 -1
- package/fesm2022/daffodil-design-textarea.mjs +6 -3
- package/fesm2022/daffodil-design-textarea.mjs.map +1 -1
- package/fesm2022/daffodil-design-toast.mjs +79 -80
- package/fesm2022/daffodil-design-toast.mjs.map +1 -1
- package/fesm2022/daffodil-design-tree.mjs +152 -112
- package/fesm2022/daffodil-design-tree.mjs.map +1 -1
- package/fesm2022/daffodil-design-youtube-player.mjs +6 -6
- package/fesm2022/daffodil-design-youtube-player.mjs.map +1 -1
- package/fesm2022/daffodil-design.mjs +559 -711
- package/fesm2022/daffodil-design.mjs.map +1 -1
- package/form/README.md +75 -0
- package/form/index.d.ts +27 -0
- package/form-field/README.md +74 -99
- package/form-field/index.d.ts +64 -42
- package/hero/README.md +5 -5
- package/image/README.md +27 -19
- package/image/index.d.ts +6 -1
- package/index.d.ts +282 -447
- package/input/README.md +36 -16
- package/input/index.d.ts +4 -3
- package/link-set/index.d.ts +9 -1
- package/list/README.md +2 -2
- package/loading-icon/README.md +1 -1
- package/loading-icon/index.d.ts +1 -1
- package/media-gallery/README.md +3 -3
- package/menu/README.md +107 -10
- package/menu/index.d.ts +143 -11
- package/modal/README.md +107 -17
- package/modal/index.d.ts +72 -35
- package/native-select/README.md +52 -15
- package/native-select/index.d.ts +8 -7
- package/navbar/README.md +23 -17
- package/navbar/index.d.ts +12 -2
- package/navbar/src/navbar-theme.scss +4 -46
- package/notification/README.md +4 -4
- package/notification/index.d.ts +7 -38
- package/package.json +1 -1
- package/paginator/README.md +42 -6
- package/paginator/index.d.ts +5 -9
- package/progress-bar/README.md +3 -3
- package/quantity-field/README.md +4 -4
- package/quantity-field/index.d.ts +4 -1
- package/radio/README.md +1 -1
- package/radio/index.d.ts +0 -16
- package/scss/layout/_breakpoint.scss +1 -1
- package/scss/theme.scss +9 -5
- package/scss/theming/_color-palettes.scss +19 -11
- package/scss/theming/_configure-theme.scss +11 -10
- package/scss/theming/_daff-theme.scss +5 -14
- package/scss/theming/_get-base-color.scss +2 -2
- package/scss/theming/_get-palette.scss +2 -2
- package/scss/theming/_get-theme-mode.scss +3 -3
- package/scss/theming/_index.scss +2 -1
- package/scss/theming/contrast/max-contrast/max-contrast.scss +3 -3
- package/scss/theming/contrast/text-contrast/text-contrast.scss +22 -16
- package/scss/theming/contrast/text-contrast/text-contrast.spec.scss +57 -0
- package/scss/theming/create-theme/_create-theme.scss +330 -0
- package/scss/theming/create-theme/_create-theme.spec.scss +122 -0
- package/scss/theming/create-theme/_index.scss +1 -0
- package/scss/theming/get-font-colors/_get-font-colors.scss +36 -0
- package/scss/theming/get-font-colors/_get-font-colors.spec.scss +72 -0
- package/scss/typography/mixins/_font-weight.scss +8 -14
- package/select/README.md +107 -4
- package/sidebar/README.md +6 -14
- package/sidebar/index.d.ts +3 -15
- package/spinner/README.md +57 -0
- package/spinner/index.d.ts +53 -0
- package/spinner/src/spinner-theme.scss +62 -0
- package/switch/README.md +21 -29
- package/switch/index.d.ts +18 -48
- package/switch/src/switch-theme.scss +26 -18
- package/tabs/README.md +1 -1
- package/tabs/index.d.ts +8 -5
- package/tag/README.md +24 -30
- package/tag/index.d.ts +1 -1
- package/tag/src/tag-theme.scss +11 -9
- package/text-snippet/README.md +1 -1
- package/text-snippet/src/text-snippet-theme.scss +12 -0
- package/textarea/README.md +36 -6
- package/textarea/index.d.ts +4 -4
- package/toast/README.md +4 -4
- package/tree/README.md +39 -22
- package/tree/index.d.ts +57 -96
- package/tree/src/tree-theme.scss +0 -4
- package/accordion/examples/index.d.ts +0 -20
- package/article/examples/index.d.ts +0 -50
- package/breadcrumb/examples/index.d.ts +0 -10
- package/button/examples/index.d.ts +0 -67
- package/callout/examples/index.d.ts +0 -41
- package/card/examples/index.d.ts +0 -62
- package/card/src/card/raised/raised-theme.scss +0 -28
- package/checkbox/examples/index.d.ts +0 -32
- package/container/examples/index.d.ts +0 -16
- package/fesm2022/daffodil-design-accordion-examples.mjs +0 -50
- package/fesm2022/daffodil-design-accordion-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-article-examples.mjs +0 -134
- package/fesm2022/daffodil-design-article-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-breadcrumb-examples.mjs +0 -46
- package/fesm2022/daffodil-design-breadcrumb-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-button-examples.mjs +0 -178
- package/fesm2022/daffodil-design-button-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-callout-examples.mjs +0 -116
- package/fesm2022/daffodil-design-callout-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-card-examples.mjs +0 -168
- package/fesm2022/daffodil-design-card-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-checkbox-examples.mjs +0 -76
- package/fesm2022/daffodil-design-checkbox-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-container-examples.mjs +0 -41
- package/fesm2022/daffodil-design-container-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-form-field-examples.mjs +0 -96
- package/fesm2022/daffodil-design-form-field-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-hero-examples.mjs +0 -121
- package/fesm2022/daffodil-design-hero-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-image-examples.mjs +0 -58
- package/fesm2022/daffodil-design-image-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-input-examples.mjs +0 -108
- package/fesm2022/daffodil-design-input-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-list-examples.mjs +0 -77
- package/fesm2022/daffodil-design-list-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-loading-icon-examples.mjs +0 -44
- package/fesm2022/daffodil-design-loading-icon-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-media-gallery-examples.mjs +0 -104
- package/fesm2022/daffodil-design-media-gallery-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-menu-examples.mjs +0 -50
- package/fesm2022/daffodil-design-menu-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-modal-examples.mjs +0 -51
- package/fesm2022/daffodil-design-modal-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-native-select-examples.mjs +0 -71
- package/fesm2022/daffodil-design-native-select-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-navbar-examples.mjs +0 -88
- package/fesm2022/daffodil-design-navbar-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-notification-examples.mjs +0 -102
- package/fesm2022/daffodil-design-notification-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-paginator-examples.mjs +0 -59
- package/fesm2022/daffodil-design-paginator-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-progress-bar-examples.mjs +0 -57
- package/fesm2022/daffodil-design-progress-bar-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-quantity-field-examples.mjs +0 -85
- package/fesm2022/daffodil-design-quantity-field-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-radio-examples.mjs +0 -34
- package/fesm2022/daffodil-design-radio-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-select-examples.mjs +0 -117
- package/fesm2022/daffodil-design-select-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-sidebar-examples.mjs +0 -109
- package/fesm2022/daffodil-design-sidebar-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-sticky-examples.mjs +0 -25
- package/fesm2022/daffodil-design-sticky-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-switch-examples.mjs +0 -110
- package/fesm2022/daffodil-design-switch-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-tabs-examples.mjs +0 -115
- package/fesm2022/daffodil-design-tabs-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-tag-examples.mjs +0 -125
- package/fesm2022/daffodil-design-tag-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-text-snippet-examples.mjs +0 -25
- package/fesm2022/daffodil-design-text-snippet-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-textarea-examples.mjs +0 -66
- package/fesm2022/daffodil-design-textarea-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-toast-examples.mjs +0 -147
- package/fesm2022/daffodil-design-toast-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-tree-examples.mjs +0 -104
- package/fesm2022/daffodil-design-tree-examples.mjs.map +0 -1
- package/form-field/examples/index.d.ts +0 -18
- package/hero/examples/index.d.ts +0 -45
- package/image/examples/index.d.ts +0 -10
- package/input/examples/index.d.ts +0 -10
- package/list/examples/index.d.ts +0 -29
- package/loading-icon/examples/index.d.ts +0 -16
- package/media-gallery/examples/index.d.ts +0 -38
- package/menu/examples/index.d.ts +0 -20
- package/modal/examples/index.d.ts +0 -15
- package/native-select/examples/index.d.ts +0 -10
- package/navbar/examples/index.d.ts +0 -31
- package/notification/examples/index.d.ts +0 -12
- package/paginator/examples/index.d.ts +0 -26
- package/progress-bar/examples/index.d.ts +0 -10
- package/quantity-field/examples/index.d.ts +0 -30
- package/radio/examples/index.d.ts +0 -13
- package/select/examples/index.d.ts +0 -28
- package/sidebar/examples/index.d.ts +0 -10
- package/sticky/examples/index.d.ts +0 -10
- package/switch/examples/index.d.ts +0 -46
- package/tabs/examples/index.d.ts +0 -12
- package/tag/examples/index.d.ts +0 -50
- package/text-snippet/examples/index.d.ts +0 -10
- package/textarea/examples/index.d.ts +0 -10
- package/toast/examples/index.d.ts +0 -56
- package/tree/examples/index.d.ts +0 -18
- /package/{form-field → form}/src/error-message/error-message-theme.scss +0 -0
- /package/{form-field → form}/src/hint/hint-theme.scss +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
@use 'true' as *;
|
|
2
|
+
@use 'sass:list';
|
|
3
|
+
@use 'sass:map';
|
|
4
|
+
@use '../create-theme' as *;
|
|
5
|
+
@use '../color-palettes' as palette;
|
|
6
|
+
@use '../configure-palette';
|
|
7
|
+
@use '../get-color';
|
|
8
|
+
@use '../get-base-color' as *;
|
|
9
|
+
@use './get-font-colors' as *;
|
|
10
|
+
@use '../configure-theme' as ct;
|
|
11
|
+
|
|
12
|
+
@include describe('daff-get-font-colors') {
|
|
13
|
+
$primary: configure-palette.daff-configure-palette(palette.$daff-blue, 60);
|
|
14
|
+
$secondary: configure-palette.daff-configure-palette(palette.$daff-purple, 60);
|
|
15
|
+
$tertiary: configure-palette.daff-configure-palette(palette.$daff-turquoise, 60);
|
|
16
|
+
$font-light: get-color.daff-color(palette.$daff-neutral, 10);
|
|
17
|
+
$font-dark: get-color.daff-color(palette.$daff-neutral, 100);
|
|
18
|
+
$default-dark: palette.$black;
|
|
19
|
+
$default-light: palette.$white;
|
|
20
|
+
$white: palette.$white;
|
|
21
|
+
$black: palette.$black;
|
|
22
|
+
|
|
23
|
+
@include it('returns theme text colors when provided') {
|
|
24
|
+
$config: (
|
|
25
|
+
'primary': $primary,
|
|
26
|
+
'secondary': $secondary,
|
|
27
|
+
'tertiary': $tertiary,
|
|
28
|
+
'text-color-default': $font-dark,
|
|
29
|
+
'text-color-inverse': $font-light
|
|
30
|
+
);
|
|
31
|
+
$theme: daff-create-theme($config);
|
|
32
|
+
|
|
33
|
+
$colors: daff-get-font-colors($theme);
|
|
34
|
+
@include assert-equal(list.nth($colors, 1), $font-dark);
|
|
35
|
+
@include assert-equal(list.nth($colors, 2), $font-light);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@include it('falls back to default text colors when no explicit text colors') {
|
|
39
|
+
$config: (
|
|
40
|
+
'primary': $primary,
|
|
41
|
+
'secondary': $secondary,
|
|
42
|
+
'tertiary': $tertiary
|
|
43
|
+
);
|
|
44
|
+
$theme: daff-create-theme($config);
|
|
45
|
+
|
|
46
|
+
$colors: daff-get-font-colors($theme);
|
|
47
|
+
@include assert-equal(list.nth($colors, 1), $default-dark);
|
|
48
|
+
@include assert-equal(list.nth($colors, 2), $default-light);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@include it('works when theme provides only one of the text colors') {
|
|
52
|
+
$config: (
|
|
53
|
+
'mode': 'dark',
|
|
54
|
+
'primary': $primary,
|
|
55
|
+
'secondary': $secondary,
|
|
56
|
+
'tertiary': $tertiary,
|
|
57
|
+
'text-color-default': $font-light
|
|
58
|
+
);
|
|
59
|
+
$theme: daff-create-theme($config);
|
|
60
|
+
|
|
61
|
+
$colors: daff-get-font-colors($theme);
|
|
62
|
+
@include assert-equal(list.nth($colors, 1), $font-light);
|
|
63
|
+
@include assert-equal(list.nth($colors, 2), $default-dark);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@include it('returns base colors when theme map is created with daff-configure-theme instead of daff-create-theme') {
|
|
67
|
+
$theme: ct.daff-configure-theme($primary, $secondary, $tertiary, 'light');
|
|
68
|
+
$colors: daff-get-font-colors($theme);
|
|
69
|
+
@include assert-equal(list.nth($colors, 1), $white);
|
|
70
|
+
@include assert-equal(list.nth($colors, 2), $black);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
@use '../utilities/variables';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// ```scss
|
|
12
|
-
// @use '@daffodil/design/scss/typography;
|
|
13
|
-
//
|
|
14
|
-
// @include typography.embolden;
|
|
15
|
-
// ```
|
|
16
|
-
//
|
|
3
|
+
/// @group Typography
|
|
4
|
+
/// @deprecated
|
|
5
|
+
/// @example scss
|
|
6
|
+
/// @use '@daffodil/design/scss/typography';
|
|
7
|
+
///
|
|
8
|
+
/// .title {
|
|
9
|
+
/// @include typography.embolden;
|
|
10
|
+
/// }
|
|
17
11
|
|
|
18
12
|
@mixin embolden() {
|
|
19
13
|
font-weight: variables.$bold-font-weight;
|
package/select/README.md
CHANGED
|
@@ -1,8 +1,111 @@
|
|
|
1
1
|
# Select
|
|
2
|
+
Select allows users to choose from a dropdown panel with a list of options, similar to a native `<select>` element but with an enhanced UI.
|
|
3
|
+
|
|
4
|
+
## Overview
|
|
5
|
+
Use select when you need users to pick one option from a list. It works like a standard dropdown menu but gives you more control over how options look and behave. It **cannot** be used by itself and must be contained within a [form field](/libs/design/form-field/README.md).
|
|
6
|
+
|
|
7
|
+
<daff-docs-example-viewer example="basic-select"></daff-docs-example-viewer>
|
|
2
8
|
|
|
3
9
|
## Usage
|
|
4
|
-
|
|
10
|
+
To use select, import the components directly into your custom component:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { DAFF_SELECT_COMPONENTS } from '@daffodil/design/select';
|
|
14
|
+
import { DAFF_FORM_FIELD_COMPONENTS } from '@daffodil/design/form-field';
|
|
15
|
+
|
|
16
|
+
@Component({
|
|
17
|
+
selector: 'custom-component',
|
|
18
|
+
templateUrl: './custom-component.component.html',
|
|
19
|
+
imports: [
|
|
20
|
+
DAFF_SELECT_COMPONENTS,
|
|
21
|
+
DAFF_FORM_FIELD_COMPONENTS,
|
|
22
|
+
],
|
|
23
|
+
})
|
|
24
|
+
export class CustomComponent {}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Anatomy
|
|
28
|
+
Select 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
|
+
Use `daffSelectOption` to render a list of options in the select panel:
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<daff-form-field>
|
|
35
|
+
<daff-form-label>Select an address</daff-form-label>
|
|
36
|
+
<daff-select [options]="options" [formControl]="selectControl">
|
|
37
|
+
<ng-template daffSelectOption let-option="option">
|
|
38
|
+
<div>{{option.name}}</div>
|
|
39
|
+
<div>{{option.street}}</div>
|
|
40
|
+
<div>{{option.city}}, {{option.state}} {{option.postcode}}</div>
|
|
41
|
+
</ng-template>
|
|
42
|
+
</daff-select>
|
|
43
|
+
</daff-form-field>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## States
|
|
47
|
+
|
|
48
|
+
### Disabled
|
|
49
|
+
Select can be disabled using Angular's reactive forms with `FormControl`.
|
|
50
|
+
|
|
51
|
+
<daff-docs-example-viewer example="disabled-select"></daff-docs-example-viewer>
|
|
52
|
+
|
|
53
|
+
### Error
|
|
54
|
+
Select 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 select is invalid and has been touched or submitted.
|
|
55
|
+
|
|
56
|
+
<daff-docs-example-viewer example="select-with-error"></daff-docs-example-viewer>
|
|
57
|
+
|
|
58
|
+
Multiple error messages can be displayed conditionally based on the type of validation error. The form field component handles the styling and positioning of error messages.
|
|
59
|
+
|
|
60
|
+
## Hints
|
|
61
|
+
Hints provide additional context or instructions to help users complete the select field correctly. Use `<daff-hint>` within the form field to display helpful information below the textarea. Unlike error messages, hints are always visible and provide guidance rather than validation feedback.
|
|
62
|
+
|
|
63
|
+
<daff-docs-example-viewer example="select-with-hint"></daff-docs-example-viewer>
|
|
64
|
+
|
|
65
|
+
## Accessibility
|
|
66
|
+
Select follows the [Combobox WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/). The combobox activator is combined with an inner `role="listbox"` element opened in a popup.
|
|
67
|
+
|
|
68
|
+
### Daffodil provides
|
|
69
|
+
- Automatic focus trapping when select panel is open
|
|
70
|
+
- `aria-labelledby` associated with the `<daff-form-label>`
|
|
71
|
+
- `aria-expanded` state management
|
|
72
|
+
|
|
73
|
+
### Developer responsibilities
|
|
74
|
+
- Always provide labels for accessibility. Use `<daff-form-label>` within `<daff-form-field>` for the best experience with auto-labelling controls.
|
|
75
|
+
|
|
76
|
+
### Keyboard interactions
|
|
77
|
+
**When select panel is closed:**
|
|
78
|
+
|
|
79
|
+
| Key | Action |
|
|
80
|
+
| --- | ------ |
|
|
81
|
+
| `Enter` / `Space` | Open the select panel |
|
|
82
|
+
| `Down Arrow` | Open the select panel |
|
|
83
|
+
| `Alt` + `Down Arrow` | Open the select panel |
|
|
84
|
+
| `Up Arrow` | Open the select panel |
|
|
85
|
+
| `Alt` + `Up Arrow` | Open the select panel |
|
|
86
|
+
|
|
87
|
+
**When select panel is opened:**
|
|
88
|
+
| Key | Action |
|
|
89
|
+
| --- | ------ |
|
|
90
|
+
| `Enter` / `Space` | Select the active option |
|
|
91
|
+
| `Escape` | Close the select panel and return focus to select |
|
|
92
|
+
| `Down Arrow` | Move focus to next option |
|
|
93
|
+
| `Up Arrow` | Move focus to previous option |
|
|
94
|
+
|
|
95
|
+
## Troubleshooting
|
|
96
|
+
|
|
97
|
+
### Error: DaffSelectComponent needs to be used with the DaffFormFieldComponent
|
|
98
|
+
This error is thrown when a select component is not used with a form field. Make sure your template looks like this:
|
|
5
99
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
100
|
+
```html
|
|
101
|
+
<daff-form-field>
|
|
102
|
+
<daff-form-label>Select an address</daff-form-label>
|
|
103
|
+
<daff-select [options]="options" [formControl]="selectControl">
|
|
104
|
+
<ng-template daffSelectOption let-option="option">
|
|
105
|
+
<div>{{option.name}}</div>
|
|
106
|
+
<div>{{option.street}}</div>
|
|
107
|
+
<div>{{option.city}}, {{option.state}} {{option.postcode}}</div>
|
|
108
|
+
</ng-template>
|
|
109
|
+
</daff-select>
|
|
110
|
+
</daff-form-field>
|
|
111
|
+
```
|
package/sidebar/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A sidebar is a component used to display additional information alongside a page
|
|
|
4
4
|
## Overview
|
|
5
5
|
Sidebars provide a flexible way to display additional content alongside the main page content. While commonly used for navigation, they can accommodate any type of content. Sidebars support multiple display modes, positions, and include optional header and footer components with minimal styling.
|
|
6
6
|
|
|
7
|
-
<
|
|
7
|
+
<daff-docs-example-viewer example="basic-sidebar"></daff-docs-example-viewer>
|
|
8
8
|
|
|
9
9
|
## Best practices
|
|
10
10
|
|
|
@@ -162,16 +162,16 @@ Use the `mode` property to control how the sidebar is displayed:
|
|
|
162
162
|
| `under` | Sits beneath the main content, which slides over the sidebar when closed. |
|
|
163
163
|
|
|
164
164
|
**Over and under sidebars**
|
|
165
|
-
<
|
|
165
|
+
<daff-docs-example-viewer example="over-and-under-sidebars"></daff-docs-example-viewer>
|
|
166
166
|
|
|
167
167
|
**Side fixed sidebar**
|
|
168
|
-
<
|
|
168
|
+
<daff-docs-example-viewer example="side-fixed-sidebar"></daff-docs-example-viewer>
|
|
169
169
|
|
|
170
170
|
**Two fixed sidebars on either side**
|
|
171
|
-
<
|
|
171
|
+
<daff-docs-example-viewer example="two-fixed-sidebars-either-side"></daff-docs-example-viewer>
|
|
172
172
|
|
|
173
173
|
**Fixed and over sidebar**
|
|
174
|
-
<
|
|
174
|
+
<daff-docs-example-viewer example="fixed-and-over-sidebar"></daff-docs-example-viewer>
|
|
175
175
|
|
|
176
176
|
### Sides
|
|
177
177
|
Use the `side` property to control the placement of the sidebar:
|
|
@@ -181,7 +181,7 @@ Use the `side` property to control the placement of the sidebar:
|
|
|
181
181
|
| `left` (default) | Places the sidebar on the left side of the screen. |
|
|
182
182
|
| `right` | Places the sidebar on the right side of the screen. |
|
|
183
183
|
|
|
184
|
-
<
|
|
184
|
+
<daff-docs-example-viewer example="sidebar-sides"></daff-docs-example-viewer>
|
|
185
185
|
|
|
186
186
|
## Customizations
|
|
187
187
|
|
|
@@ -214,11 +214,3 @@ body {
|
|
|
214
214
|
### Developer responsibilities
|
|
215
215
|
- Apply a meaningful `role` attribute (e.g., `role="navigation"`) to describe the sidebar's purpose
|
|
216
216
|
- Provide an `aria-label` when no title or header is present
|
|
217
|
-
|
|
218
|
-
## Deprecations
|
|
219
|
-
`[daffSidebarHeaderAction]` has been deprecated in favor of the `dismissible` property. Replace `[daffSidebarHeaderAction]` with `<daff-sidebar-header [dismissible]="true">`
|
|
220
|
-
|
|
221
|
-
```html
|
|
222
|
-
<daff-sidebar-header [dismissible]="true">
|
|
223
|
-
</daff-sidebar-header>
|
|
224
|
-
```
|
package/sidebar/index.d.ts
CHANGED
|
@@ -308,24 +308,12 @@ declare class DaffSidebarHeaderTitleDirective {
|
|
|
308
308
|
static ɵdir: i0.ɵɵDirectiveDeclaration<DaffSidebarHeaderTitleDirective, "[daffSidebarHeaderTitle]", never, {}, {}, never, never, true, never>;
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
/**
|
|
312
|
-
* @deprecated in favor of the `dismissible` property on `DaffSidebarHeaderComponent`. Deprecated in version 0.88.0. Will be removed in version 0.91.0.
|
|
313
|
-
*/
|
|
314
|
-
declare class DaffSidebarHeaderActionDirective {
|
|
315
|
-
/**
|
|
316
|
-
* @docs-private
|
|
317
|
-
*/
|
|
318
|
-
class: boolean;
|
|
319
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<DaffSidebarHeaderActionDirective, never>;
|
|
320
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<DaffSidebarHeaderActionDirective, "[daffSidebarHeaderAction]", never, {}, {}, never, never, true, never>;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
311
|
/**
|
|
324
312
|
* @deprecated in favor of {@link DAFF_SIDEBAR_COMPONENTS}. Deprecated in version 0.78.0. Will be removed in version 1.0.0.
|
|
325
313
|
*/
|
|
326
314
|
declare class DaffSidebarModule {
|
|
327
315
|
static ɵfac: i0.ɵɵFactoryDeclaration<DaffSidebarModule, never>;
|
|
328
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<DaffSidebarModule, never, [typeof i1$1.CommonModule, typeof i2.A11yModule, typeof DaffSidebarComponent, typeof DaffSidebarViewportComponent, typeof DaffSidebarHeaderComponent, typeof DaffSidebarFooterComponent, typeof DaffSidebarHeaderTitleDirective
|
|
316
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<DaffSidebarModule, never, [typeof i1$1.CommonModule, typeof i2.A11yModule, typeof DaffSidebarComponent, typeof DaffSidebarViewportComponent, typeof DaffSidebarHeaderComponent, typeof DaffSidebarFooterComponent, typeof DaffSidebarHeaderTitleDirective], [typeof DaffSidebarComponent, typeof DaffSidebarViewportComponent, typeof DaffSidebarHeaderComponent, typeof DaffSidebarFooterComponent, typeof DaffSidebarHeaderTitleDirective]>;
|
|
329
317
|
static ɵinj: i0.ɵɵInjectorDeclaration<DaffSidebarModule>;
|
|
330
318
|
}
|
|
331
319
|
|
|
@@ -376,7 +364,7 @@ declare const daffSidebarIsFloatingMode: (mode: DaffSidebarModeEnum) => boolean;
|
|
|
376
364
|
/**
|
|
377
365
|
* @docs-private
|
|
378
366
|
*/
|
|
379
|
-
declare const DAFF_SIDEBAR_COMPONENTS: readonly [typeof DaffSidebarComponent, typeof DaffSidebarViewportComponent, typeof DaffSidebarHeaderComponent, typeof DaffSidebarFooterComponent, typeof DaffSidebarHeaderTitleDirective
|
|
367
|
+
declare const DAFF_SIDEBAR_COMPONENTS: readonly [typeof DaffSidebarComponent, typeof DaffSidebarViewportComponent, typeof DaffSidebarHeaderComponent, typeof DaffSidebarFooterComponent, typeof DaffSidebarHeaderTitleDirective];
|
|
380
368
|
|
|
381
|
-
export { DAFF_SIDEBAR_COMPONENTS, DaffSidebarComponent, DaffSidebarFooterComponent,
|
|
369
|
+
export { DAFF_SIDEBAR_COMPONENTS, DaffSidebarComponent, DaffSidebarFooterComponent, DaffSidebarHeaderComponent, DaffSidebarHeaderTitleDirective, DaffSidebarModeEnum, DaffSidebarModule, DaffSidebarService, DaffSidebarSideEnum, DaffSidebarViewportComponent, daffSidebarIsDockedMode, daffSidebarIsFloatingMode };
|
|
382
370
|
export type { DaffSidebarMode, DaffSidebarRegistration, DaffSidebarSide };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Spinner
|
|
2
|
+
A spinner is an animated indicator that lets users know content or action is being loaded.
|
|
3
|
+
|
|
4
|
+
## Overview
|
|
5
|
+
Use a spinner to indicate a short, indeterminate loading state. It can appear on its own or paired with a loading message. For longer processes with measurable progress, use the [progress bar](/libs/design/progress-bar/README.md) component.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
To use spinner, import `DAFF_SPINNER_COMPONENTS` directly into your custom component:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { DAFF_SPINNER_COMPONENTS } from '@daffodil/design/spinner';
|
|
12
|
+
|
|
13
|
+
@Component({
|
|
14
|
+
selector: 'custom-component',
|
|
15
|
+
templateUrl: './custom-component.component.html',
|
|
16
|
+
imports: [
|
|
17
|
+
DAFF_SPINNER_COMPONENTS,
|
|
18
|
+
],
|
|
19
|
+
})
|
|
20
|
+
export class CustomComponent {}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Anatomy
|
|
24
|
+
|
|
25
|
+
### Label
|
|
26
|
+
Labels are used to describe the loading state and provide context for users. They are optional.
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
<daff-spinner>
|
|
30
|
+
<daff-spinner-label>Loading products...</daff-spinner-label>
|
|
31
|
+
</daff-spinner>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
<daff-docs-example-viewer example="spinner-with-label"></daff-docs-example-viewer>
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
### Colors
|
|
39
|
+
Use the `color` property to change the color of a spinner.
|
|
40
|
+
|
|
41
|
+
> Note: `dark`, `light`, and `theme` should be used on appropriate backgrounds for sufficient contrast.
|
|
42
|
+
|
|
43
|
+
<daff-docs-example-viewer example="spinner-colors"></daff-docs-example-viewer>
|
|
44
|
+
|
|
45
|
+
### Sizes
|
|
46
|
+
Use the `size` proeprty to change the size of a spinner. The default size is `md`.
|
|
47
|
+
|
|
48
|
+
<daff-docs-example-viewer example="spinner-sizes"></daff-docs-example-viewer>
|
|
49
|
+
|
|
50
|
+
## Accessibility
|
|
51
|
+
The spinner has `role="status"` which announces content changes to assistive technologies.
|
|
52
|
+
|
|
53
|
+
When using `<daff-spinner-label>`, the visible text serves as the accessible name. When no label is provided, the spinner defaults to `aria-label="loading"`. You can customize this with the `aria-label` input:
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<daff-spinner aria-label="Saving changes"></daff-spinner>
|
|
57
|
+
```
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import * as i1 from '@daffodil/design';
|
|
3
|
+
import { DaffSizableDirective, DaffSizeAllType } from '@daffodil/design';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Labels are used to describe the loading state and provide context for users.
|
|
7
|
+
* They are optional.
|
|
8
|
+
*
|
|
9
|
+
* @usage
|
|
10
|
+
* ```html
|
|
11
|
+
* <daff-spinner-label>Loading</daff-spinner-label>
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
declare class DaffSpinnerLabelDirective {
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffSpinnerLabelDirective, never>;
|
|
16
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<DaffSpinnerLabelDirective, "daff-spinner-label", never, {}, {}, never, never, true, never>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* DaffSpinnerComponent is an animated indicator that lets users know content or action is being loaded.
|
|
21
|
+
*/
|
|
22
|
+
declare class DaffSpinnerComponent {
|
|
23
|
+
private sizable;
|
|
24
|
+
/**
|
|
25
|
+
* @docs-private
|
|
26
|
+
*/
|
|
27
|
+
_label: DaffSpinnerLabelDirective;
|
|
28
|
+
private static readonly SIZE_MAP;
|
|
29
|
+
/**
|
|
30
|
+
* The `aria-label` for the spinner. Defaults to "loading".
|
|
31
|
+
*/
|
|
32
|
+
ariaLabel: i0.InputSignal<string>;
|
|
33
|
+
/**
|
|
34
|
+
* @docs-private
|
|
35
|
+
*/
|
|
36
|
+
get _ariaLabel(): string;
|
|
37
|
+
/**
|
|
38
|
+
* @docs-private
|
|
39
|
+
*
|
|
40
|
+
* The dimension (width/height) based on the size.
|
|
41
|
+
*/
|
|
42
|
+
get dimension(): number;
|
|
43
|
+
constructor(sizable: DaffSizableDirective<DaffSizeAllType>);
|
|
44
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffSpinnerComponent, never>;
|
|
45
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DaffSpinnerComponent, "daff-spinner", never, { "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; }, {}, ["_label"], ["daff-spinner-label"], true, [{ directive: typeof i1.DaffColorableDirective; inputs: { "color": "color"; }; outputs: {}; }, { directive: typeof i1.DaffSizableDirective; inputs: { "size": "size"; }; outputs: {}; }]>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @docs-private
|
|
50
|
+
*/
|
|
51
|
+
declare const DAFF_SPINNER_COMPONENTS: readonly [typeof DaffSpinnerComponent, typeof DaffSpinnerLabelDirective];
|
|
52
|
+
|
|
53
|
+
export { DAFF_SPINNER_COMPONENTS, DaffSpinnerComponent, DaffSpinnerLabelDirective };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
@use '../../scss/theming' as *;
|
|
2
|
+
|
|
3
|
+
@mixin daff-spinner-light-variant($loader-color) {
|
|
4
|
+
.daff-spinner__track,
|
|
5
|
+
.daff-spinner__path {
|
|
6
|
+
stroke: $loader-color;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.daff-spinner__path {
|
|
10
|
+
stroke: $loader-color;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@mixin daff-spinner-dark-variant($loader-color) {
|
|
15
|
+
.daff-spinner__track {
|
|
16
|
+
stroke: $loader-color;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.daff-spinner__path {
|
|
20
|
+
stroke: $loader-color;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@mixin daff-spinner-theme($theme) {
|
|
25
|
+
$primary: daff-get-palette($theme, primary);
|
|
26
|
+
$secondary: daff-get-palette($theme, secondary);
|
|
27
|
+
$tertiary: daff-get-palette($theme, tertiary);
|
|
28
|
+
$base: daff-get-base-color($theme, base);
|
|
29
|
+
$base-contrast: daff-get-base-color($theme, base-contrast);
|
|
30
|
+
$white: daff-get-base-color($theme, 'white');
|
|
31
|
+
$black: daff-get-base-color($theme, 'black');
|
|
32
|
+
|
|
33
|
+
.daff-spinner {
|
|
34
|
+
&.daff-primary {
|
|
35
|
+
@include daff-spinner-light-variant(daff-color($primary));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&.daff-secondary {
|
|
39
|
+
@include daff-spinner-light-variant(daff-color($secondary));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&.daff-tertiary {
|
|
43
|
+
@include daff-spinner-light-variant(daff-color($tertiary));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&.daff-theme {
|
|
47
|
+
@include daff-spinner-light-variant($base);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&.daff-theme-contrast {
|
|
51
|
+
@include daff-spinner-light-variant($base-contrast);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&.daff-dark {
|
|
55
|
+
@include daff-spinner-light-variant($black);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&.daff-light {
|
|
59
|
+
@include daff-spinner-light-variant($white);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
package/switch/README.md
CHANGED
|
@@ -4,10 +4,12 @@ A switch allows users to toggle the state of a single setting.
|
|
|
4
4
|
## Overview
|
|
5
5
|
Switches provide a way to toggle between two states with a visual indicator of the current state. A label can be positioned on the left, right, top, or bottom of the switch. The switch can be set to a disabled state, display a loading indicator, or show a custom error message.
|
|
6
6
|
|
|
7
|
+
<daff-docs-example-viewer example="basic-switch"></daff-docs-example-viewer>
|
|
8
|
+
|
|
7
9
|
## Usage
|
|
8
10
|
|
|
9
11
|
### Within a standalone component
|
|
10
|
-
To use
|
|
12
|
+
To use switch, import `DAFF_SWITCH_COMPONENTS` directly into your custom component:
|
|
11
13
|
|
|
12
14
|
```ts
|
|
13
15
|
import { DAFF_SWITCH_COMPONENTS } from '@daffodil/design/switch';
|
|
@@ -22,41 +24,31 @@ import { DAFF_SWITCH_COMPONENTS } from '@daffodil/design/switch';
|
|
|
22
24
|
export class CustomComponent {}
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
##
|
|
26
|
-
|
|
27
|
-
### Basic Switch
|
|
28
|
-
A basic switch can be toggled by setting the `checked` property to `true` or `false`. By default, this is set to `false`.
|
|
29
|
-
|
|
30
|
-
<design-land-example-viewer-container example="basic-switch"></design-land-example-viewer-container>
|
|
31
|
-
|
|
32
|
-
### Disabled Switch
|
|
33
|
-
A switch with the `disabled` property will be non-interactive.
|
|
34
|
-
|
|
35
|
-
<design-land-example-viewer-container example="disabled-switch"></design-land-example-viewer-container>
|
|
27
|
+
## Sizes
|
|
28
|
+
A small switch variant is available for dense layouts. Use the `size="sm"` property to render a more compact version of a switch.
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
A switch can display a loading state by setting `loading` to `true`. This will also disable the switch.
|
|
30
|
+
<daff-docs-example-viewer example="switch-sizes"></daff-docs-example-viewer>
|
|
39
31
|
|
|
40
|
-
|
|
32
|
+
## Disable a switch
|
|
33
|
+
Use the `disabled` property on switch to make it non-interactive.
|
|
41
34
|
|
|
42
|
-
|
|
43
|
-
An error message can be displayed by setting `error` to `true` and including a `daff-error-message` to show the message text.
|
|
35
|
+
<daff-docs-example-viewer example="disabled-switch"></daff-docs-example-viewer>
|
|
44
36
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
### Changing Label Position
|
|
48
|
-
The label position can be changed by setting the `labelPosition` property. The default position is `left`.
|
|
49
|
-
|
|
50
|
-
Supported positions: `left | right | top | bottom`
|
|
51
|
-
|
|
52
|
-
<design-land-example-viewer-container example="switch-label-positions"></design-land-example-viewer-container>
|
|
37
|
+
## Label positions
|
|
38
|
+
Use the `labelPosition` property to control the visual relationship between the switch and its label. By default, labels appear to the left of the switch control.
|
|
53
39
|
|
|
40
|
+
<daff-docs-example-viewer example="switch-label-positions"></daff-docs-example-viewer>
|
|
54
41
|
|
|
55
42
|
## Accessibility
|
|
56
|
-
|
|
43
|
+
Switch follows the [ARIA Switch design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/switch/).
|
|
44
|
+
|
|
45
|
+
- The switch control is implemented as a `<button>` element with a role of `switch`.
|
|
46
|
+
- `aria-checked` is used to indicate the switch's on/off state.
|
|
47
|
+
- Links the switch to its label `id` using `aria-labelledby`.
|
|
57
48
|
|
|
58
|
-
### Keyboard
|
|
49
|
+
### Keyboard interactions
|
|
59
50
|
| Key | Action |
|
|
60
51
|
| --- | ------ |
|
|
61
|
-
|
|
|
62
|
-
|
|
|
52
|
+
| Tab | Moves focus to or away from the switch control. |
|
|
53
|
+
| Space | Changes the switch's state between on and off. |
|
|
54
|
+
| Enter | Changes the switch's state between on and off. |
|
package/switch/index.d.ts
CHANGED
|
@@ -1,73 +1,43 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { EventEmitter } from '@angular/core';
|
|
3
|
+
import * as i1 from '@daffodil/design';
|
|
4
|
+
import { DaffSizableDirective, DaffSizeSmallType, DaffDisableable, DaffDisableableDirective } from '@daffodil/design';
|
|
3
5
|
|
|
4
|
-
type
|
|
6
|
+
type DaffSwitchLabelPosition = 'left' | 'right' | 'top' | 'bottom';
|
|
5
7
|
|
|
8
|
+
type DaffSwitchSize = DaffSizeSmallType;
|
|
6
9
|
/**
|
|
7
10
|
* The switch component provides a way to toggle between two settings.
|
|
8
11
|
*
|
|
9
12
|
* ```html
|
|
10
|
-
* <daff-switch>
|
|
11
|
-
* Label
|
|
12
|
-
* </daff-switch>
|
|
13
|
+
* <daff-switch>Label</daff-switch>
|
|
13
14
|
* ```
|
|
14
15
|
*/
|
|
15
|
-
declare class DaffSwitchComponent {
|
|
16
|
+
declare class DaffSwitchComponent extends DaffSizableDirective<DaffSwitchSize> implements DaffDisableable {
|
|
17
|
+
private disabledDirective;
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
get disabled(): any;
|
|
20
|
-
set disabled(value: any);
|
|
21
|
-
/**
|
|
22
|
-
* @docs-private
|
|
23
|
-
*/
|
|
24
|
-
get disabledAttribute(): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* @docs-private
|
|
27
|
-
*/
|
|
28
|
-
get ariaDisabled(): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* @docs-private
|
|
19
|
+
* The position of the label relative to the switch.
|
|
31
20
|
*/
|
|
32
|
-
|
|
21
|
+
labelPosition: DaffSwitchLabelPosition;
|
|
22
|
+
constructor(disabledDirective: DaffDisableableDirective);
|
|
33
23
|
/**
|
|
34
|
-
* Whether the switch is
|
|
24
|
+
* Whether the switch is disabled.
|
|
35
25
|
*/
|
|
36
|
-
|
|
26
|
+
get disabled(): any;
|
|
27
|
+
set disabled(value: any);
|
|
37
28
|
/**
|
|
38
29
|
* Current state of switch (on/off).
|
|
39
30
|
*/
|
|
40
31
|
checked: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* The position of the label relative to the switch.
|
|
43
|
-
*/
|
|
44
|
-
labelPosition: DaffLabelPosition;
|
|
45
|
-
/**
|
|
46
|
-
* Whether the switch shows an error.
|
|
47
|
-
*/
|
|
48
|
-
error: boolean;
|
|
49
32
|
/**
|
|
50
33
|
* @docs-private
|
|
51
34
|
*/
|
|
52
|
-
|
|
53
|
-
handleKeydown(event: KeyboardEvent): void;
|
|
35
|
+
labelId: string;
|
|
54
36
|
/**
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
private externalAriaLabel;
|
|
58
|
-
/**
|
|
59
|
-
* aria-label for the switch.
|
|
60
|
-
*/
|
|
61
|
-
ariaLabel: string;
|
|
62
|
-
/**
|
|
63
|
-
* A unique id for the switch.
|
|
64
|
-
*
|
|
65
|
-
* The `id` is automatically generated by linking the prefix 'daff-switch-' with an incrementing number. This value can be customized by passing a different `id` value via the component's `id` input.
|
|
37
|
+
* The unique id of the switch. Defaults to an autogenerated value. When using this,
|
|
38
|
+
* it's your responsibility to ensure that the id for each switch is unique.
|
|
66
39
|
*
|
|
67
|
-
*
|
|
68
|
-
* ```html
|
|
69
|
-
* <daff-switch [id]="'custom-id'"></daff-switch>
|
|
70
|
-
* ```
|
|
40
|
+
* It gets assigned to the `for` attribute on the `<label>` inside of the switch.
|
|
71
41
|
*/
|
|
72
42
|
id: string;
|
|
73
43
|
/**
|
|
@@ -79,7 +49,7 @@ declare class DaffSwitchComponent {
|
|
|
79
49
|
*/
|
|
80
50
|
onToggle(): void;
|
|
81
51
|
static ɵfac: i0.ɵɵFactoryDeclaration<DaffSwitchComponent, never>;
|
|
82
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<DaffSwitchComponent, "daff-switch", never, { "
|
|
52
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DaffSwitchComponent, "daff-switch", never, { "labelPosition": { "alias": "labelPosition"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "checked": { "alias": "checked"; "required": false; }; "id": { "alias": "id"; "required": false; }; }, { "toggled": "toggled"; }, never, ["*"], true, [{ directive: typeof i1.DaffSizableDirective; inputs: { "size": "size"; }; outputs: {}; }, { directive: typeof i1.DaffDisableableDirective; inputs: { "disabled": "disabled"; }; outputs: {}; }]>;
|
|
83
53
|
}
|
|
84
54
|
|
|
85
55
|
/**
|