@nectary/components 2.4.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/index.d.ts +11 -0
- package/accordion/index.js +86 -0
- package/accordion/types.d.ts +21 -0
- package/accordion/types.js +1 -0
- package/accordion-item/index.d.ts +14 -0
- package/accordion-item/index.js +95 -0
- package/accordion-item/types.d.ts +36 -0
- package/accordion-item/types.js +1 -0
- package/accordion-item/utils.d.ts +2 -0
- package/accordion-item/utils.js +1 -0
- package/action-menu/index.d.ts +11 -0
- package/action-menu/index.js +195 -0
- package/action-menu/types.d.ts +13 -0
- package/action-menu/types.js +1 -0
- package/action-menu-option/index.d.ts +12 -0
- package/action-menu-option/index.js +82 -0
- package/action-menu-option/types.d.ts +23 -0
- package/action-menu-option/types.js +1 -0
- package/action-menu-option/utils.d.ts +2 -0
- package/action-menu-option/utils.js +3 -0
- package/alert/index.d.ts +14 -0
- package/alert/index.js +48 -0
- package/alert/types.d.ts +18 -0
- package/alert/types.js +1 -0
- package/alert/utils.d.ts +2 -0
- package/alert/utils.js +1 -0
- package/avatar/index.d.ts +11 -0
- package/avatar/index.js +94 -0
- package/avatar/types.d.ts +37 -0
- package/avatar/types.js +1 -0
- package/avatar/utils.d.ts +4 -0
- package/avatar/utils.js +7 -0
- package/badge/index.d.ts +11 -0
- package/badge/index.js +114 -0
- package/badge/types.d.ts +34 -0
- package/badge/types.js +1 -0
- package/badge/utils.d.ts +2 -0
- package/badge/utils.js +1 -0
- package/button/index.d.ts +11 -0
- package/button/index.js +168 -0
- package/button/types.d.ts +45 -0
- package/button/types.js +1 -0
- package/button/utils.d.ts +2 -0
- package/button/utils.js +1 -0
- package/card/index.d.ts +13 -0
- package/card/index.js +133 -0
- package/card/types.d.ts +28 -0
- package/card/types.js +1 -0
- package/card-container/index.d.ts +11 -0
- package/card-container/index.js +11 -0
- package/card-container/types.d.ts +3 -0
- package/card-container/types.js +1 -0
- package/chat/index.d.ts +11 -0
- package/chat/index.js +11 -0
- package/chat/types.d.ts +3 -0
- package/chat/types.js +1 -0
- package/chat-block/index.d.ts +11 -0
- package/chat-block/index.js +86 -0
- package/chat-block/types.d.ts +30 -0
- package/chat-block/types.js +1 -0
- package/chat-bubble/index.d.ts +11 -0
- package/chat-bubble/index.js +41 -0
- package/chat-bubble/types.d.ts +20 -0
- package/chat-bubble/types.js +1 -0
- package/chat-bubble/utils.d.ts +3 -0
- package/chat-bubble/utils.js +2 -0
- package/checkbox/index.d.ts +11 -0
- package/checkbox/index.js +126 -0
- package/checkbox/types.d.ts +49 -0
- package/checkbox/types.js +1 -0
- package/chip/index.d.ts +13 -0
- package/chip/index.js +144 -0
- package/chip/types.d.ts +37 -0
- package/chip/types.js +1 -0
- package/chip/utils.d.ts +2 -0
- package/chip/utils.js +6 -0
- package/code-tag/index.d.ts +11 -0
- package/code-tag/index.js +31 -0
- package/code-tag/types.d.ts +11 -0
- package/code-tag/types.js +1 -0
- package/color-menu/index.d.ts +11 -0
- package/color-menu/index.js +308 -0
- package/color-menu/types.d.ts +32 -0
- package/color-menu/types.js +1 -0
- package/color-menu/utils.d.ts +1 -0
- package/color-menu/utils.js +11 -0
- package/color-menu-option/index.d.ts +13 -0
- package/color-menu-option/index.js +48 -0
- package/color-menu-option/types.d.ts +11 -0
- package/color-menu-option/types.js +1 -0
- package/color-menu-option/utils.d.ts +1 -0
- package/color-menu-option/utils.js +11 -0
- package/color-swatch/index.d.ts +12 -0
- package/color-swatch/index.js +54 -0
- package/color-swatch/types.d.ts +11 -0
- package/color-swatch/types.js +1 -0
- package/color-swatch/utils.d.ts +2 -0
- package/color-swatch/utils.js +6 -0
- package/colors.json +88 -0
- package/date-picker/index.d.ts +14 -0
- package/date-picker/index.js +381 -0
- package/date-picker/types.d.ts +70 -0
- package/date-picker/types.js +1 -0
- package/date-picker/utils.d.ts +28 -0
- package/date-picker/utils.js +142 -0
- package/dialog/index.d.ts +15 -0
- package/dialog/index.js +144 -0
- package/dialog/types.d.ts +28 -0
- package/dialog/types.js +1 -0
- package/dialog/utils.d.ts +2 -0
- package/dialog/utils.js +18 -0
- package/emoji/index.d.ts +11 -0
- package/emoji/index.js +46 -0
- package/emoji/types.d.ts +11 -0
- package/emoji/types.js +1 -0
- package/emoji/utils.d.ts +1 -0
- package/emoji/utils.js +42 -0
- package/emoji-picker/data.json +1 -0
- package/emoji-picker/index.d.ts +22 -0
- package/emoji-picker/index.js +304 -0
- package/emoji-picker/types.d.ts +26 -0
- package/emoji-picker/types.js +1 -0
- package/field/index.d.ts +11 -0
- package/field/index.js +112 -0
- package/field/types.d.ts +35 -0
- package/field/types.js +1 -0
- package/file-drop/index.d.ts +13 -0
- package/file-drop/index.js +205 -0
- package/file-drop/types.d.ts +50 -0
- package/file-drop/types.js +1 -0
- package/file-drop/utils.d.ts +2 -0
- package/file-drop/utils.js +31 -0
- package/file-picker/index.d.ts +11 -0
- package/file-picker/index.js +103 -0
- package/file-picker/types.d.ts +32 -0
- package/file-picker/types.js +1 -0
- package/file-picker/utils.d.ts +1 -0
- package/file-picker/utils.js +8 -0
- package/file-status/index.d.ts +14 -0
- package/file-status/index.js +61 -0
- package/file-status/types.d.ts +18 -0
- package/file-status/types.js +1 -0
- package/file-status/utils.d.ts +2 -0
- package/file-status/utils.js +1 -0
- package/flag/index.d.ts +11 -0
- package/flag/index.js +46 -0
- package/flag/types.d.ts +11 -0
- package/flag/types.js +1 -0
- package/flag/utils.d.ts +1 -0
- package/flag/utils.js +17 -0
- package/grid/index.d.ts +11 -0
- package/grid/index.js +11 -0
- package/grid/types.d.ts +3 -0
- package/grid/types.js +1 -0
- package/grid-item/index.d.ts +11 -0
- package/grid-item/index.js +35 -0
- package/grid-item/types.d.ts +17 -0
- package/grid-item/types.js +1 -0
- package/help-tooltip/index.d.ts +13 -0
- package/help-tooltip/index.js +74 -0
- package/help-tooltip/types.d.ts +3 -0
- package/help-tooltip/types.js +1 -0
- package/horizontal-stepper/index.d.ts +11 -0
- package/horizontal-stepper/index.js +61 -0
- package/horizontal-stepper/types.d.ts +13 -0
- package/horizontal-stepper/types.js +1 -0
- package/horizontal-stepper-item/index.d.ts +14 -0
- package/horizontal-stepper-item/index.js +61 -0
- package/horizontal-stepper-item/types.d.ts +24 -0
- package/horizontal-stepper-item/types.js +1 -0
- package/horizontal-stepper-item/utils.d.ts +2 -0
- package/horizontal-stepper-item/utils.js +1 -0
- package/icon/index.d.ts +11 -0
- package/icon/index.js +32 -0
- package/icon/types.d.ts +11 -0
- package/icon/types.js +1 -0
- package/icon-button/index.d.ts +12 -0
- package/icon-button/index.js +173 -0
- package/icon-button/types.d.ts +44 -0
- package/icon-button/types.js +1 -0
- package/icon-button/utils.d.ts +2 -0
- package/icon-button/utils.js +1 -0
- package/inline-alert/index.d.ts +15 -0
- package/inline-alert/index.js +83 -0
- package/inline-alert/types.d.ts +15 -0
- package/inline-alert/types.js +1 -0
- package/inline-alert/utils.d.ts +2 -0
- package/inline-alert/utils.js +1 -0
- package/input/index.d.ts +11 -0
- package/input/index.js +620 -0
- package/input/types.d.ts +80 -0
- package/input/types.js +1 -0
- package/input/utils.d.ts +26 -0
- package/input/utils.js +302 -0
- package/link/index.d.ts +12 -0
- package/link/index.js +132 -0
- package/link/types.d.ts +55 -0
- package/link/types.js +1 -0
- package/list/index.d.ts +11 -0
- package/list/index.js +14 -0
- package/list/types.d.ts +3 -0
- package/list/types.js +1 -0
- package/list-item/index.d.ts +11 -0
- package/list-item/index.js +14 -0
- package/list-item/types.d.ts +3 -0
- package/list-item/types.js +1 -0
- package/package.json +30 -0
- package/pagination/index.d.ts +12 -0
- package/pagination/index.js +147 -0
- package/pagination/types.d.ts +16 -0
- package/pagination/types.js +1 -0
- package/pop/index.d.ts +11 -0
- package/pop/index.js +425 -0
- package/pop/types.d.ts +35 -0
- package/pop/types.js +1 -0
- package/pop/utils.d.ts +4 -0
- package/pop/utils.js +16 -0
- package/popover/index.d.ts +12 -0
- package/popover/index.js +140 -0
- package/popover/types.d.ts +40 -0
- package/popover/types.js +1 -0
- package/popover/utils.d.ts +4 -0
- package/popover/utils.js +10 -0
- package/progress/index.d.ts +12 -0
- package/progress/index.js +58 -0
- package/progress/types.d.ts +12 -0
- package/progress/types.js +1 -0
- package/progress-stepper/index.d.ts +11 -0
- package/progress-stepper/index.js +206 -0
- package/progress-stepper/types.d.ts +22 -0
- package/progress-stepper/types.js +1 -0
- package/progress-stepper-item/index.d.ts +12 -0
- package/progress-stepper-item/index.js +82 -0
- package/progress-stepper-item/types.d.ts +23 -0
- package/progress-stepper-item/types.js +1 -0
- package/progress-stepper-item/utils.d.ts +11 -0
- package/progress-stepper-item/utils.js +13 -0
- package/radio/index.d.ts +11 -0
- package/radio/index.js +154 -0
- package/radio/types.d.ts +14 -0
- package/radio/types.js +1 -0
- package/radio-option/index.d.ts +11 -0
- package/radio-option/index.js +79 -0
- package/radio-option/types.d.ts +17 -0
- package/radio-option/types.js +1 -0
- package/readme.md +179 -0
- package/rich-text/index.d.ts +11 -0
- package/rich-text/index.js +48 -0
- package/rich-text/types.d.ts +12 -0
- package/rich-text/types.js +1 -0
- package/rich-text/utils.d.ts +2 -0
- package/rich-text/utils.js +1 -0
- package/segment/index.d.ts +12 -0
- package/segment/index.js +109 -0
- package/segment/types.d.ts +16 -0
- package/segment/types.js +1 -0
- package/segment/utils.d.ts +3 -0
- package/segment/utils.js +16 -0
- package/segment-collapse/index.d.ts +13 -0
- package/segment-collapse/index.js +60 -0
- package/segment-collapse/types.d.ts +11 -0
- package/segment-collapse/types.js +1 -0
- package/segmented-control/index.d.ts +11 -0
- package/segmented-control/index.js +85 -0
- package/segmented-control/types.d.ts +11 -0
- package/segmented-control/types.js +1 -0
- package/segmented-control-option/index.d.ts +11 -0
- package/segmented-control-option/index.js +95 -0
- package/segmented-control-option/types.d.ts +19 -0
- package/segmented-control-option/types.js +1 -0
- package/segmented-icon-control/index.d.ts +11 -0
- package/segmented-icon-control/index.js +101 -0
- package/segmented-icon-control/types.d.ts +14 -0
- package/segmented-icon-control/types.js +1 -0
- package/segmented-icon-control-option/index.d.ts +11 -0
- package/segmented-icon-control-option/index.js +82 -0
- package/segmented-icon-control-option/types.d.ts +16 -0
- package/segmented-icon-control-option/types.js +1 -0
- package/select-button/index.d.ts +13 -0
- package/select-button/index.js +200 -0
- package/select-button/types.d.ts +50 -0
- package/select-button/types.js +1 -0
- package/select-menu/index.d.ts +15 -0
- package/select-menu/index.js +307 -0
- package/select-menu/types.d.ts +29 -0
- package/select-menu/types.js +1 -0
- package/select-menu-option/index.d.ts +28 -0
- package/select-menu-option/index.js +65 -0
- package/select-menu-option/types.d.ts +26 -0
- package/select-menu-option/types.js +1 -0
- package/skeleton/index.d.ts +11 -0
- package/skeleton/index.js +108 -0
- package/skeleton/types.d.ts +9 -0
- package/skeleton/types.js +1 -0
- package/skeleton-item/index.d.ts +11 -0
- package/skeleton-item/index.js +11 -0
- package/skeleton-item/types.d.ts +13 -0
- package/skeleton-item/types.js +1 -0
- package/spinner/index.d.ts +11 -0
- package/spinner/index.js +58 -0
- package/spinner/types.d.ts +12 -0
- package/spinner/types.js +1 -0
- package/stop-events/index.d.ts +1 -0
- package/stop-events/index.js +27 -0
- package/table/index.d.ts +11 -0
- package/table/index.js +14 -0
- package/table/types.d.ts +3 -0
- package/table/types.js +1 -0
- package/table-body/index.d.ts +11 -0
- package/table-body/index.js +14 -0
- package/table-body/types.d.ts +3 -0
- package/table-body/types.js +1 -0
- package/table-cell/index.d.ts +11 -0
- package/table-cell/index.js +21 -0
- package/table-cell/types.d.ts +9 -0
- package/table-cell/types.js +1 -0
- package/table-cell/utils.d.ts +2 -0
- package/table-cell/utils.js +1 -0
- package/table-head/index.d.ts +11 -0
- package/table-head/index.js +14 -0
- package/table-head/types.d.ts +3 -0
- package/table-head/types.js +1 -0
- package/table-head-cell/index.d.ts +12 -0
- package/table-head-cell/index.js +57 -0
- package/table-head-cell/types.d.ts +15 -0
- package/table-head-cell/types.js +1 -0
- package/table-row/index.d.ts +11 -0
- package/table-row/index.js +42 -0
- package/table-row/types.d.ts +11 -0
- package/table-row/types.js +1 -0
- package/tabs/index.d.ts +11 -0
- package/tabs/index.js +80 -0
- package/tabs/types.d.ts +18 -0
- package/tabs/types.js +1 -0
- package/tabs-icon-option/index.d.ts +11 -0
- package/tabs-icon-option/index.js +79 -0
- package/tabs-icon-option/types.d.ts +19 -0
- package/tabs-icon-option/types.js +1 -0
- package/tabs-option/index.d.ts +12 -0
- package/tabs-option/index.js +86 -0
- package/tabs-option/types.d.ts +25 -0
- package/tabs-option/types.js +1 -0
- package/tag/index.d.ts +12 -0
- package/tag/index.js +84 -0
- package/tag/types.d.ts +23 -0
- package/tag/types.js +1 -0
- package/tag/utils.d.ts +2 -0
- package/tag/utils.js +6 -0
- package/text/index.d.ts +11 -0
- package/text/index.js +64 -0
- package/text/types.d.ts +30 -0
- package/text/types.js +1 -0
- package/text/utils.d.ts +2 -0
- package/text/utils.js +1 -0
- package/textarea/index.d.ts +11 -0
- package/textarea/index.js +228 -0
- package/textarea/types.d.ts +57 -0
- package/textarea/types.js +1 -0
- package/tile-control/index.d.ts +11 -0
- package/tile-control/index.js +110 -0
- package/tile-control/types.d.ts +35 -0
- package/tile-control/types.js +1 -0
- package/tile-control-option/index.d.ts +11 -0
- package/tile-control-option/index.js +98 -0
- package/tile-control-option/types.d.ts +37 -0
- package/tile-control-option/types.js +1 -0
- package/time-picker/index.d.ts +15 -0
- package/time-picker/index.js +337 -0
- package/time-picker/types.d.ts +34 -0
- package/time-picker/types.js +1 -0
- package/time-picker/utils.d.ts +11 -0
- package/time-picker/utils.js +75 -0
- package/title/index.d.ts +11 -0
- package/title/index.js +60 -0
- package/title/types.d.ts +31 -0
- package/title/types.js +1 -0
- package/title/utils.d.ts +3 -0
- package/title/utils.js +17 -0
- package/toast/index.d.ts +14 -0
- package/toast/index.js +87 -0
- package/toast/types.d.ts +28 -0
- package/toast/types.js +1 -0
- package/toast/utils.d.ts +2 -0
- package/toast/utils.js +1 -0
- package/toast-manager/index.d.ts +13 -0
- package/toast-manager/index.js +163 -0
- package/toast-manager/types.d.ts +7 -0
- package/toast-manager/types.js +1 -0
- package/toggle/index.d.ts +11 -0
- package/toggle/index.js +126 -0
- package/toggle/types.d.ts +23 -0
- package/toggle/types.js +1 -0
- package/tooltip/index.d.ts +13 -0
- package/tooltip/index.js +258 -0
- package/tooltip/tooltip-state.d.ts +19 -0
- package/tooltip/tooltip-state.js +126 -0
- package/tooltip/types.d.ts +35 -0
- package/tooltip/types.js +1 -0
- package/tooltip/utils.d.ts +5 -0
- package/tooltip/utils.js +17 -0
- package/types.d.ts +14 -0
- package/utils/context.d.ts +20 -0
- package/utils/context.js +84 -0
- package/utils/countries.d.ts +6 -0
- package/utils/countries.js +2 -0
- package/utils/countries.json +1217 -0
- package/utils/csv.d.ts +5 -0
- package/utils/csv.js +22 -0
- package/utils/debounce.d.ts +8 -0
- package/utils/debounce.js +22 -0
- package/utils/dom.d.ts +34 -0
- package/utils/dom.js +154 -0
- package/utils/element.d.ts +16 -0
- package/utils/element.js +48 -0
- package/utils/event-target.d.ts +4 -0
- package/utils/event-target.js +26 -0
- package/utils/get-react-event-handler.d.ts +1 -0
- package/utils/get-react-event-handler.js +8 -0
- package/utils/index.d.ts +12 -0
- package/utils/index.js +12 -0
- package/utils/markdown.d.ts +1 -0
- package/utils/markdown.js +128 -0
- package/utils/rect.d.ts +4 -0
- package/utils/rect.js +28 -0
- package/utils/size.d.ts +5 -0
- package/utils/size.js +3 -0
- package/utils/slot.d.ts +4 -0
- package/utils/slot.js +38 -0
- package/utils/throttle.d.ts +4 -0
- package/utils/throttle.js +20 -0
- package/utils/uid.d.ts +1 -0
- package/utils/uid.js +13 -0
- package/vertical-stepper/index.d.ts +11 -0
- package/vertical-stepper/index.js +57 -0
- package/vertical-stepper/types.d.ts +13 -0
- package/vertical-stepper/types.js +1 -0
- package/vertical-stepper-item/index.d.ts +14 -0
- package/vertical-stepper-item/index.js +61 -0
- package/vertical-stepper-item/types.d.ts +24 -0
- package/vertical-stepper-item/types.js +1 -0
- package/vertical-stepper-item/utils.d.ts +2 -0
- package/vertical-stepper-item/utils.js +1 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export type TSinchTextareaElement = HTMLElement & {
|
|
3
|
+
/** Value */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Text that appears in the text field when it has no value set */
|
|
6
|
+
placeholder: string | null;
|
|
7
|
+
/** Disabled */
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
/** Invalid state */
|
|
10
|
+
invalid: boolean;
|
|
11
|
+
selectionStart: HTMLTextAreaElement['selectionStart'];
|
|
12
|
+
selectionEnd: HTMLTextAreaElement['selectionEnd'];
|
|
13
|
+
selectionDirection: HTMLTextAreaElement['selectionDirection'];
|
|
14
|
+
/** Number of rows */
|
|
15
|
+
rows: HTMLTextAreaElement['rows'];
|
|
16
|
+
/** Whether the text field is resizable */
|
|
17
|
+
resizable: boolean;
|
|
18
|
+
/** Change value event */
|
|
19
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
20
|
+
/** Focus event */
|
|
21
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
22
|
+
/** Blur event */
|
|
23
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
24
|
+
/** Value */
|
|
25
|
+
setAttribute(name: 'value', value: string): void;
|
|
26
|
+
/** Text that appears in the text field when it has no value set */
|
|
27
|
+
setAttribute(name: 'placeholder', value: string): void;
|
|
28
|
+
/** Invalid state */
|
|
29
|
+
setAttribute(name: 'invalid', value: ''): void;
|
|
30
|
+
/** Disabled */
|
|
31
|
+
setAttribute(name: 'disabled', value: ''): void;
|
|
32
|
+
/** Number of rows */
|
|
33
|
+
setAttribute(name: 'rows', value: string): void;
|
|
34
|
+
/** Whether the text field is resizable */
|
|
35
|
+
setAttribute(name: 'resizable', value: ''): void;
|
|
36
|
+
};
|
|
37
|
+
export type TSinchTextareaReact = TSinchElementReact<TSinchTextareaElement> & {
|
|
38
|
+
/** Value */
|
|
39
|
+
value: string;
|
|
40
|
+
/** Text that appears in the text field when it has no value set */
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
/** Disabled */
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
/** Invalid state */
|
|
45
|
+
invalid?: boolean;
|
|
46
|
+
'aria-label': string;
|
|
47
|
+
/** Number of rows */
|
|
48
|
+
rows?: number;
|
|
49
|
+
/** Whether the text field is resizable */
|
|
50
|
+
resizable?: boolean;
|
|
51
|
+
/** Change value handler */
|
|
52
|
+
'on-change'?: (e: CustomEvent<string>) => void;
|
|
53
|
+
/** Focus handler */
|
|
54
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
55
|
+
/** Blur handler */
|
|
56
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TSinchTileControlElement, TSinchTileControlReact } from './types';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace JSX {
|
|
4
|
+
interface IntrinsicElements {
|
|
5
|
+
'sinch-tile-control': TSinchTileControlReact;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'sinch-tile-control': TSinchTileControlElement;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateIntegerAttribute, isAttrTrue, isAttrEqual } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:block;outline:0;--sinch-grid-num-columns:1}#wrapper{display:grid;grid-template-columns:repeat(var(--sinch-grid-num-columns),auto);gap:16px;width:fit-content}:host([small]) #wrapper{gap:8px}:host([cols="2"]){--sinch-grid-num-columns:2}:host([cols="3"]){--sinch-grid-num-columns:3}:host([cols="4"]){--sinch-grid-num-columns:4}:host([cols="5"]){--sinch-grid-num-columns:5}:host([cols="6"]){--sinch-grid-num-columns:6}:host([cols="7"]){--sinch-grid-num-columns:7}:host([cols="8"]){--sinch-grid-num-columns:8}</style><div id="wrapper"><slot></slot></div>';
|
|
3
|
+
const template = document.createElement('template');
|
|
4
|
+
template.innerHTML = templateHTML;
|
|
5
|
+
defineCustomElement('sinch-tile-control', class extends NectaryElement {
|
|
6
|
+
#$slot;
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
const shadowRoot = this.attachShadow();
|
|
10
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
11
|
+
this.#$slot = shadowRoot.querySelector('slot');
|
|
12
|
+
}
|
|
13
|
+
connectedCallback() {
|
|
14
|
+
this.setAttribute('role', 'tablist');
|
|
15
|
+
this.#$slot.addEventListener('option-change', this.#onOptionChange);
|
|
16
|
+
this.#$slot.addEventListener('slotchange', this.#onSlotChange);
|
|
17
|
+
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
18
|
+
}
|
|
19
|
+
disconnectedCallback() {
|
|
20
|
+
this.#$slot.removeEventListener('option-change', this.#onOptionChange);
|
|
21
|
+
this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
|
|
22
|
+
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
23
|
+
}
|
|
24
|
+
static get observedAttributes() {
|
|
25
|
+
return ['value', 'small', 'multiple'];
|
|
26
|
+
}
|
|
27
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
28
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
switch (name) {
|
|
32
|
+
case 'value':
|
|
33
|
+
{
|
|
34
|
+
this.#onValueChange(newVal ?? '');
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case 'small':
|
|
38
|
+
{
|
|
39
|
+
this.#onSmallChange();
|
|
40
|
+
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case 'multiple':
|
|
44
|
+
{
|
|
45
|
+
this.#onValueChange(this.value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
set value(value) {
|
|
50
|
+
updateAttribute(this, 'value', value);
|
|
51
|
+
}
|
|
52
|
+
get value() {
|
|
53
|
+
return getAttribute(this, 'value', '');
|
|
54
|
+
}
|
|
55
|
+
set small(isSmall) {
|
|
56
|
+
updateBooleanAttribute(this, 'small', isSmall);
|
|
57
|
+
}
|
|
58
|
+
get small() {
|
|
59
|
+
return getBooleanAttribute(this, 'small');
|
|
60
|
+
}
|
|
61
|
+
set multiple(isMultiple) {
|
|
62
|
+
updateBooleanAttribute(this, 'multiple', isMultiple);
|
|
63
|
+
}
|
|
64
|
+
get multiple() {
|
|
65
|
+
return getBooleanAttribute(this, 'multiple');
|
|
66
|
+
}
|
|
67
|
+
set cols(value) {
|
|
68
|
+
updateIntegerAttribute(this, 'cols', value);
|
|
69
|
+
}
|
|
70
|
+
get cols() {
|
|
71
|
+
return getIntegerAttribute(this, 'cols', 1);
|
|
72
|
+
}
|
|
73
|
+
#onSlotChange = () => {
|
|
74
|
+
this.#onValueChange(this.value);
|
|
75
|
+
this.#onSmallChange();
|
|
76
|
+
};
|
|
77
|
+
#onOptionChange = e => {
|
|
78
|
+
e.stopPropagation();
|
|
79
|
+
const $elem = e.target;
|
|
80
|
+
const value = e.detail;
|
|
81
|
+
const detail = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($elem, 'data-checked')) : value;
|
|
82
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
83
|
+
detail
|
|
84
|
+
}));
|
|
85
|
+
};
|
|
86
|
+
#onValueChange(csv) {
|
|
87
|
+
if (this.multiple) {
|
|
88
|
+
const values = unpackCsv(csv);
|
|
89
|
+
for (const $option of this.#$slot.assignedElements()) {
|
|
90
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && values.includes(getAttribute($option, 'value', ''));
|
|
91
|
+
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
const value = getFirstCsvValue(csv);
|
|
95
|
+
for (const $option of this.#$slot.assignedElements()) {
|
|
96
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
97
|
+
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
#onSmallChange() {
|
|
102
|
+
const isSmall = this.small;
|
|
103
|
+
for (const $opt of this.#$slot.assignedElements()) {
|
|
104
|
+
updateBooleanAttribute($opt, 'data-small', isSmall);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
#onChangeReactHandler = e => {
|
|
108
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
109
|
+
};
|
|
110
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export type TSinchTileControlElement = HTMLElement & {
|
|
3
|
+
/** Value */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Small */
|
|
6
|
+
small: boolean;
|
|
7
|
+
/** Multiple */
|
|
8
|
+
multiple: boolean;
|
|
9
|
+
/** Number of columns from 1 to 8 */
|
|
10
|
+
cols: number;
|
|
11
|
+
/** Change value event */
|
|
12
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
13
|
+
/** Value */
|
|
14
|
+
setAttribute(name: 'value', value: string): void;
|
|
15
|
+
/** Small */
|
|
16
|
+
setAttribute(name: 'small', value: ''): void;
|
|
17
|
+
/** Multiple */
|
|
18
|
+
setAttribute(name: 'multiple', value: ''): void;
|
|
19
|
+
/** Number of columns from 1 to 8 */
|
|
20
|
+
setAttribute(name: 'cols', value: string): void;
|
|
21
|
+
};
|
|
22
|
+
export type TSinchTileControlReact = TSinchElementReact<TSinchTileControlElement> & {
|
|
23
|
+
/** Value */
|
|
24
|
+
value: string;
|
|
25
|
+
/** Multiple */
|
|
26
|
+
multiple?: boolean;
|
|
27
|
+
/** Small */
|
|
28
|
+
small?: boolean;
|
|
29
|
+
/** Number of columns from 1 to 8 */
|
|
30
|
+
cols: number;
|
|
31
|
+
/** Label that is used for a11y */
|
|
32
|
+
'aria-label': string;
|
|
33
|
+
/** Change value handler */
|
|
34
|
+
'on-change'?: (e: CustomEvent<string>) => void;
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TSinchTileControlOptionElement, TSinchTileControlOptionReact } from './types';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace JSX {
|
|
4
|
+
interface IntrinsicElements {
|
|
5
|
+
'sinch-tile-control-option': TSinchTileControlOptionReact;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'sinch-tile-control-option': TSinchTileControlOptionElement;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}button{all:initial;position:relative;display:flex;flex-direction:column;justify-content:space-between;box-sizing:border-box;width:var(--sinch-local-size);height:var(--sinch-local-size);padding:16px 8px 8px;border-radius:var(--sinch-local-shape-radius);background-color:var(--sinch-local-color-background);box-shadow:var(--sinch-local-shadow);cursor:pointer;--sinch-local-color-background:var(--sinch-comp-tile-control-color-default-background-initial);--sinch-local-color-border:var(--sinch-comp-tile-control-color-default-border-initial);--sinch-local-color-text:var(--sinch-comp-tile-control-color-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-tile-control-color-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-tile-control-shadow-initial);--sinch-local-shape-radius:var(--sinch-comp-tile-control-shape-radius-l);--sinch-local-size:88px;--sinch-local-size-icon:var(--sinch-comp-tile-control-size-m-icon)}button::before{content:"";position:absolute;inset:0;border:1px solid var(--sinch-local-color-border);border-radius:var(--sinch-local-shape-radius);pointer-events:none}button:focus-visible::after{position:absolute;content:"";inset:-4px;padding:2px;border:2px solid var(--sinch-comp-tile-control-color-default-outline-focus);border-radius:calc(var(--sinch-local-shape-radius) + 4px);pointer-events:none}:host([data-small])>button{padding:12px 4px 4px;--sinch-local-shape-radius:var(--sinch-comp-tile-control-shape-radius-s);--sinch-local-size:64px;--sinch-local-size-icon:var(--sinch-comp-tile-control-size-s-icon)}button:enabled:hover{--sinch-local-color-background:var(--sinch-comp-tile-control-color-default-background-hover);--sinch-local-color-border:var(--sinch-comp-tile-control-color-default-border-hover);--sinch-local-shadow:var(--sinch-comp-tile-control-shadow-hover)}:host([data-checked])>button:enabled,button:enabled:active{--sinch-local-color-background:var(--sinch-comp-tile-control-color-checked-background-initial);--sinch-local-color-border:var(--sinch-comp-tile-control-color-checked-border-initial);--sinch-local-color-text:var(--sinch-comp-tile-control-color-checked-text-initial);--sinch-local-color-icon:var(--sinch-comp-tile-control-color-checked-icon-initial);--sinch-local-shadow:var(--sinch-comp-tile-control-shadow-active)}:host([data-checked])>button:enabled::before,button:enabled:active::before{border-width:2px}button:disabled{cursor:initial;--sinch-local-color-background:var(--sinch-comp-tile-control-color-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-tile-control-color-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-tile-control-color-disabled-text-initial);--sinch-local-color-icon:var(--sinch-comp-tile-control-color-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-tile-control-shadow-disabled)}#text{display:inline-block;min-height:20px;text-align:center;font:var(--sinch-comp-tile-control-font-label);color:var(--sinch-local-color-text);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon{width:var(--sinch-local-size-icon);height:var(--sinch-local-size-icon);align-self:center;--sinch-global-size-icon:var(--sinch-local-size-icon);--sinch-global-color-icon:var(--sinch-local-color-icon)}</style><button><div id="icon"><slot name="icon"></slot></div><span id="text"></span></button>';
|
|
3
|
+
const template = document.createElement('template');
|
|
4
|
+
template.innerHTML = templateHTML;
|
|
5
|
+
defineCustomElement('sinch-tile-control-option', class extends NectaryElement {
|
|
6
|
+
#$button;
|
|
7
|
+
#$text;
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
const shadowRoot = this.attachShadow();
|
|
11
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
+
this.#$button = shadowRoot.querySelector('button');
|
|
13
|
+
this.#$text = shadowRoot.querySelector('#text');
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
this.setAttribute('role', 'tab');
|
|
17
|
+
this.#$button.addEventListener('click', this.#onButtonClick);
|
|
18
|
+
this.#$button.addEventListener('focus', this.#onButtonFocus);
|
|
19
|
+
this.#$button.addEventListener('blur', this.#onButtonBlur);
|
|
20
|
+
this.addEventListener('-focus', this.#onFocusReactHandler);
|
|
21
|
+
this.addEventListener('-blur', this.#onBlurReactHandler);
|
|
22
|
+
}
|
|
23
|
+
disconnectedCallback() {
|
|
24
|
+
this.#$button.removeEventListener('click', this.#onButtonClick);
|
|
25
|
+
this.#$button.removeEventListener('focus', this.#onButtonFocus);
|
|
26
|
+
this.#$button.removeEventListener('blur', this.#onButtonBlur);
|
|
27
|
+
this.removeEventListener('-focus', this.#onFocusReactHandler);
|
|
28
|
+
this.removeEventListener('-blur', this.#onBlurReactHandler);
|
|
29
|
+
}
|
|
30
|
+
static get observedAttributes() {
|
|
31
|
+
return ['data-checked', 'text', 'disabled'];
|
|
32
|
+
}
|
|
33
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
34
|
+
switch (name) {
|
|
35
|
+
case 'text':
|
|
36
|
+
{
|
|
37
|
+
this.#$text.textContent = newVal;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case 'data-checked':
|
|
41
|
+
{
|
|
42
|
+
updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case 'disabled':
|
|
46
|
+
{
|
|
47
|
+
this.#$button.disabled = isAttrTrue(newVal);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
set value(value) {
|
|
53
|
+
updateAttribute(this, 'value', value);
|
|
54
|
+
}
|
|
55
|
+
get value() {
|
|
56
|
+
return getAttribute(this, 'value', '');
|
|
57
|
+
}
|
|
58
|
+
set disabled(isDisabled) {
|
|
59
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
60
|
+
}
|
|
61
|
+
get disabled() {
|
|
62
|
+
return getBooleanAttribute(this, 'disabled');
|
|
63
|
+
}
|
|
64
|
+
set text(value) {
|
|
65
|
+
updateAttribute(this, 'text', value);
|
|
66
|
+
}
|
|
67
|
+
get text() {
|
|
68
|
+
return getAttribute(this, 'text', '');
|
|
69
|
+
}
|
|
70
|
+
get focusable() {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
focus() {
|
|
74
|
+
this.#$button.focus();
|
|
75
|
+
}
|
|
76
|
+
blur() {
|
|
77
|
+
this.#$button.blur();
|
|
78
|
+
}
|
|
79
|
+
#onButtonClick = e => {
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
this.dispatchEvent(new CustomEvent('option-change', {
|
|
82
|
+
detail: this.value,
|
|
83
|
+
bubbles: true
|
|
84
|
+
}));
|
|
85
|
+
};
|
|
86
|
+
#onButtonFocus = () => {
|
|
87
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
88
|
+
};
|
|
89
|
+
#onButtonBlur = () => {
|
|
90
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
91
|
+
};
|
|
92
|
+
#onFocusReactHandler = () => {
|
|
93
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
94
|
+
};
|
|
95
|
+
#onBlurReactHandler = () => {
|
|
96
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
97
|
+
};
|
|
98
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export type TSinchTileControlOptionElement = HTMLElement & {
|
|
3
|
+
/** Value */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Text content */
|
|
6
|
+
text: string;
|
|
7
|
+
/** Disabled */
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
/** Small */
|
|
10
|
+
small: boolean;
|
|
11
|
+
/** Focus event */
|
|
12
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
13
|
+
/** Blur event */
|
|
14
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
15
|
+
/** Value */
|
|
16
|
+
setAttribute(name: 'value', value: string): void;
|
|
17
|
+
/** Text content */
|
|
18
|
+
setAttribute(attr: 'text', value: string): void;
|
|
19
|
+
/** Disabled */
|
|
20
|
+
setAttribute(name: 'disabled', value: ''): void;
|
|
21
|
+
/** Small */
|
|
22
|
+
setAttribute(name: 'small', value: ''): void;
|
|
23
|
+
};
|
|
24
|
+
export type TSinchTileControlOptionReact = TSinchElementReact<TSinchTileControlOptionElement> & {
|
|
25
|
+
/** Value */
|
|
26
|
+
value: string;
|
|
27
|
+
/** Text content */
|
|
28
|
+
text: string;
|
|
29
|
+
/** Label that is used for a11y */
|
|
30
|
+
'aria-label': string;
|
|
31
|
+
/** Disabled */
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/** Focus handler */
|
|
34
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
35
|
+
/** Blur handler */
|
|
36
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import '../icon-button';
|
|
2
|
+
import '../icon';
|
|
3
|
+
import '../segmented-control';
|
|
4
|
+
import '../segmented-control-option';
|
|
5
|
+
import type { TSinchTimePickerElement, TSinchTimePickerReact } from './types';
|
|
6
|
+
declare global {
|
|
7
|
+
namespace JSX {
|
|
8
|
+
interface IntrinsicElements {
|
|
9
|
+
'sinch-time-picker': TSinchTimePickerReact;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
'sinch-time-picker': TSinchTimePickerElement;
|
|
14
|
+
}
|
|
15
|
+
}
|