@nectary/components 2.8.8 → 2.9.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/package.json +1 -1
- package/accordion/index.d.ts +0 -11
- package/accordion/index.js +0 -86
- package/accordion/types.d.ts +0 -21
- package/accordion/types.js +0 -1
- package/accordion-item/index.d.ts +0 -14
- package/accordion-item/index.js +0 -95
- package/accordion-item/types.d.ts +0 -36
- package/accordion-item/types.js +0 -1
- package/accordion-item/utils.d.ts +0 -2
- package/accordion-item/utils.js +0 -1
- package/action-menu/index.d.ts +0 -11
- package/action-menu/index.js +0 -195
- package/action-menu/types.d.ts +0 -13
- package/action-menu/types.js +0 -1
- package/action-menu-option/index.d.ts +0 -12
- package/action-menu-option/index.js +0 -82
- package/action-menu-option/types.d.ts +0 -23
- package/action-menu-option/types.js +0 -1
- package/action-menu-option/utils.d.ts +0 -2
- package/action-menu-option/utils.js +0 -3
- package/alert/index.d.ts +0 -14
- package/alert/index.js +0 -48
- package/alert/types.d.ts +0 -18
- package/alert/types.js +0 -1
- package/alert/utils.d.ts +0 -2
- package/alert/utils.js +0 -1
- package/avatar/index.d.ts +0 -11
- package/avatar/index.js +0 -94
- package/avatar/types.d.ts +0 -37
- package/avatar/types.js +0 -1
- package/avatar/utils.d.ts +0 -4
- package/avatar/utils.js +0 -7
- package/badge/index.d.ts +0 -11
- package/badge/index.js +0 -114
- package/badge/types.d.ts +0 -34
- package/badge/types.js +0 -1
- package/badge/utils.d.ts +0 -2
- package/badge/utils.js +0 -1
- package/button/index.d.ts +0 -11
- package/button/index.js +0 -182
- package/button/types.d.ts +0 -53
- package/button/types.js +0 -1
- package/button/utils.d.ts +0 -2
- package/button/utils.js +0 -1
- package/card/index.d.ts +0 -13
- package/card/index.js +0 -133
- package/card/types.d.ts +0 -28
- package/card/types.js +0 -1
- package/card-container/index.d.ts +0 -11
- package/card-container/index.js +0 -11
- package/card-container/types.d.ts +0 -3
- package/card-container/types.js +0 -1
- package/chat/index.d.ts +0 -11
- package/chat/index.js +0 -11
- package/chat/types.d.ts +0 -3
- package/chat/types.js +0 -1
- package/chat-block/index.d.ts +0 -11
- package/chat-block/index.js +0 -86
- package/chat-block/types.d.ts +0 -30
- package/chat-block/types.js +0 -1
- package/chat-bubble/index.d.ts +0 -11
- package/chat-bubble/index.js +0 -41
- package/chat-bubble/types.d.ts +0 -20
- package/chat-bubble/types.js +0 -1
- package/chat-bubble/utils.d.ts +0 -3
- package/chat-bubble/utils.js +0 -2
- package/checkbox/index.d.ts +0 -11
- package/checkbox/index.js +0 -126
- package/checkbox/types.d.ts +0 -49
- package/checkbox/types.js +0 -1
- package/chip/index.d.ts +0 -13
- package/chip/index.js +0 -144
- package/chip/types.d.ts +0 -37
- package/chip/types.js +0 -1
- package/chip/utils.d.ts +0 -2
- package/chip/utils.js +0 -6
- package/code-tag/index.d.ts +0 -11
- package/code-tag/index.js +0 -31
- package/code-tag/types.d.ts +0 -11
- package/code-tag/types.js +0 -1
- package/color-menu/index.d.ts +0 -11
- package/color-menu/index.js +0 -308
- package/color-menu/types.d.ts +0 -32
- package/color-menu/types.js +0 -1
- package/color-menu/utils.d.ts +0 -1
- package/color-menu/utils.js +0 -11
- package/color-menu-option/index.d.ts +0 -13
- package/color-menu-option/index.js +0 -48
- package/color-menu-option/types.d.ts +0 -11
- package/color-menu-option/types.js +0 -1
- package/color-menu-option/utils.d.ts +0 -1
- package/color-menu-option/utils.js +0 -11
- package/color-swatch/index.d.ts +0 -12
- package/color-swatch/index.js +0 -54
- package/color-swatch/types.d.ts +0 -11
- package/color-swatch/types.js +0 -1
- package/color-swatch/utils.d.ts +0 -2
- package/color-swatch/utils.js +0 -6
- package/date-picker/index.d.ts +0 -14
- package/date-picker/index.js +0 -381
- package/date-picker/types.d.ts +0 -70
- package/date-picker/types.js +0 -1
- package/date-picker/utils.d.ts +0 -28
- package/date-picker/utils.js +0 -142
- package/dialog/index.d.ts +0 -15
- package/dialog/index.js +0 -144
- package/dialog/types.d.ts +0 -28
- package/dialog/types.js +0 -1
- package/dialog/utils.d.ts +0 -2
- package/dialog/utils.js +0 -18
- package/emoji/index.d.ts +0 -11
- package/emoji/index.js +0 -46
- package/emoji/types.d.ts +0 -11
- package/emoji/types.js +0 -1
- package/emoji/utils.d.ts +0 -3
- package/emoji/utils.js +0 -47
- package/emoji-picker/index.d.ts +0 -22
- package/emoji-picker/index.js +0 -308
- package/emoji-picker/types.d.ts +0 -26
- package/emoji-picker/types.js +0 -1
- package/field/index.d.ts +0 -11
- package/field/index.js +0 -120
- package/field/types.d.ts +0 -35
- package/field/types.js +0 -1
- package/file-drop/index.d.ts +0 -13
- package/file-drop/index.js +0 -205
- package/file-drop/types.d.ts +0 -50
- package/file-drop/types.js +0 -1
- package/file-drop/utils.d.ts +0 -2
- package/file-drop/utils.js +0 -31
- package/file-picker/index.d.ts +0 -11
- package/file-picker/index.js +0 -103
- package/file-picker/types.d.ts +0 -32
- package/file-picker/types.js +0 -1
- package/file-picker/utils.d.ts +0 -1
- package/file-picker/utils.js +0 -8
- package/file-status/index.d.ts +0 -14
- package/file-status/index.js +0 -61
- package/file-status/types.d.ts +0 -18
- package/file-status/types.js +0 -1
- package/file-status/utils.d.ts +0 -2
- package/file-status/utils.js +0 -1
- package/flag/index.d.ts +0 -11
- package/flag/index.js +0 -46
- package/flag/types.d.ts +0 -11
- package/flag/types.js +0 -1
- package/flag/utils.d.ts +0 -1
- package/flag/utils.js +0 -17
- package/grid/index.d.ts +0 -11
- package/grid/index.js +0 -11
- package/grid/types.d.ts +0 -3
- package/grid/types.js +0 -1
- package/grid-item/index.d.ts +0 -11
- package/grid-item/index.js +0 -35
- package/grid-item/types.d.ts +0 -17
- package/grid-item/types.js +0 -1
- package/help-tooltip/index.d.ts +0 -13
- package/help-tooltip/index.js +0 -74
- package/help-tooltip/types.d.ts +0 -3
- package/help-tooltip/types.js +0 -1
- package/horizontal-stepper/index.d.ts +0 -11
- package/horizontal-stepper/index.js +0 -61
- package/horizontal-stepper/types.d.ts +0 -13
- package/horizontal-stepper/types.js +0 -1
- package/horizontal-stepper-item/index.d.ts +0 -14
- package/horizontal-stepper-item/index.js +0 -61
- package/horizontal-stepper-item/types.d.ts +0 -24
- package/horizontal-stepper-item/types.js +0 -1
- package/horizontal-stepper-item/utils.d.ts +0 -2
- package/horizontal-stepper-item/utils.js +0 -1
- package/icon/index.d.ts +0 -11
- package/icon/index.js +0 -32
- package/icon/types.d.ts +0 -11
- package/icon/types.js +0 -1
- package/icon-button/index.d.ts +0 -12
- package/icon-button/index.js +0 -175
- package/icon-button/types.d.ts +0 -44
- package/icon-button/types.js +0 -1
- package/icon-button/utils.d.ts +0 -2
- package/icon-button/utils.js +0 -1
- package/inline-alert/index.d.ts +0 -15
- package/inline-alert/index.js +0 -83
- package/inline-alert/types.d.ts +0 -15
- package/inline-alert/types.js +0 -1
- package/inline-alert/utils.d.ts +0 -2
- package/inline-alert/utils.js +0 -1
- package/input/index.d.ts +0 -11
- package/input/index.js +0 -637
- package/input/types.d.ts +0 -86
- package/input/types.js +0 -1
- package/input/utils.d.ts +0 -26
- package/input/utils.js +0 -302
- package/link/index.d.ts +0 -12
- package/link/index.js +0 -150
- package/link/types.d.ts +0 -59
- package/link/types.js +0 -1
- package/list/index.d.ts +0 -11
- package/list/index.js +0 -14
- package/list/types.d.ts +0 -3
- package/list/types.js +0 -1
- package/list-item/index.d.ts +0 -11
- package/list-item/index.js +0 -14
- package/list-item/types.d.ts +0 -3
- package/list-item/types.js +0 -1
- package/pagination/index.d.ts +0 -12
- package/pagination/index.js +0 -147
- package/pagination/types.d.ts +0 -16
- package/pagination/types.js +0 -1
- package/pop/index.d.ts +0 -11
- package/pop/index.js +0 -425
- package/pop/types.d.ts +0 -35
- package/pop/types.js +0 -1
- package/pop/utils.d.ts +0 -4
- package/pop/utils.js +0 -16
- package/popover/index.d.ts +0 -12
- package/popover/index.js +0 -146
- package/popover/types.d.ts +0 -40
- package/popover/types.js +0 -1
- package/popover/utils.d.ts +0 -4
- package/popover/utils.js +0 -10
- package/progress/index.d.ts +0 -12
- package/progress/index.js +0 -58
- package/progress/types.d.ts +0 -12
- package/progress/types.js +0 -1
- package/progress-stepper/index.d.ts +0 -11
- package/progress-stepper/index.js +0 -206
- package/progress-stepper/types.d.ts +0 -22
- package/progress-stepper/types.js +0 -1
- package/progress-stepper-item/index.d.ts +0 -12
- package/progress-stepper-item/index.js +0 -82
- package/progress-stepper-item/types.d.ts +0 -23
- package/progress-stepper-item/types.js +0 -1
- package/progress-stepper-item/utils.d.ts +0 -11
- package/progress-stepper-item/utils.js +0 -13
- package/radio/index.d.ts +0 -11
- package/radio/index.js +0 -154
- package/radio/types.d.ts +0 -14
- package/radio/types.js +0 -1
- package/radio-option/index.d.ts +0 -11
- package/radio-option/index.js +0 -79
- package/radio-option/types.d.ts +0 -18
- package/radio-option/types.js +0 -1
- package/rich-text/index.d.ts +0 -14
- package/rich-text/index.js +0 -75
- package/rich-text/types.d.ts +0 -12
- package/rich-text/types.js +0 -1
- package/rich-text/utils.d.ts +0 -7
- package/rich-text/utils.js +0 -107
- package/rich-textarea/index.d.ts +0 -11
- package/rich-textarea/index.js +0 -464
- package/rich-textarea/types.d.ts +0 -48
- package/rich-textarea/types.js +0 -1
- package/rich-textarea/utils.d.ts +0 -39
- package/rich-textarea/utils.js +0 -1730
- package/segment/index.d.ts +0 -12
- package/segment/index.js +0 -109
- package/segment/types.d.ts +0 -16
- package/segment/types.js +0 -1
- package/segment/utils.d.ts +0 -3
- package/segment/utils.js +0 -16
- package/segment-collapse/index.d.ts +0 -13
- package/segment-collapse/index.js +0 -60
- package/segment-collapse/types.d.ts +0 -11
- package/segment-collapse/types.js +0 -1
- package/segmented-control/index.d.ts +0 -11
- package/segmented-control/index.js +0 -85
- package/segmented-control/types.d.ts +0 -11
- package/segmented-control/types.js +0 -1
- package/segmented-control-option/index.d.ts +0 -11
- package/segmented-control-option/index.js +0 -95
- package/segmented-control-option/types.d.ts +0 -19
- package/segmented-control-option/types.js +0 -1
- package/segmented-icon-control/index.d.ts +0 -11
- package/segmented-icon-control/index.js +0 -101
- package/segmented-icon-control/types.d.ts +0 -14
- package/segmented-icon-control/types.js +0 -1
- package/segmented-icon-control-option/index.d.ts +0 -11
- package/segmented-icon-control-option/index.js +0 -82
- package/segmented-icon-control-option/types.d.ts +0 -16
- package/segmented-icon-control-option/types.js +0 -1
- package/select-button/index.d.ts +0 -13
- package/select-button/index.js +0 -202
- package/select-button/types.d.ts +0 -50
- package/select-button/types.js +0 -1
- package/select-menu/index.d.ts +0 -15
- package/select-menu/index.js +0 -339
- package/select-menu/types.d.ts +0 -41
- package/select-menu/types.js +0 -1
- package/select-menu-option/index.d.ts +0 -28
- package/select-menu-option/index.js +0 -65
- package/select-menu-option/types.d.ts +0 -26
- package/select-menu-option/types.js +0 -1
- package/skeleton/index.d.ts +0 -11
- package/skeleton/index.js +0 -108
- package/skeleton/types.d.ts +0 -9
- package/skeleton/types.js +0 -1
- package/skeleton-item/index.d.ts +0 -11
- package/skeleton-item/index.js +0 -11
- package/skeleton-item/types.d.ts +0 -13
- package/skeleton-item/types.js +0 -1
- package/spinner/index.d.ts +0 -11
- package/spinner/index.js +0 -58
- package/spinner/types.d.ts +0 -12
- package/spinner/types.js +0 -1
- package/standalone.d.ts +0 -85
- package/standalone.js +0 -87
- package/stop-events/index.d.ts +0 -1
- package/stop-events/index.js +0 -27
- package/table/index.d.ts +0 -11
- package/table/index.js +0 -14
- package/table/types.d.ts +0 -3
- package/table/types.js +0 -1
- package/table-body/index.d.ts +0 -11
- package/table-body/index.js +0 -14
- package/table-body/types.d.ts +0 -3
- package/table-body/types.js +0 -1
- package/table-cell/index.d.ts +0 -11
- package/table-cell/index.js +0 -21
- package/table-cell/types.d.ts +0 -9
- package/table-cell/types.js +0 -1
- package/table-cell/utils.d.ts +0 -2
- package/table-cell/utils.js +0 -1
- package/table-head/index.d.ts +0 -11
- package/table-head/index.js +0 -14
- package/table-head/types.d.ts +0 -3
- package/table-head/types.js +0 -1
- package/table-head-cell/index.d.ts +0 -12
- package/table-head-cell/index.js +0 -57
- package/table-head-cell/types.d.ts +0 -15
- package/table-head-cell/types.js +0 -1
- package/table-row/index.d.ts +0 -11
- package/table-row/index.js +0 -42
- package/table-row/types.d.ts +0 -11
- package/table-row/types.js +0 -1
- package/tabs/index.d.ts +0 -11
- package/tabs/index.js +0 -80
- package/tabs/types.d.ts +0 -18
- package/tabs/types.js +0 -1
- package/tabs-icon-option/index.d.ts +0 -11
- package/tabs-icon-option/index.js +0 -79
- package/tabs-icon-option/types.d.ts +0 -19
- package/tabs-icon-option/types.js +0 -1
- package/tabs-option/index.d.ts +0 -12
- package/tabs-option/index.js +0 -86
- package/tabs-option/types.d.ts +0 -25
- package/tabs-option/types.js +0 -1
- package/tag/index.d.ts +0 -12
- package/tag/index.js +0 -84
- package/tag/types.d.ts +0 -23
- package/tag/types.js +0 -1
- package/tag/utils.d.ts +0 -2
- package/tag/utils.js +0 -6
- package/text/index.d.ts +0 -11
- package/text/index.js +0 -64
- package/text/types.d.ts +0 -30
- package/text/types.js +0 -1
- package/text/utils.d.ts +0 -2
- package/text/utils.js +0 -1
- package/textarea/index.d.ts +0 -11
- package/textarea/index.js +0 -322
- package/textarea/types.d.ts +0 -60
- package/textarea/types.js +0 -1
- package/tile-control/index.d.ts +0 -11
- package/tile-control/index.js +0 -110
- package/tile-control/types.d.ts +0 -37
- package/tile-control/types.js +0 -1
- package/tile-control-option/index.d.ts +0 -11
- package/tile-control-option/index.js +0 -98
- package/tile-control-option/types.d.ts +0 -37
- package/tile-control-option/types.js +0 -1
- package/time-picker/index.d.ts +0 -15
- package/time-picker/index.js +0 -337
- package/time-picker/types.d.ts +0 -34
- package/time-picker/types.js +0 -1
- package/time-picker/utils.d.ts +0 -11
- package/time-picker/utils.js +0 -75
- package/title/index.d.ts +0 -11
- package/title/index.js +0 -60
- package/title/types.d.ts +0 -31
- package/title/types.js +0 -1
- package/title/utils.d.ts +0 -3
- package/title/utils.js +0 -17
- package/toast/index.d.ts +0 -13
- package/toast/index.js +0 -86
- package/toast/types.d.ts +0 -28
- package/toast/types.js +0 -1
- package/toast/utils.d.ts +0 -2
- package/toast/utils.js +0 -1
- package/toast-manager/index.d.ts +0 -13
- package/toast-manager/index.js +0 -170
- package/toast-manager/types.d.ts +0 -13
- package/toast-manager/types.js +0 -1
- package/toast-manager/utils.d.ts +0 -2
- package/toast-manager/utils.js +0 -1
- package/toggle/index.d.ts +0 -11
- package/toggle/index.js +0 -141
- package/toggle/types.d.ts +0 -23
- package/toggle/types.js +0 -1
- package/tooltip/index.d.ts +0 -13
- package/tooltip/index.js +0 -264
- package/tooltip/tooltip-state.d.ts +0 -19
- package/tooltip/tooltip-state.js +0 -126
- package/tooltip/types.d.ts +0 -35
- package/tooltip/types.js +0 -1
- package/tooltip/utils.d.ts +0 -5
- package/tooltip/utils.js +0 -17
- package/utils/context.d.ts +0 -20
- package/utils/context.js +0 -84
- package/utils/countries.d.ts +0 -6
- package/utils/countries.js +0 -2
- package/utils/csv.d.ts +0 -5
- package/utils/csv.js +0 -22
- package/utils/debounce.d.ts +0 -8
- package/utils/debounce.js +0 -22
- package/utils/dom.d.ts +0 -34
- package/utils/dom.js +0 -154
- package/utils/element.d.ts +0 -16
- package/utils/element.js +0 -48
- package/utils/event-target.d.ts +0 -4
- package/utils/event-target.js +0 -26
- package/utils/get-react-event-handler.d.ts +0 -1
- package/utils/get-react-event-handler.js +0 -8
- package/utils/index.d.ts +0 -12
- package/utils/index.js +0 -12
- package/utils/markdown.d.ts +0 -19
- package/utils/markdown.js +0 -143
- package/utils/rect.d.ts +0 -4
- package/utils/rect.js +0 -28
- package/utils/size.d.ts +0 -5
- package/utils/size.js +0 -3
- package/utils/slot.d.ts +0 -4
- package/utils/slot.js +0 -38
- package/utils/throttle.d.ts +0 -4
- package/utils/throttle.js +0 -20
- package/utils/uid.d.ts +0 -1
- package/utils/uid.js +0 -13
- package/vertical-stepper/index.d.ts +0 -11
- package/vertical-stepper/index.js +0 -57
- package/vertical-stepper/types.d.ts +0 -13
- package/vertical-stepper/types.js +0 -1
- package/vertical-stepper-item/index.d.ts +0 -14
- package/vertical-stepper-item/index.js +0 -61
- package/vertical-stepper-item/types.d.ts +0 -24
- package/vertical-stepper-item/types.js +0 -1
- package/vertical-stepper-item/utils.d.ts +0 -2
- package/vertical-stepper-item/utils.js +0 -1
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/time-picker/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
}
|
package/time-picker/index.js
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import '../icon-button';
|
|
2
|
-
import '../icon';
|
|
3
|
-
import '../segmented-control';
|
|
4
|
-
import '../segmented-control-option';
|
|
5
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getRect, isAttrEqual, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
6
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;width:248px;padding:16px;box-sizing:border-box;gap:16px}#header{position:relative;width:100%;height:48px;font:var(--sinch-comp-time-picker-header-font);line-height:48px;user-select:none;color:var(--sinch-comp-time-picker-header-color-default-text-initial)}#footer{display:flex;justify-content:center;width:100%;height:32px}#picker{position:relative;width:216px;height:216px;border-radius:50%;box-sizing:border-box;border:1px solid var(--sinch-comp-time-picker-watch-face-color-default-border-initial);background-color:var(--sinch-comp-time-picker-watch-face-color-default-background-initial)}#picker-hours,#picker-minutes{position:absolute;left:0;top:0;width:100%;height:100%;border-radius:50%;pointer-events:none;user-select:none}.digit-hour-12,.digit-hour-24,.digit-minute{position:absolute;width:28px;height:28px;text-align:center;top:calc(50% - 14px);left:calc(50% - 14px);z-index:1;cursor:pointer}.digit-hour-12{font:var(--sinch-comp-time-picker-digit-font-default-h12);color:var(--sinch-comp-time-picker-digit-color-default-h12-initial);line-height:28px}.digit-hour-12.selected{font:var(--sinch-comp-time-picker-digit-font-checked-h12);color:var(--sinch-comp-time-picker-digit-color-checked-h12-default)}.digit-hour-24{font:var(--sinch-comp-time-picker-digit-font-default-h24);color:var(--sinch-comp-time-picker-digit-color-default-h24-initial);line-height:28px}.digit-hour-24.selected{font:var(--sinch-comp-time-picker-digit-font-checked-h24);color:var(--sinch-comp-time-picker-digit-color-checked-h24-initial)}.digit-minute{font:var(--sinch-comp-time-picker-digit-font-default-minutes);color:var(--sinch-comp-time-picker-digit-color-default-minute-initial);line-height:28px}.digit-minute.selected{font:var(--sinch-comp-time-picker-digit-font-checked-minutes);color:var(--sinch-comp-time-picker-digit-color-checked-minute-initial)}#picker-touch{position:absolute;left:0;top:0;width:100%;height:100%;cursor:pointer;border-radius:50%}#needle-hour,#needle-minute,#picker-touch::after{background-color:var(--sinch-comp-time-picker-needle-color-default-background-initial)}#needle-hour,#needle-minute{position:absolute;transform-origin:bottom center;transform:rotate(0);bottom:50%;height:50px;transition-duration:.25s;transition-timing-function:ease-in-out;transition-property:transform height;z-index:2;outline:0}@media (prefers-reduced-motion){#needle-hour,#needle-minute{transition:none}}#needle-hour{width:4px;left:calc(50% - 2px);border-radius:2px}#needle-minute{width:2px;left:calc(50% - 1px);border-radius:1px}#needle-hour:focus-visible,#needle-minute:focus-visible{background-color:var(--sinch-comp-time-picker-needle-color-default-background-focus)}#needle-minute:not(.selected)::after{content:"";position:absolute;transform:translateX(-50%);left:0;top:-16px;width:4px;height:4px;border-radius:50%;background-color:var(--sinch-comp-time-picker-digit-color-checked-minute-initial)}#picker-touch::after{content:"";position:absolute;top:50%;left:50%;width:12px;height:12px;border-radius:50%;transform:translate(-50%,-50%)}#header-hours,#header-minutes{position:absolute;padding:0 4px;width:50px;outline:0}#header-hours{right:calc(50% + 8px);text-align:right}#header-minutes{left:calc(50% + 8px)}#header-colon{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}#submit{position:absolute;right:0;top:50%;transform:translateY(-50%)}#submit-icon{--sinch-global-color-icon:var(--sinch-comp-time-picker-header-color-default-icon-initial)}:host([ampm]) .digit-hour-24{display:none}:host(:not([ampm])) #footer{display:none}</style><div id="wrapper"><div id="header"><div id="header-hours" role="meter" aria-valuemin="0" aria-valuemax="23" aria-valuenow="0" aria-valuetext="0"><span>00</span></div><div id="header-colon">:</div><div id="header-minutes" role="meter" aria-valuemin="0" aria-valuemax="59" aria-valuenow="0" aria-valuetext="0"><span>00</span></div><sinch-icon-button id="submit" size="s" aria-label="Submit"><sinch-icon id="icon-submit" slot="icon" name="done"></sinch-icon></sinch-icon-button></div><div id="picker" aria-hidden="true"><div id="picker-hours"></div><div id="picker-minutes"></div><div id="picker-touch"><div id="needle-hour" tabindex="0"></div><div id="needle-minute" tabindex="0"></div></div></div><div id="footer"><sinch-segmented-control id="ampm"><sinch-segmented-control-option value="am" text="AM" aria-label="AM"></sinch-segmented-control-option><sinch-segmented-control-option value="pm" text="PM" aria-label="PM"></sinch-segmented-control-option></sinch-segmented-control></div></div>';
|
|
7
|
-
import { getNeedleRotationDeg, getShortestCssDeg, hourToIndex, parseTime, stringifyHour, stringifyHourFace, stringifyMinute, stringifyTime } from './utils';
|
|
8
|
-
const template = document.createElement('template');
|
|
9
|
-
template.innerHTML = templateHTML;
|
|
10
|
-
const PICKER_RADIUS = 216 / 2;
|
|
11
|
-
const MINUTE_DIGIT_SIZE = 30;
|
|
12
|
-
const HOUR_12_DIGIT_SIZE = 26;
|
|
13
|
-
const HOUR_24_DIGIT_SIZE = 26;
|
|
14
|
-
const MINUTE_RADIUS = PICKER_RADIUS - MINUTE_DIGIT_SIZE;
|
|
15
|
-
const HOUR_12_RADIUS = MINUTE_RADIUS - HOUR_12_DIGIT_SIZE;
|
|
16
|
-
const HOUR_24_RADIUS = HOUR_12_RADIUS - HOUR_24_DIGIT_SIZE;
|
|
17
|
-
const NEEDLE_HOUR_12_LENGTH = HOUR_12_RADIUS;
|
|
18
|
-
const NEEDLE_HOUR_24_LENGTH = HOUR_24_RADIUS;
|
|
19
|
-
const NEEDLE_MINUTE_LENGTH = MINUTE_RADIUS;
|
|
20
|
-
defineCustomElement('sinch-time-picker', class extends NectaryElement {
|
|
21
|
-
#$pickerHours;
|
|
22
|
-
#$pickerMinutes;
|
|
23
|
-
#$pickerTouch;
|
|
24
|
-
#$needleHour;
|
|
25
|
-
#$needleMinute;
|
|
26
|
-
#$headerHours;
|
|
27
|
-
#$headerHoursText;
|
|
28
|
-
#$headerMinutes;
|
|
29
|
-
#$headerMinutesText;
|
|
30
|
-
#$ampm;
|
|
31
|
-
#$submitButton;
|
|
32
|
-
#hour = 0;
|
|
33
|
-
#minute = 0;
|
|
34
|
-
#controller = null;
|
|
35
|
-
constructor() {
|
|
36
|
-
super();
|
|
37
|
-
const shadowRoot = this.attachShadow();
|
|
38
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
39
|
-
this.#$pickerHours = shadowRoot.querySelector('#picker-hours');
|
|
40
|
-
this.#$pickerMinutes = shadowRoot.querySelector('#picker-minutes');
|
|
41
|
-
this.#$pickerTouch = shadowRoot.querySelector('#picker');
|
|
42
|
-
this.#$needleHour = shadowRoot.querySelector('#needle-hour');
|
|
43
|
-
this.#$needleMinute = shadowRoot.querySelector('#needle-minute');
|
|
44
|
-
this.#$headerHours = shadowRoot.querySelector('#header-hours');
|
|
45
|
-
this.#$headerMinutes = shadowRoot.querySelector('#header-minutes');
|
|
46
|
-
this.#$headerHoursText = shadowRoot.querySelector('#header-hours > span');
|
|
47
|
-
this.#$headerMinutesText = shadowRoot.querySelector('#header-minutes > span');
|
|
48
|
-
this.#$ampm = shadowRoot.querySelector('#ampm');
|
|
49
|
-
this.#$submitButton = shadowRoot.querySelector('#submit');
|
|
50
|
-
this.#$needleMinute.style.height = `${NEEDLE_MINUTE_LENGTH}px`;
|
|
51
|
-
this.#$needleHour.style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
|
|
52
|
-
const MINUTE_DIGIT_RADIUS = MINUTE_RADIUS + MINUTE_DIGIT_SIZE / 2;
|
|
53
|
-
const HOUR_12_DIGIT_RADIUS = HOUR_12_RADIUS + HOUR_12_DIGIT_SIZE / 2;
|
|
54
|
-
const HOUR_24_DIGIT_RADIUS = HOUR_24_RADIUS + HOUR_24_DIGIT_SIZE / 2;
|
|
55
|
-
const hours12Frag = document.createDocumentFragment();
|
|
56
|
-
for (let i = 0; i < 12; i++) {
|
|
57
|
-
const rad = Math.PI / 6 * (i - 3);
|
|
58
|
-
const el = document.createElement('div');
|
|
59
|
-
const x = Math.cos(rad) * HOUR_12_DIGIT_RADIUS;
|
|
60
|
-
const y = Math.sin(rad) * HOUR_12_DIGIT_RADIUS;
|
|
61
|
-
const hourDisplayValue = stringifyHourFace(i);
|
|
62
|
-
el.className = 'digit-hour-12';
|
|
63
|
-
el.style.transform = `translate(${x}px, ${y}px)`;
|
|
64
|
-
el.textContent = hourDisplayValue;
|
|
65
|
-
hours12Frag.appendChild(el);
|
|
66
|
-
}
|
|
67
|
-
this.#$pickerHours.appendChild(hours12Frag);
|
|
68
|
-
const hours24Frag = document.createDocumentFragment();
|
|
69
|
-
for (let i = 12; i < 24; i++) {
|
|
70
|
-
const rad = Math.PI / 6 * (i - 3);
|
|
71
|
-
const el = document.createElement('div');
|
|
72
|
-
const x = Math.cos(rad) * HOUR_24_DIGIT_RADIUS;
|
|
73
|
-
const y = Math.sin(rad) * HOUR_24_DIGIT_RADIUS;
|
|
74
|
-
const hourDisplayValue = stringifyHourFace(i);
|
|
75
|
-
el.className = 'digit-hour-24';
|
|
76
|
-
el.style.transform = `translate(${x}px, ${y}px)`;
|
|
77
|
-
el.textContent = hourDisplayValue;
|
|
78
|
-
hours24Frag.appendChild(el);
|
|
79
|
-
}
|
|
80
|
-
this.#$pickerHours.appendChild(hours24Frag);
|
|
81
|
-
const minutesFrag = document.createDocumentFragment();
|
|
82
|
-
for (let i = 0; i < 60; i += 5) {
|
|
83
|
-
const rad = Math.PI / 30 * (i - 15);
|
|
84
|
-
const el = document.createElement('div');
|
|
85
|
-
const x = Math.cos(rad) * MINUTE_DIGIT_RADIUS;
|
|
86
|
-
const y = Math.sin(rad) * MINUTE_DIGIT_RADIUS;
|
|
87
|
-
el.className = 'digit-minute';
|
|
88
|
-
el.style.transform = `translate(${x}px, ${y}px)`;
|
|
89
|
-
el.textContent = stringifyMinute(i);
|
|
90
|
-
minutesFrag.appendChild(el);
|
|
91
|
-
}
|
|
92
|
-
this.#$pickerMinutes.appendChild(minutesFrag);
|
|
93
|
-
}
|
|
94
|
-
connectedCallback() {
|
|
95
|
-
this.#controller = new AbortController();
|
|
96
|
-
const options = {
|
|
97
|
-
signal: this.#controller.signal
|
|
98
|
-
};
|
|
99
|
-
this.#$pickerTouch.addEventListener('click', this.#onPickerClick, options);
|
|
100
|
-
this.#$ampm.addEventListener('-change', this.#onAmPmChange, options);
|
|
101
|
-
this.#$submitButton.addEventListener('click', this.#onSubmitButtonClick, options);
|
|
102
|
-
this.#$needleHour.addEventListener('keydown', this.#onHoursKeydown, options);
|
|
103
|
-
this.#$needleMinute.addEventListener('keydown', this.#onMinutesKeydown, options);
|
|
104
|
-
this.addEventListener('-change', this.#onChangeReactHandler, options);
|
|
105
|
-
}
|
|
106
|
-
disconnectedCallback() {
|
|
107
|
-
this.#controller.abort();
|
|
108
|
-
this.#controller = null;
|
|
109
|
-
}
|
|
110
|
-
static get observedAttributes() {
|
|
111
|
-
return ['value', 'ampm', 'submit-aria-label'];
|
|
112
|
-
}
|
|
113
|
-
attributeChangedCallback(name, prevValue, newVal) {
|
|
114
|
-
if (isAttrEqual(prevValue, newVal)) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
switch (name) {
|
|
118
|
-
case 'value':
|
|
119
|
-
{
|
|
120
|
-
const {
|
|
121
|
-
hours,
|
|
122
|
-
minutes
|
|
123
|
-
} = parseTime(newVal);
|
|
124
|
-
this.#hour = hours;
|
|
125
|
-
this.#minute = minutes;
|
|
126
|
-
this.#render();
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
case 'ampm':
|
|
130
|
-
{
|
|
131
|
-
this.#render();
|
|
132
|
-
updateBooleanAttribute(this, 'ampm', isAttrTrue(newVal));
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
case 'submit-aria-label':
|
|
136
|
-
{
|
|
137
|
-
updateAttribute(this.#$submitButton, 'aria-label', newVal);
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
set value(value) {
|
|
143
|
-
updateAttribute(this, 'value', value);
|
|
144
|
-
}
|
|
145
|
-
get value() {
|
|
146
|
-
return getAttribute(this, 'value', '');
|
|
147
|
-
}
|
|
148
|
-
set ampm(value) {
|
|
149
|
-
updateBooleanAttribute(this, 'ampm', value);
|
|
150
|
-
}
|
|
151
|
-
get ampm() {
|
|
152
|
-
return getBooleanAttribute(this, 'ampm');
|
|
153
|
-
}
|
|
154
|
-
set submitAriaLabel(value) {
|
|
155
|
-
updateAttribute(this, 'submit-aria-label', value);
|
|
156
|
-
}
|
|
157
|
-
get submitAriaLabel() {
|
|
158
|
-
return getAttribute(this, 'submit-aria-label', '');
|
|
159
|
-
}
|
|
160
|
-
get submitButtonRect() {
|
|
161
|
-
return getRect(this.#$submitButton);
|
|
162
|
-
}
|
|
163
|
-
get amButtonRect() {
|
|
164
|
-
if (!this.ampm) {
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
const $am = this.#$ampm.querySelector('[value="am"]');
|
|
168
|
-
return $am != null ? getRect($am) : null;
|
|
169
|
-
}
|
|
170
|
-
get pmButtonRect() {
|
|
171
|
-
if (!this.ampm) {
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
const $pm = this.#$ampm.querySelector('[value="pm"]');
|
|
175
|
-
return $pm != null ? getRect($pm) : null;
|
|
176
|
-
}
|
|
177
|
-
hourDigitRect(hour) {
|
|
178
|
-
const $digit = this.#$pickerHours.children[hourToIndex(hour, !this.ampm)];
|
|
179
|
-
return $digit != null ? getRect($digit) : null;
|
|
180
|
-
}
|
|
181
|
-
minuteDigitRect(minute) {
|
|
182
|
-
const $digit = this.#$pickerMinutes.children[Math.round(minute / 5)];
|
|
183
|
-
return $digit != null ? getRect($digit) : null;
|
|
184
|
-
}
|
|
185
|
-
#getClickDegree(x, y) {
|
|
186
|
-
const touchRect = this.#$pickerTouch.getBoundingClientRect();
|
|
187
|
-
const cx = touchRect.width / 2;
|
|
188
|
-
const cy = touchRect.height / 2;
|
|
189
|
-
const px = x - touchRect.x;
|
|
190
|
-
const py = touchRect.height - y + touchRect.y;
|
|
191
|
-
const dx = px - cx;
|
|
192
|
-
const dy = py - cy;
|
|
193
|
-
const len = Math.sqrt(dx * dx + dy * dy);
|
|
194
|
-
const cosRad = dx / len;
|
|
195
|
-
const rad = Math.acos(cosRad * (dy < 0 ? -1 : 1));
|
|
196
|
-
const deg = rad * (180 / Math.PI);
|
|
197
|
-
let cssDeg = (deg - 90 - 360) % 360 * -1;
|
|
198
|
-
if (dy < 0) {
|
|
199
|
-
cssDeg += 180;
|
|
200
|
-
}
|
|
201
|
-
const rowIndex = len > MINUTE_RADIUS ? 0 : len > HOUR_12_RADIUS ? 1 : 2;
|
|
202
|
-
return [cssDeg, rowIndex];
|
|
203
|
-
}
|
|
204
|
-
#onPickerClick = e => {
|
|
205
|
-
const [cssDeg, rowIndex] = this.#getClickDegree(e.x, e.y);
|
|
206
|
-
const isHourRowClick = rowIndex > 0;
|
|
207
|
-
const isHour24RowClick = rowIndex > 1;
|
|
208
|
-
if (isHourRowClick) {
|
|
209
|
-
const digitIndex = Math.round(cssDeg / 30) % 12;
|
|
210
|
-
const is24 = getBooleanAttribute(this, 'ampm') === false;
|
|
211
|
-
if (is24) {
|
|
212
|
-
if (isHour24RowClick) {
|
|
213
|
-
this.#hour = digitIndex === 0 ? 0 : digitIndex + 12;
|
|
214
|
-
} else {
|
|
215
|
-
this.#hour = digitIndex === 0 ? 12 : digitIndex;
|
|
216
|
-
}
|
|
217
|
-
} else {
|
|
218
|
-
this.#hour = digitIndex + (this.#$ampm.value === 'pm' ? 12 : 0);
|
|
219
|
-
}
|
|
220
|
-
this.#$headerHours.focus();
|
|
221
|
-
} else {
|
|
222
|
-
this.#minute = Math.round(cssDeg / 6) % 60;
|
|
223
|
-
this.#$headerMinutes.focus();
|
|
224
|
-
}
|
|
225
|
-
this.#render();
|
|
226
|
-
};
|
|
227
|
-
#render() {
|
|
228
|
-
const is24 = getBooleanAttribute(this, 'ampm') === false;
|
|
229
|
-
this.#selectHour(is24);
|
|
230
|
-
this.#selectMinute();
|
|
231
|
-
this.#$headerHoursText.textContent = stringifyHour(this.#hour, is24);
|
|
232
|
-
this.#$headerMinutesText.textContent = stringifyMinute(this.#minute);
|
|
233
|
-
updateAttribute(this.#$headerHours, 'aria-valuenow', this.#hour);
|
|
234
|
-
updateAttribute(this.#$headerHours, 'aria-valuetext', this.#hour);
|
|
235
|
-
updateAttribute(this.#$headerMinutes, 'aria-valuenow', this.#minute);
|
|
236
|
-
updateAttribute(this.#$headerMinutes, 'aria-valuetext', this.#minute);
|
|
237
|
-
}
|
|
238
|
-
#selectHour(is24) {
|
|
239
|
-
const $hours = this.#$pickerHours.children;
|
|
240
|
-
const hourDigitIndex = this.#hour % 12;
|
|
241
|
-
const selectedIndex = hourToIndex(this.#hour, is24);
|
|
242
|
-
const currentCssDeg = getNeedleRotationDeg(this.#$needleHour);
|
|
243
|
-
const hourCssDeg = getShortestCssDeg(currentCssDeg, hourDigitIndex * 30);
|
|
244
|
-
for (let i = 0; i < $hours.length; i++) {
|
|
245
|
-
setClass($hours[i], 'selected', i === selectedIndex);
|
|
246
|
-
}
|
|
247
|
-
this.#$needleHour.style.transform = `rotate(${hourCssDeg}deg)`;
|
|
248
|
-
if (is24) {
|
|
249
|
-
if (this.#hour > 0 && this.#hour <= 12) {
|
|
250
|
-
this.#$needleHour.style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
|
|
251
|
-
} else {
|
|
252
|
-
this.#$needleHour.style.height = `${NEEDLE_HOUR_24_LENGTH}px`;
|
|
253
|
-
}
|
|
254
|
-
} else {
|
|
255
|
-
this.#$needleHour.style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
|
|
256
|
-
}
|
|
257
|
-
this.#$ampm.setAttribute('value', this.#hour >= 0 && this.#hour < 12 ? 'am' : 'pm');
|
|
258
|
-
}
|
|
259
|
-
#selectMinute() {
|
|
260
|
-
const $minutes = this.#$pickerMinutes.children;
|
|
261
|
-
const isNeedleSelected = this.#minute % 5 === 0;
|
|
262
|
-
const selectedIndex = this.#minute / 5;
|
|
263
|
-
const currentCssDeg = getNeedleRotationDeg(this.#$needleMinute);
|
|
264
|
-
const minuteCssDeg = getShortestCssDeg(currentCssDeg, this.#minute * 6);
|
|
265
|
-
for (let i = 0; i < $minutes.length; i++) {
|
|
266
|
-
setClass($minutes[i], 'selected', selectedIndex === i);
|
|
267
|
-
}
|
|
268
|
-
setClass(this.#$needleMinute, 'selected', isNeedleSelected);
|
|
269
|
-
this.#$needleMinute.style.transform = `rotate(${minuteCssDeg}deg)`;
|
|
270
|
-
}
|
|
271
|
-
#onAmPmChange = e => {
|
|
272
|
-
const value = e.detail;
|
|
273
|
-
switch (value) {
|
|
274
|
-
case 'am':
|
|
275
|
-
{
|
|
276
|
-
if (this.#hour >= 12) {
|
|
277
|
-
this.#hour -= 12;
|
|
278
|
-
this.#render();
|
|
279
|
-
}
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
case 'pm':
|
|
283
|
-
{
|
|
284
|
-
if (this.#hour < 12) {
|
|
285
|
-
this.#hour += 12;
|
|
286
|
-
this.#render();
|
|
287
|
-
}
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
#onSubmitButtonClick = () => {
|
|
293
|
-
const value = stringifyTime(this.#hour, this.#minute);
|
|
294
|
-
this.dispatchEvent(new CustomEvent('-change', {
|
|
295
|
-
detail: value
|
|
296
|
-
}));
|
|
297
|
-
};
|
|
298
|
-
#onHoursKeydown = e => {
|
|
299
|
-
switch (e.key) {
|
|
300
|
-
case 'ArrowUp':
|
|
301
|
-
{
|
|
302
|
-
e.preventDefault();
|
|
303
|
-
this.#hour = (this.#hour + 1) % 24;
|
|
304
|
-
this.#render();
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
case 'ArrowDown':
|
|
308
|
-
{
|
|
309
|
-
e.preventDefault();
|
|
310
|
-
this.#hour = (this.#hour + 23) % 24;
|
|
311
|
-
this.#render();
|
|
312
|
-
break;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
#onMinutesKeydown = e => {
|
|
317
|
-
switch (e.key) {
|
|
318
|
-
case 'ArrowUp':
|
|
319
|
-
{
|
|
320
|
-
e.preventDefault();
|
|
321
|
-
this.#minute = (this.#minute + 1) % 60;
|
|
322
|
-
this.#render();
|
|
323
|
-
break;
|
|
324
|
-
}
|
|
325
|
-
case 'ArrowDown':
|
|
326
|
-
{
|
|
327
|
-
e.preventDefault();
|
|
328
|
-
this.#minute = (this.#minute + 59) % 60;
|
|
329
|
-
this.#render();
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
#onChangeReactHandler = e => {
|
|
335
|
-
getReactEventHandler(this, 'on-change')?.(e);
|
|
336
|
-
};
|
|
337
|
-
});
|
package/time-picker/types.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { TRect, TSinchElementReact } from '../types';
|
|
2
|
-
export type TSinchTimePickerElement = HTMLElement & {
|
|
3
|
-
/** Time value in ISO 8601 format */
|
|
4
|
-
value: string;
|
|
5
|
-
/** AM/PM 12-hour clock system, `false` by default */
|
|
6
|
-
ampm: boolean;
|
|
7
|
-
/** Submit button label that is used for a11y */
|
|
8
|
-
submitAriaLabel: string;
|
|
9
|
-
readonly submitButtonRect: TRect;
|
|
10
|
-
readonly amButtonRect: TRect | null;
|
|
11
|
-
readonly pmButtonRect: TRect | null;
|
|
12
|
-
hourDigitRect(hour: number): TRect | null;
|
|
13
|
-
minuteDigitRect(minute: number): TRect | null;
|
|
14
|
-
/** Change value handler, return time in ISO 8601 format */
|
|
15
|
-
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
16
|
-
/** Time value in ISO 8601 format */
|
|
17
|
-
setAttribute(name: 'value', value: string): void;
|
|
18
|
-
/** AM/PM 12-hour clock system, `false` by default */
|
|
19
|
-
setAttribute(name: 'ampm', value: boolean): void;
|
|
20
|
-
/** Submit button label that is used for a11y */
|
|
21
|
-
setAttribute(name: 'submit-aria-label', value: string): void;
|
|
22
|
-
};
|
|
23
|
-
export type TSinchTimePickerReact = TSinchElementReact<TSinchTimePickerElement> & {
|
|
24
|
-
/** Time value in ISO 8601 format */
|
|
25
|
-
value: string;
|
|
26
|
-
/** AM/PM 12-hour clock system, `false` by default */
|
|
27
|
-
ampm?: boolean;
|
|
28
|
-
/** Label that is used for a11y */
|
|
29
|
-
'aria-label': string;
|
|
30
|
-
/** Submit button label that is used for a11y */
|
|
31
|
-
'submit-aria-label': string;
|
|
32
|
-
/** Change value handler, return time in ISO 8601 format */
|
|
33
|
-
'on-change'?: (e: CustomEvent<string>) => void;
|
|
34
|
-
};
|
package/time-picker/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/time-picker/utils.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const parseTime: (value: string | null) => {
|
|
2
|
-
hours: number;
|
|
3
|
-
minutes: number;
|
|
4
|
-
};
|
|
5
|
-
export declare const stringifyTime: (hour: number, minute: number) => string;
|
|
6
|
-
export declare const stringifyHour: (hour: number, is24: boolean) => string;
|
|
7
|
-
export declare const stringifyHourFace: (hour: number) => string;
|
|
8
|
-
export declare const stringifyMinute: (minute: number) => string;
|
|
9
|
-
export declare const hourToIndex: (hour: number, is24: boolean) => number;
|
|
10
|
-
export declare const getNeedleRotationDeg: (elem: HTMLElement) => number;
|
|
11
|
-
export declare const getShortestCssDeg: (currentDeg: number, nextDeg: number) => number;
|
package/time-picker/utils.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
export const parseTime = value => {
|
|
2
|
-
if (value === '' || value === null) {
|
|
3
|
-
return {
|
|
4
|
-
hours: 0,
|
|
5
|
-
minutes: 0
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
const timeParts = value.split(':');
|
|
9
|
-
const hours = parseInt(timeParts[0] ?? '00');
|
|
10
|
-
const minutes = parseInt(timeParts[1] ?? '00');
|
|
11
|
-
if (isNaN(hours) || hours > 23 || hours < 0) {
|
|
12
|
-
return {
|
|
13
|
-
hours: 0,
|
|
14
|
-
minutes: 0
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
if (isNaN(minutes) || minutes > 59 || minutes < 0) {
|
|
18
|
-
return {
|
|
19
|
-
hours: 0,
|
|
20
|
-
minutes: 0
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
hours,
|
|
25
|
-
minutes
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
const pad = value => {
|
|
29
|
-
return value.toString().padStart(2, '0');
|
|
30
|
-
};
|
|
31
|
-
export const stringifyTime = (hour, minute) => {
|
|
32
|
-
return `${pad(hour)}:${pad(minute)}:00`;
|
|
33
|
-
};
|
|
34
|
-
export const stringifyHour = (hour, is24) => {
|
|
35
|
-
if (is24) {
|
|
36
|
-
return pad(hour);
|
|
37
|
-
}
|
|
38
|
-
if (hour === 0 || hour === 12) {
|
|
39
|
-
return '12';
|
|
40
|
-
}
|
|
41
|
-
return pad(hour % 12);
|
|
42
|
-
};
|
|
43
|
-
export const stringifyHourFace = hour => {
|
|
44
|
-
return hour === 0 ? '12' : hour === 12 ? '24' : String(hour);
|
|
45
|
-
};
|
|
46
|
-
export const stringifyMinute = minute => {
|
|
47
|
-
return pad(minute);
|
|
48
|
-
};
|
|
49
|
-
export const hourToIndex = (hour, is24) => {
|
|
50
|
-
if (is24) {
|
|
51
|
-
if (hour === 0) {
|
|
52
|
-
return 12;
|
|
53
|
-
}
|
|
54
|
-
if (hour === 12) {
|
|
55
|
-
return 0;
|
|
56
|
-
}
|
|
57
|
-
return hour;
|
|
58
|
-
}
|
|
59
|
-
return hour % 12;
|
|
60
|
-
};
|
|
61
|
-
export const getNeedleRotationDeg = elem => {
|
|
62
|
-
const match = elem.style.transform.match(/^rotate\((-?\d+)deg\)$/);
|
|
63
|
-
if (match === null) {
|
|
64
|
-
return 0;
|
|
65
|
-
}
|
|
66
|
-
return Number(match[1]);
|
|
67
|
-
};
|
|
68
|
-
export const getShortestCssDeg = (currentDeg, nextDeg) => {
|
|
69
|
-
const angle = currentDeg % 360;
|
|
70
|
-
const diff = (360 - (angle - nextDeg)) % 360;
|
|
71
|
-
if (diff > 180) {
|
|
72
|
-
return currentDeg - 360 + diff;
|
|
73
|
-
}
|
|
74
|
-
return currentDeg + diff;
|
|
75
|
-
};
|
package/title/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TSinchTitleElement, TSinchTitleReact } from './types';
|
|
2
|
-
declare global {
|
|
3
|
-
namespace JSX {
|
|
4
|
-
interface IntrinsicElements {
|
|
5
|
-
'sinch-title': TSinchTitleReact;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
interface HTMLElementTagNameMap {
|
|
9
|
-
'sinch-title': TSinchTitleElement;
|
|
10
|
-
}
|
|
11
|
-
}
|
package/title/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute, isAttrTrue, isAttrEqual } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-m)}:host([type=xl]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-xl)}:host([type="l"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-l)}:host([type="m"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-m)}:host([type="s"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-s)}:host([type=xs]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-xs)}#text{letter-spacing:-2%;color:var(--sinch-global-color-text,var(--sinch-sys-color-text-default));font:var(--sinch-comp-title-font)}:host([ellipsis]) #text{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}</style><span id="text"></span>';
|
|
3
|
-
import { typeValues } from './utils';
|
|
4
|
-
const template = document.createElement('template');
|
|
5
|
-
template.innerHTML = templateHTML;
|
|
6
|
-
defineCustomElement('sinch-title', class extends NectaryElement {
|
|
7
|
-
#$text;
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
const shadowRoot = this.attachShadow();
|
|
11
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
-
this.#$text = shadowRoot.querySelector('#text');
|
|
13
|
-
}
|
|
14
|
-
connectedCallback() {
|
|
15
|
-
this.setAttribute('role', 'heading');
|
|
16
|
-
}
|
|
17
|
-
static get observedAttributes() {
|
|
18
|
-
return ['text', 'level', 'ellipsis'];
|
|
19
|
-
}
|
|
20
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
21
|
-
switch (name) {
|
|
22
|
-
case 'text':
|
|
23
|
-
{
|
|
24
|
-
this.#$text.textContent = newVal;
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
case 'level':
|
|
28
|
-
{
|
|
29
|
-
updateAttribute(this, 'aria-level', newVal);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case 'ellipsis':
|
|
33
|
-
{
|
|
34
|
-
if (isAttrEqual(oldVal, newVal)) {
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
updateBooleanAttribute(this, 'ellipsis', isAttrTrue(newVal));
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
get text() {
|
|
43
|
-
return getAttribute(this, 'text', '');
|
|
44
|
-
}
|
|
45
|
-
set text(value) {
|
|
46
|
-
updateAttribute(this, 'text', value);
|
|
47
|
-
}
|
|
48
|
-
set type(value) {
|
|
49
|
-
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
50
|
-
}
|
|
51
|
-
get type() {
|
|
52
|
-
return getLiteralAttribute(this, typeValues, 'type');
|
|
53
|
-
}
|
|
54
|
-
set ellipsis(isEllipsis) {
|
|
55
|
-
updateBooleanAttribute(this, 'ellipsis', isEllipsis);
|
|
56
|
-
}
|
|
57
|
-
get ellipsis() {
|
|
58
|
-
return getBooleanAttribute(this, 'ellipsis');
|
|
59
|
-
}
|
|
60
|
-
});
|
package/title/types.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export type TSinchTitleType = 'xl' | 'l' | 'm' | 's' | 'xs';
|
|
3
|
-
export type TSinchTitleLevel = '1' | '2' | '3' | '4' | '5' | '6';
|
|
4
|
-
export type TSinchTitleElement = HTMLElement & {
|
|
5
|
-
/** Text */
|
|
6
|
-
text: string;
|
|
7
|
-
/** Type */
|
|
8
|
-
type: TSinchTitleType;
|
|
9
|
-
/** Semantical level */
|
|
10
|
-
level: TSinchTitleLevel;
|
|
11
|
-
/** Cuts the long title with “…” ellipsis */
|
|
12
|
-
ellipsis: boolean;
|
|
13
|
-
/** Text */
|
|
14
|
-
setAttribute(name: 'text', value: string): void;
|
|
15
|
-
/** Type */
|
|
16
|
-
setAttribute(name: 'type', value: TSinchTitleType): void;
|
|
17
|
-
/** Semantical level */
|
|
18
|
-
setAttribute(name: 'level', value: TSinchTitleLevel): void;
|
|
19
|
-
/** Cuts the long title with “…” ellipsis */
|
|
20
|
-
setAttribute(name: 'ellipsis', value: ''): void;
|
|
21
|
-
};
|
|
22
|
-
export type TSinchTitleReact = TSinchElementReact<TSinchTitleElement> & {
|
|
23
|
-
/** Text */
|
|
24
|
-
text: string;
|
|
25
|
-
/** Type */
|
|
26
|
-
type: TSinchTitleType;
|
|
27
|
-
/** Semantical level */
|
|
28
|
-
level: TSinchTitleLevel;
|
|
29
|
-
/** Cuts the long title with “…” ellipsis */
|
|
30
|
-
ellipsis?: boolean;
|
|
31
|
-
};
|
package/title/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/title/utils.d.ts
DELETED
package/title/utils.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const typeValues = ['xl', 'l', 'm', 's', 'xs'];
|
|
2
|
-
export const getTitleLevelFromType = type => {
|
|
3
|
-
switch (type) {
|
|
4
|
-
case 'xl':
|
|
5
|
-
return '1';
|
|
6
|
-
case 'l':
|
|
7
|
-
return '2';
|
|
8
|
-
case 'm':
|
|
9
|
-
return '3';
|
|
10
|
-
case 's':
|
|
11
|
-
return '4';
|
|
12
|
-
case 'xs':
|
|
13
|
-
return '5';
|
|
14
|
-
default:
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
};
|
package/toast/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import '../icon';
|
|
2
|
-
import '../rich-text';
|
|
3
|
-
import type { TSinchToastElement, TSinchToastReact } from './types';
|
|
4
|
-
declare global {
|
|
5
|
-
namespace JSX {
|
|
6
|
-
interface IntrinsicElements {
|
|
7
|
-
'sinch-toast': TSinchToastReact;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
interface HTMLElementTagNameMap {
|
|
11
|
-
'sinch-toast': TSinchToastElement;
|
|
12
|
-
}
|
|
13
|
-
}
|