@nectary/components 1.4.0 → 2.1.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.js +0 -3
- package/accordion/types.d.ts +0 -3
- package/accordion-item/index.d.ts +2 -0
- package/accordion-item/index.js +33 -34
- package/action-menu/index.js +5 -1
- package/action-menu-option/index.js +2 -2
- package/alert/index.js +4 -21
- package/alert/utils.d.ts +0 -3
- package/alert/utils.js +1 -6
- package/avatar/index.js +5 -21
- package/avatar/utils.d.ts +0 -4
- package/avatar/utils.js +2 -15
- package/badge/index.js +36 -68
- package/badge/types.d.ts +0 -4
- package/badge/utils.d.ts +0 -6
- package/badge/utils.js +1 -17
- package/button/index.js +25 -27
- package/button/types.d.ts +2 -2
- package/button/utils.d.ts +0 -3
- package/button/utils.js +1 -9
- package/card/index.js +5 -16
- package/card/types.d.ts +0 -6
- package/card-container/index.js +1 -1
- package/chat-block/index.js +1 -1
- package/chat-bubble/index.d.ts +0 -1
- package/chat-bubble/index.js +3 -25
- package/checkbox/index.js +32 -33
- package/checkbox/types.d.ts +0 -3
- package/chip/index.js +54 -44
- package/chip/utils.d.ts +0 -1
- package/chip/utils.js +2 -7
- package/code-tag/index.js +1 -1
- package/color-menu/index.d.ts +0 -3
- package/color-menu/index.js +55 -101
- package/color-menu/types.d.ts +0 -4
- package/color-menu-option/index.d.ts +14 -0
- package/color-menu-option/index.js +52 -0
- package/color-menu-option/types.d.ts +9 -0
- package/color-menu-option/utils.d.ts +1 -0
- package/color-menu-option/utils.js +11 -0
- package/color-swatch/index.js +2 -5
- package/color-swatch/utils.d.ts +0 -1
- package/color-swatch/utils.js +2 -7
- package/date-picker/index.js +3 -40
- package/date-picker/types.d.ts +0 -3
- package/date-picker/utils.d.ts +0 -8
- package/date-picker/utils.js +0 -20
- package/dialog/index.js +2 -6
- package/dialog/types.d.ts +0 -2
- package/emoji/index.js +1 -1
- package/emoji-picker/index.d.ts +1 -0
- package/emoji-picker/index.js +36 -34
- package/field/index.js +39 -32
- package/file-drop/index.js +1 -1
- package/file-status/index.js +4 -25
- package/file-status/utils.d.ts +0 -3
- package/file-status/utils.js +1 -6
- package/flag/index.js +1 -1
- package/grid/index.js +1 -1
- package/help-tooltip/index.d.ts +0 -1
- package/help-tooltip/index.js +3 -13
- package/horizontal-stepper/index.js +1 -1
- package/horizontal-stepper-item/index.d.ts +2 -0
- package/horizontal-stepper-item/index.js +8 -12
- package/icon/index.js +1 -1
- package/icon-button/index.js +23 -27
- package/icon-button/utils.d.ts +0 -3
- package/icon-button/utils.js +1 -9
- package/inline-alert/index.js +20 -37
- package/inline-alert/utils.d.ts +0 -3
- package/inline-alert/utils.js +1 -6
- package/input/index.d.ts +0 -3
- package/input/index.js +22 -58
- package/input/types.d.ts +1 -5
- package/input/utils.d.ts +0 -3
- package/input/utils.js +1 -6
- package/link/index.js +35 -37
- package/list-item/index.js +1 -1
- package/package.json +11 -11
- package/pagination/index.js +8 -21
- package/pagination/types.d.ts +0 -3
- package/pop/index.js +39 -38
- package/pop/utils.d.ts +0 -3
- package/pop/utils.js +0 -5
- package/popover/index.js +42 -51
- package/popover/utils.d.ts +0 -3
- package/popover/utils.js +0 -5
- package/progress/index.js +20 -15
- package/radio/index.js +19 -6
- package/radio/types.d.ts +3 -3
- package/radio-option/index.js +35 -27
- package/rich-text/index.js +3 -10
- package/rich-text/utils.d.ts +0 -3
- package/rich-text/utils.js +1 -6
- package/segment/index.js +3 -7
- package/segment-collapse/index.js +2 -11
- package/segment-collapse/types.d.ts +0 -3
- package/segmented-control/index.js +0 -3
- package/segmented-control/types.d.ts +0 -3
- package/segmented-control-option/index.js +20 -19
- package/segmented-icon-control/index.js +1 -4
- package/segmented-icon-control/types.d.ts +0 -3
- package/segmented-icon-control-option/index.js +18 -14
- package/select-button/index.js +29 -31
- package/select-menu/index.js +18 -8
- package/select-menu-option/index.js +2 -5
- package/skeleton/index.js +1 -1
- package/skeleton-item/index.js +1 -1
- package/spinner/index.js +3 -10
- package/table/index.js +1 -1
- package/table-body/index.js +1 -1
- package/table-cell/index.js +1 -1
- package/table-head-cell/index.d.ts +1 -0
- package/table-head-cell/index.js +12 -3
- package/table-row/index.js +18 -2
- package/tabs/index.js +1 -4
- package/tabs/types.d.ts +0 -3
- package/tabs-icon-option/index.js +4 -2
- package/tabs-option/index.js +25 -20
- package/tag/index.js +17 -12
- package/tag/utils.d.ts +0 -1
- package/tag/utils.js +2 -7
- package/text/index.js +24 -21
- package/text/utils.d.ts +0 -3
- package/text/utils.js +1 -6
- package/textarea/index.js +10 -6
- package/textarea/types.d.ts +0 -3
- package/tile-control/index.js +23 -25
- package/tile-control/types.d.ts +0 -3
- package/tile-control-option/index.js +1 -1
- package/time-picker/index.js +2 -11
- package/time-picker/types.d.ts +0 -3
- package/time-picker/utils.d.ts +1 -1
- package/time-picker/utils.js +17 -5
- package/title/index.js +28 -30
- package/title/utils.d.ts +0 -7
- package/title/utils.js +1 -29
- package/toast/index.js +22 -39
- package/toast/utils.d.ts +0 -3
- package/toast/utils.js +1 -6
- package/toggle/index.js +33 -30
- package/toggle/types.d.ts +0 -3
- package/tooltip/index.js +3 -15
- package/tooltip/types.d.ts +0 -12
- package/tooltip/utils.d.ts +0 -5
- package/tooltip/utils.js +0 -10
- package/utils/dom.js +0 -5
- package/utils/element.js +2 -2
- package/utils/size.d.ts +0 -5
- package/utils/size.js +1 -17
- package/vertical-stepper/index.js +1 -1
- package/vertical-stepper-item/index.d.ts +2 -0
- package/vertical-stepper-item/index.js +8 -12
- package/logo/create-logo-class.d.ts +0 -1
- package/logo/create-logo-class.js +0 -52
- package/logo/engage-icon/index.d.ts +0 -11
- package/logo/engage-icon/index.js +0 -4
- package/logo/engage-icon-wordmark/index.d.ts +0 -11
- package/logo/engage-icon-wordmark/index.js +0 -4
- package/logo/sinch-icon/index.d.ts +0 -11
- package/logo/sinch-icon/index.js +0 -4
- package/logo/sinch-icon-wordmark/index.d.ts +0 -11
- package/logo/sinch-icon-wordmark/index.js +0 -4
- package/logo/types.d.ts +0 -11
- package/theme/accordion-item.css +0 -4
- package/theme/alert.css +0 -6
- package/theme/avatar.css +0 -25
- package/theme/badge.css +0 -15
- package/theme/button.css +0 -146
- package/theme/chat.css +0 -9
- package/theme/chip.css +0 -68
- package/theme/color-menu.css +0 -4
- package/theme/color-swatch.css +0 -71
- package/theme/colors.d.ts +0 -4
- package/theme/colors.js +0 -4
- package/theme/contextual.css +0 -40
- package/theme/date-picker.css +0 -7
- package/theme/dialog.css +0 -4
- package/theme/elevation.css +0 -7
- package/theme/emoji-picker.css +0 -13
- package/theme/emoji.css +0 -5
- package/theme/file-status.css +0 -7
- package/theme/flag.css +0 -4
- package/theme/fonts.css +0 -86
- package/theme/fonts.json +0 -89
- package/theme/help-tooltip.css +0 -5
- package/theme/horizontal-stepper.css +0 -5
- package/theme/icon-button.css +0 -68
- package/theme/icon.css +0 -7
- package/theme/index.css +0 -4
- package/theme/index.d.ts +0 -39
- package/theme/index.js +0 -39
- package/theme/inline-alert.css +0 -7
- package/theme/input.css +0 -10
- package/theme/link.css +0 -5
- package/theme/pagination.css +0 -5
- package/theme/palette.css +0 -90
- package/theme/segment.css +0 -4
- package/theme/select-button.css +0 -10
- package/theme/select-menu.css +0 -6
- package/theme/shapes.css +0 -8
- package/theme/size.css +0 -9
- package/theme/spinner.css +0 -7
- package/theme/tag.css +0 -67
- package/theme/time-picker.css +0 -4
- package/theme/toast.css +0 -7
- package/theme/typography.css +0 -16
- package/theme/vertical-stepper.css +0 -5
- /package/{logo → color-menu-option}/types.js +0 -0
package/button/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineCustomElement, getBooleanAttribute, getAttribute, isAttrTrue, updateBooleanAttribute, updateAttribute, NectaryElement, getReactEventHandler, getLiteralAttribute, updateLiteralAttribute, Context, subscribeContext } from '../utils';
|
|
2
|
-
import {
|
|
3
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;--sinch-size:var(--sinch-size-m);--sinch-size-icon:var(--sinch-button-icon-size-m);--sinch-shape-radius:var(--sinch-shape-radius-m);--sinch-button-font:var(--sinch-button-font-m)}:host([data-size="l"]){--sinch-size:var(--sinch-size-l);--sinch-size-icon:var(--sinch-button-icon-size-l);--sinch-shape-radius:var(--sinch-shape-radius-l);--sinch-button-font:var(--sinch-button-font-l)}:host([data-size="m"]){--sinch-size:var(--sinch-size-m);--sinch-size-icon:var(--sinch-button-icon-size-m);--sinch-shape-radius:var(--sinch-shape-radius-m);--sinch-button-font:var(--sinch-button-font-m)}:host([data-size="s"]){--sinch-size:var(--sinch-size-s);--sinch-size-icon:var(--sinch-button-icon-size-s);--sinch-shape-radius:var(--sinch-shape-radius-s);--sinch-button-font:var(--sinch-button-font-s)}:host([type=primary]){--sinch-button-color-background:var(--sinch-button-primary-color-background);--sinch-button-color-background-hover:var(--sinch-button-primary-color-background-hover);--sinch-button-color-background-active:var(--sinch-button-primary-color-background-active);--sinch-button-color-background-disabled:var(--sinch-button-primary-color-background-disabled);--sinch-button-color-border:var(--sinch-button-primary-color-border);--sinch-button-color-border-hover:var(--sinch-button-primary-color-border-hover);--sinch-button-color-border-active:var(--sinch-button-primary-color-border-active);--sinch-button-color-border-disabled:var(--sinch-button-primary-color-border-disabled);--sinch-button-color-text:var(--sinch-button-primary-color-text);--sinch-button-color-text-hover:var(--sinch-button-primary-color-text-hover);--sinch-button-color-text-active:var(--sinch-button-primary-color-text-active);--sinch-button-color-text-disabled:var(--sinch-button-primary-color-text-disabled);--sinch-button-color-icon:var(--sinch-button-primary-color-icon);--sinch-button-color-icon-hover:var(--sinch-button-primary-color-icon-hover);--sinch-button-color-icon-active:var(--sinch-button-primary-color-icon-active);--sinch-button-color-icon-disabled:var(--sinch-button-primary-color-icon-disabled);--sinch-button-mix-blend-mode:var(--sinch-button-primary-mix-blend-mode);--sinch-elevation-level:var(--sinch-elevation-level-1)}:host([type=secondary]){--sinch-button-color-background:var(--sinch-button-secondary-color-background);--sinch-button-color-background-hover:var(--sinch-button-secondary-color-background-hover);--sinch-button-color-background-active:var(--sinch-button-secondary-color-background-active);--sinch-button-color-background-disabled:var(--sinch-button-secondary-color-background-disabled);--sinch-button-color-border:var(--sinch-button-secondary-color-border);--sinch-button-color-border-hover:var(--sinch-button-secondary-color-border-hover);--sinch-button-color-border-active:var(--sinch-button-secondary-color-border-active);--sinch-button-color-border-disabled:var(--sinch-button-secondary-color-border-disabled);--sinch-button-color-text:var(--sinch-button-secondary-color-text);--sinch-button-color-text-hover:var(--sinch-button-secondary-color-text-hover);--sinch-button-color-text-active:var(--sinch-button-secondary-color-text-active);--sinch-button-color-text-disabled:var(--sinch-button-secondary-color-text-disabled);--sinch-button-color-icon:var(--sinch-button-secondary-color-icon);--sinch-button-color-icon-hover:var(--sinch-button-secondary-color-icon-hover);--sinch-button-color-icon-active:var(--sinch-button-secondary-color-icon-active);--sinch-button-color-icon-disabled:var(--sinch-button-secondary-color-icon-disabled);--sinch-button-mix-blend-mode:var(--sinch-button-secondary-mix-blend-mode);--sinch-elevation-level:var(--sinch-elevation-level-1)}:host([type=tertiary]){--sinch-button-color-background:var(--sinch-button-tertiary-color-background);--sinch-button-color-background-hover:var(--sinch-button-tertiary-color-background-hover);--sinch-button-color-background-active:var(--sinch-button-tertiary-color-background-active);--sinch-button-color-background-disabled:var(--sinch-button-tertiary-color-background-disabled);--sinch-button-color-border:var(--sinch-button-tertiary-color-border);--sinch-button-color-border-hover:var(--sinch-button-tertiary-color-border-hover);--sinch-button-color-border-active:var(--sinch-button-tertiary-color-border-active);--sinch-button-color-border-disabled:var(--sinch-button-tertiary-color-border-disabled);--sinch-button-color-text:var(--sinch-button-tertiary-color-text);--sinch-button-color-text-hover:var(--sinch-button-tertiary-color-text-hover);--sinch-button-color-text-active:var(--sinch-button-tertiary-color-text-active);--sinch-button-color-text-disabled:var(--sinch-button-tertiary-color-text-disabled);--sinch-button-color-icon:var(--sinch-button-tertiary-color-icon);--sinch-button-color-icon-hover:var(--sinch-button-tertiary-color-icon-hover);--sinch-button-color-icon-active:var(--sinch-button-tertiary-color-icon-active);--sinch-button-color-icon-disabled:var(--sinch-button-tertiary-color-icon-disabled);--sinch-button-mix-blend-mode:var(--sinch-button-tertiary-mix-blend-mode);--sinch-elevation-level:var(--sinch-elevation-level-0)}:host([type=cta-primary]){--sinch-button-color-background:var(--sinch-button-cta-primary-color-background);--sinch-button-color-background-hover:var(--sinch-button-cta-primary-color-background-hover);--sinch-button-color-background-active:var(--sinch-button-cta-primary-color-background-active);--sinch-button-color-background-disabled:var(--sinch-button-cta-primary-color-background-disabled);--sinch-button-color-border:var(--sinch-button-cta-primary-color-border);--sinch-button-color-border-hover:var(--sinch-button-cta-primary-color-border-hover);--sinch-button-color-border-active:var(--sinch-button-cta-primary-color-border-active);--sinch-button-color-border-disabled:var(--sinch-button-cta-primary-color-border-disabled);--sinch-button-color-text:var(--sinch-button-cta-primary-color-text);--sinch-button-color-text-hover:var(--sinch-button-cta-primary-color-text-hover);--sinch-button-color-text-active:var(--sinch-button-cta-primary-color-text-active);--sinch-button-color-text-disabled:var(--sinch-button-cta-primary-color-text-disabled);--sinch-button-color-icon:var(--sinch-button-cta-primary-color-icon);--sinch-button-color-icon-hover:var(--sinch-button-cta-primary-color-icon-hover);--sinch-button-color-icon-active:var(--sinch-button-cta-primary-color-icon-active);--sinch-button-color-icon-disabled:var(--sinch-button-cta-primary-color-icon-disabled);--sinch-button-mix-blend-mode:var(--sinch-button-cta-primary-mix-blend-mode);--sinch-elevation-level:var(--sinch-elevation-level-1)}:host([type=cta-secondary]){--sinch-button-color-background:var(--sinch-button-cta-secondary-color-background);--sinch-button-color-background-hover:var(--sinch-button-cta-secondary-color-background-hover);--sinch-button-color-background-active:var(--sinch-button-cta-secondary-color-background-active);--sinch-button-color-background-disabled:var(--sinch-button-cta-secondary-color-background-disabled);--sinch-button-color-border:var(--sinch-button-cta-secondary-color-border);--sinch-button-color-border-hover:var(--sinch-button-cta-secondary-color-border-hover);--sinch-button-color-border-active:var(--sinch-button-cta-secondary-color-border-active);--sinch-button-color-border-disabled:var(--sinch-button-cta-secondary-color-border-disabled);--sinch-button-color-text:var(--sinch-button-cta-secondary-color-text);--sinch-button-color-text-hover:var(--sinch-button-cta-secondary-color-text-hover);--sinch-button-color-text-active:var(--sinch-button-cta-secondary-color-text-active);--sinch-button-color-text-disabled:var(--sinch-button-cta-secondary-color-text-disabled);--sinch-button-color-icon:var(--sinch-button-cta-secondary-color-icon);--sinch-button-color-icon-hover:var(--sinch-button-cta-secondary-color-icon-hover);--sinch-button-color-icon-active:var(--sinch-button-cta-secondary-color-icon-active);--sinch-button-color-icon-disabled:var(--sinch-button-cta-secondary-color-icon-disabled);--sinch-button-mix-blend-mode:var(--sinch-button-cta-secondary-mix-blend-mode);--sinch-elevation-level:var(--sinch-elevation-level-1)}:host([type=destructive]){--sinch-button-color-background:var(--sinch-button-destructive-color-background);--sinch-button-color-background-hover:var(--sinch-button-destructive-color-background-hover);--sinch-button-color-background-active:var(--sinch-button-destructive-color-background-active);--sinch-button-color-background-disabled:var(--sinch-button-destructive-color-background-disabled);--sinch-button-color-border:var(--sinch-button-destructive-color-border);--sinch-button-color-border-hover:var(--sinch-button-destructive-color-border-hover);--sinch-button-color-border-active:var(--sinch-button-destructive-color-border-active);--sinch-button-color-border-disabled:var(--sinch-button-destructive-color-border-disabled);--sinch-button-color-text:var(--sinch-button-destructive-color-text);--sinch-button-color-text-hover:var(--sinch-button-destructive-color-text-hover);--sinch-button-color-text-active:var(--sinch-button-destructive-color-text-active);--sinch-button-color-text-disabled:var(--sinch-button-destructive-color-text-disabled);--sinch-button-color-icon:var(--sinch-button-destructive-color-icon);--sinch-button-color-icon-hover:var(--sinch-button-destructive-color-icon-hover);--sinch-button-color-icon-active:var(--sinch-button-destructive-color-icon-active);--sinch-button-color-icon-disabled:var(--sinch-button-destructive-color-icon-disabled);--sinch-button-mix-blend-mode:var(--sinch-button-destructive-mix-blend-mode);--sinch-elevation-level:var(--sinch-elevation-level-1)}#button{all:initial;display:block;position:relative;width:100%;height:var(--sinch-size);font:var(--sinch-button-font);color:var(--sinch-button-color-text);cursor:pointer;--sinch-color-icon:var(--sinch-button-color-icon)}#button::before{content:"";position:absolute;inset:0;background-color:var(--sinch-button-color-background);border:1px solid var(--sinch-button-color-border);border-radius:var(--sinch-shape-radius);box-shadow:var(--sinch-elevation-level);pointer-events:none;mix-blend-mode:var(--sinch-button-mix-blend-mode)}#button:focus-visible::after{position:absolute;content:"";inset:-3px;border:2px solid var(--sinch-color-border-focus);border-radius:calc(var(--sinch-shape-radius) + 3px);pointer-events:none}#button:disabled{color:var(--sinch-button-color-text-disabled);cursor:initial;--sinch-color-icon:var(--sinch-button-color-icon-disabled)}#button:disabled::before{background-color:var(--sinch-button-color-background-disabled);border-color:var(--sinch-button-color-border-disabled);box-shadow:var(--sinch-elevation-level-0)}#button:enabled:hover{--sinch-color-icon:var(--sinch-button-color-icon-hover)}#button:enabled:hover::before{background-color:var(--sinch-button-color-background-hover);border-color:var(--sinch-button-color-border-hover)}#button:enabled:active{--sinch-color-icon:var(--sinch-button-color-icon-active)}#button:enabled:active::before{background-color:var(--sinch-button-color-background-active);border-color:var(--sinch-button-color-border-active);border-width:2px;box-shadow:var(--sinch-elevation-level-0)}#content{position:relative;display:flex;align-items:center;justify-content:center;gap:.75em;width:100%;height:100%;padding:0 1em;box-sizing:border-box;pointer-events:none}#text{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex-shrink:1;min-width:0}</style><button id="button"><div id="content"><slot name="left-icon"></slot><span id="text"></span><slot name="right-icon"></slot></div></button>';
|
|
4
|
-
import {
|
|
2
|
+
import { DEFAULT_SIZE, sizeValues } from '../utils/size';
|
|
3
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#button{all:initial;display:block;position:relative;width:100%;height:var(--sinch-local-size);cursor:pointer;--sinch-local-size:var(--sinch-comp-button-size-container-m);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-m);--sinch-local-font:var(--sinch-comp-button-font-size-m-text);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-m);--sinch-global-color-icon:var(--sinch-local-color-icon)}#button:disabled{cursor:initial}:host([data-size="l"])>#button{--sinch-local-size:var(--sinch-comp-button-size-container-l);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-l);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-l);--sinch-local-font:var(--sinch-comp-button-font-size-l-text)}:host([data-size="m"])>#button{--sinch-local-size:var(--sinch-comp-button-size-container-m);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-m);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-m);--sinch-local-font:var(--sinch-comp-button-font-size-m-text)}:host([data-size="s"])>#button{--sinch-local-size:var(--sinch-comp-button-size-container-s);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-s);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-s);--sinch-local-font:var(--sinch-comp-button-font-size-s-text)}:host([type=primary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-primary-default-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-primary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-primary-default-icon-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-primary-default-outilne-focus);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-initial)}:host([type=secondary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-secondary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-secondary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-secondary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-secondary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-initial)}:host([type=tertiary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-tertiary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-tertiary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-tertiary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-tertiary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-tertiary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-tertiary-initial)}:host([type=cta-primary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-primary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-cta-primary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-cta-primary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-cta-primary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-cta-primary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-initial)}:host([type=cta-secondary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-secondary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-cta-secondary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-cta-secondary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-cta-secondary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-cta-secondary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-initial)}:host([type=destructive])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-danger-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-danger-default-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-danger-default-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-danger-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-destructive-initial)}:host([type=primary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-focus)}:host([type=secondary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-focus)}:host([type=tertiary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-tertiary-focus)}:host([type=cta-primary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-focus)}:host([type=cta-secondary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-focus)}:host([type=destructive]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-destructive-focus)}:host([type=primary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-hover)}:host([type=primary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-active)}:host([type=secondary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-hover)}:host([type=secondary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-active)}:host([type=tertiary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-tertiary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-tertiary-hover)}:host([type=tertiary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-tertiary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-tertiary-active)}:host([type=cta-primary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-primary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-hover)}:host([type=cta-primary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-primary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-active)}:host([type=cta-secondary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-secondary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-hover)}:host([type=cta-secondary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-secondary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-active)}:host([type=destructive]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-danger-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-hover)}:host([type=destructive]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-danger-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-active)}:host([type=primary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-primary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-primary-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-primary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-disabled)}:host([type=secondary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-secondary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-secondary-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-secondary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-disabled)}:host([type=tertiary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-tertiary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-tertiary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-tertiary-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-tertiary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-tertiary-disabled)}:host([type=cta-primary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-primary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-cta-primary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-cta-primary-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-cta-primary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-disabled)}:host([type=cta-secondary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-secondary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-cta-secondary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-cta-secondary-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-cta-secondary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-disabled)}:host([type=destructive][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-danger-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-danger-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-danger-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-danger-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-disabled)}#button::before{content:"";position:absolute;inset:0;background-color:var(--sinch-local-color-background);border:1px solid var(--sinch-local-color-border);border-radius:var(--sinch-local-shape-radius);box-shadow:var(--sinch-local-shadow);pointer-events:none}:host(:not([disabled]):active) #button::before{border-width:2px}:host(:focus-visible) #button::after{position:absolute;content:"";inset:-3px;border:2px solid var(--sinch-local-color-outline-focus);border-radius:calc(var(--sinch-local-shape-radius) + 3px);pointer-events:none}#content{position:relative;display:flex;align-items:center;justify-content:center;gap:.75em;width:100%;height:100%;padding:0 1em;box-sizing:border-box;pointer-events:none}#text{font:var(--sinch-local-font);color:var(--sinch-local-color-text);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex-shrink:1;min-width:0}</style><div id="button" inert><div id="content"><slot name="left-icon"></slot><span id="text"></span><slot name="right-icon"></slot></div></div>';
|
|
4
|
+
import { typeValues } from './utils';
|
|
5
5
|
const template = document.createElement('template');
|
|
6
6
|
template.innerHTML = templateHTML;
|
|
7
7
|
defineCustomElement('sinch-button', class extends NectaryElement {
|
|
@@ -12,7 +12,7 @@ defineCustomElement('sinch-button', class extends NectaryElement {
|
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
14
|
const shadowRoot = this.attachShadow({
|
|
15
|
-
delegatesFocus:
|
|
15
|
+
delegatesFocus: false
|
|
16
16
|
});
|
|
17
17
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
18
18
|
this.#$button = shadowRoot.querySelector('#button');
|
|
@@ -25,14 +25,18 @@ defineCustomElement('sinch-button', class extends NectaryElement {
|
|
|
25
25
|
const {
|
|
26
26
|
signal
|
|
27
27
|
} = this.#controller;
|
|
28
|
-
this.
|
|
29
|
-
this
|
|
28
|
+
this.role = 'button';
|
|
29
|
+
this.tabIndex = 0;
|
|
30
|
+
this.addEventListener('click', this.#onButtonClick, {
|
|
30
31
|
signal
|
|
31
32
|
});
|
|
32
|
-
this
|
|
33
|
+
this.addEventListener('focus', this.#onButtonFocus, {
|
|
33
34
|
signal
|
|
34
35
|
});
|
|
35
|
-
this
|
|
36
|
+
this.addEventListener('blur', this.#onButtonBlur, {
|
|
37
|
+
signal
|
|
38
|
+
});
|
|
39
|
+
this.addEventListener('keydown', this.#onButtonKeydown, {
|
|
36
40
|
signal
|
|
37
41
|
});
|
|
38
42
|
this.addEventListener('-click', this.#onClickReactHandler, {
|
|
@@ -53,7 +57,7 @@ defineCustomElement('sinch-button', class extends NectaryElement {
|
|
|
53
57
|
this.#controller.abort();
|
|
54
58
|
}
|
|
55
59
|
static get observedAttributes() {
|
|
56
|
-
return ['text', 'disabled', 'size', '
|
|
60
|
+
return ['text', 'disabled', 'size', 'data-size'];
|
|
57
61
|
}
|
|
58
62
|
attributeChangedCallback(name, _, newVal) {
|
|
59
63
|
switch (name) {
|
|
@@ -65,17 +69,9 @@ defineCustomElement('sinch-button', class extends NectaryElement {
|
|
|
65
69
|
case 'disabled':
|
|
66
70
|
{
|
|
67
71
|
const isDisabled = isAttrTrue(newVal);
|
|
68
|
-
this.#$button.disabled = isDisabled;
|
|
69
72
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
70
73
|
break;
|
|
71
74
|
}
|
|
72
|
-
case 'type':
|
|
73
|
-
{
|
|
74
|
-
if ('production' !== 'production') {
|
|
75
|
-
assertType(newVal);
|
|
76
|
-
}
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
75
|
case 'size':
|
|
80
76
|
{
|
|
81
77
|
updateAttribute(this, 'data-size', newVal);
|
|
@@ -83,9 +79,6 @@ defineCustomElement('sinch-button', class extends NectaryElement {
|
|
|
83
79
|
}
|
|
84
80
|
case 'data-size':
|
|
85
81
|
{
|
|
86
|
-
if ('production' !== 'production') {
|
|
87
|
-
assertSize(newVal, 'sinch-button');
|
|
88
|
-
}
|
|
89
82
|
this.#onSizeUpdate();
|
|
90
83
|
break;
|
|
91
84
|
}
|
|
@@ -118,12 +111,6 @@ defineCustomElement('sinch-button', class extends NectaryElement {
|
|
|
118
111
|
get focusable() {
|
|
119
112
|
return true;
|
|
120
113
|
}
|
|
121
|
-
focus() {
|
|
122
|
-
this.#$button.focus();
|
|
123
|
-
}
|
|
124
|
-
blur() {
|
|
125
|
-
this.#$button.blur();
|
|
126
|
-
}
|
|
127
114
|
#onSizeUpdate() {
|
|
128
115
|
if (!this.isConnected) {
|
|
129
116
|
return;
|
|
@@ -147,8 +134,19 @@ defineCustomElement('sinch-button', class extends NectaryElement {
|
|
|
147
134
|
}
|
|
148
135
|
}
|
|
149
136
|
};
|
|
137
|
+
#onButtonKeydown = e => {
|
|
138
|
+
switch (e.code) {
|
|
139
|
+
case 'Space':
|
|
140
|
+
case 'Enter':
|
|
141
|
+
{
|
|
142
|
+
this.click();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
150
146
|
#onButtonClick = () => {
|
|
151
|
-
this.
|
|
147
|
+
if (!this.disabled) {
|
|
148
|
+
this.dispatchEvent(new CustomEvent('-click'));
|
|
149
|
+
}
|
|
152
150
|
};
|
|
153
151
|
#onButtonFocus = () => {
|
|
154
152
|
this.dispatchEvent(new CustomEvent('-focus'));
|
package/button/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { TSinchElementReact } from '../types';
|
|
|
2
2
|
import type { TSinchSize } from '../utils/size';
|
|
3
3
|
export type TSinchButtonType = 'primary' | 'secondary' | 'tertiary' | 'cta-primary' | 'cta-secondary' | 'destructive';
|
|
4
4
|
export type TSinchButtonElement = HTMLElement & {
|
|
5
|
-
/** Type
|
|
5
|
+
/** Button Type */
|
|
6
6
|
type: TSinchButtonType;
|
|
7
7
|
/** Size, `m` by default */
|
|
8
8
|
size: TSinchSize;
|
|
@@ -26,7 +26,7 @@ export type TSinchButtonElement = HTMLElement & {
|
|
|
26
26
|
setAttribute(attr: 'disabled', value: ''): void;
|
|
27
27
|
};
|
|
28
28
|
export type TSinchButtonReact = TSinchElementReact<TSinchButtonElement> & {
|
|
29
|
-
/** Type
|
|
29
|
+
/** Button Type */
|
|
30
30
|
type?: TSinchButtonType;
|
|
31
31
|
/** Size, `m` by default */
|
|
32
32
|
size?: TSinchSize;
|
package/button/utils.d.ts
CHANGED
package/button/utils.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export const typeValues = ['primary', 'secondary', 'tertiary', 'cta-primary', 'cta-secondary', 'destructive'];
|
|
2
|
-
export const assertType = value => {
|
|
3
|
-
if (value === null || value.length === 0) {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
if (!typeValues.includes(value)) {
|
|
7
|
-
throw new Error(`sinch-button: invalid type attribute: ${value}`);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
1
|
+
export const typeValues = ['primary', 'secondary', 'tertiary', 'cta-primary', 'cta-secondary', 'destructive'];
|
package/card/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../title';
|
|
2
2
|
import '../text';
|
|
3
|
-
import { defineCustomElement, getBooleanAttribute, getAttribute,
|
|
4
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{border-radius:var(--sinch-shape-radius
|
|
3
|
+
import { defineCustomElement, getBooleanAttribute, getAttribute, updateAttribute, setClass, NectaryElement, isAttrTrue, getRect } from '../utils';
|
|
4
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{border-radius:var(--sinch-comp-card-shape-radius);border:1px solid var(--sinch-comp-card-color-white-default-border-initial);background-color:var(--sinch-comp-card-color-white-default-background-initial);box-shadow:var(--sinch-comp-card-shadow-initial);overflow:hidden}:host(:hover) #wrapper{box-shadow:var(--sinch-comp-card-shadow-hover)}#card-body{padding:24px;box-sizing:border-box;display:flex;flex-direction:column;gap:16px}#illustration-wrapper{display:none;overflow:hidden;height:240px}#illustration-wrapper.active{display:block}#label{--sinch-comp-text-font:var(--sinch-comp-card-font-label);--sinch-global-color-text:var(--sinch-comp-card-color-white-default-text-title)}#label:empty{display:none}#header{display:flex;flex-direction:row;align-items:center;gap:8px;--sinch-global-size-icon:var(--sinch-comp-card-size-icon)}#caption{flex:1;min-width:0;--sinch-comp-title-font:var(--sinch-comp-card-font-title);--sinch-global-color-text:var(--sinch-comp-card-color-white-default-text-title)}#description{flex:1;min-height:0;max-height:120px;overflow-y:auto;--sinch-comp-text-font:var(--sinch-comp-card-font-description);--sinch-global-color-text:var(--sinch-comp-card-color-white-default-text-description)}#description:empty{display:none}slot[name=action]::slotted(*){margin-top:20px;align-self:flex-start;max-width:100%}:host([draggable=true]) #header{cursor:grab}</style><div id="wrapper"><div id="illustration-wrapper"><slot name="illustration"></slot></div><div id="card-body"><sinch-text id="label" type="s" emphasized ellipsis></sinch-text><div id="header"><slot name="icon"></slot><sinch-title id="caption" type="m" level="3" ellipsis></sinch-title></div><sinch-text id="description" type="m"></sinch-text><slot name="action"></slot></div></div>';
|
|
5
5
|
const template = document.createElement('template');
|
|
6
6
|
template.innerHTML = templateHTML;
|
|
7
7
|
defineCustomElement('sinch-card', class extends NectaryElement {
|
|
@@ -47,10 +47,10 @@ defineCustomElement('sinch-card', class extends NectaryElement {
|
|
|
47
47
|
this.#controller.abort();
|
|
48
48
|
}
|
|
49
49
|
static get observedAttributes() {
|
|
50
|
-
return ['text', 'label', 'caption', '
|
|
50
|
+
return ['text', 'label', 'caption', 'draggable'];
|
|
51
51
|
}
|
|
52
|
-
attributeChangedCallback(name,
|
|
53
|
-
if (
|
|
52
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
53
|
+
if (oldVal === newVal) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
switch (name) {
|
|
@@ -69,11 +69,6 @@ defineCustomElement('sinch-card', class extends NectaryElement {
|
|
|
69
69
|
updateAttribute(this.#$caption, 'text', newVal);
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
|
-
case 'disabled':
|
|
73
|
-
{
|
|
74
|
-
updateBooleanAttribute(this, 'disabled', isAttrTrue(newVal));
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
72
|
case 'draggable':
|
|
78
73
|
{
|
|
79
74
|
const isDraggingEnabled = isAttrTrue(newVal);
|
|
@@ -105,12 +100,6 @@ defineCustomElement('sinch-card', class extends NectaryElement {
|
|
|
105
100
|
get label() {
|
|
106
101
|
return getAttribute(this, 'label', '');
|
|
107
102
|
}
|
|
108
|
-
set disabled(isDisabled) {
|
|
109
|
-
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
110
|
-
}
|
|
111
|
-
get disabled() {
|
|
112
|
-
return getBooleanAttribute(this, 'disabled');
|
|
113
|
-
}
|
|
114
103
|
get dragRect() {
|
|
115
104
|
return this.#isDraggingSubscribed ? getRect(this.#$header) : null;
|
|
116
105
|
}
|
package/card/types.d.ts
CHANGED
|
@@ -6,8 +6,6 @@ export type TSinchCardElement = HTMLElement & {
|
|
|
6
6
|
caption: string;
|
|
7
7
|
/** Label */
|
|
8
8
|
label: string | null;
|
|
9
|
-
/** Disabled */
|
|
10
|
-
disabled: boolean;
|
|
11
9
|
readonly dragRect: TRect | null;
|
|
12
10
|
/** Text */
|
|
13
11
|
setAttribute(name: 'text', value: string): void;
|
|
@@ -15,8 +13,6 @@ export type TSinchCardElement = HTMLElement & {
|
|
|
15
13
|
setAttribute(name: 'caption', value: string): void;
|
|
16
14
|
/** Label */
|
|
17
15
|
setAttribute(name: 'label', value: string): void;
|
|
18
|
-
/** Disabled */
|
|
19
|
-
setAttribute(name: 'disabled', value: ''): void;
|
|
20
16
|
/** Draggable */
|
|
21
17
|
setAttribute(name: 'draggable', value: ''): void;
|
|
22
18
|
};
|
|
@@ -27,8 +23,6 @@ export type TSinchCardReact = TSinchElementReact<TSinchCardElement> & {
|
|
|
27
23
|
caption: string;
|
|
28
24
|
/** Label */
|
|
29
25
|
label?: string;
|
|
30
|
-
/** Disabled */
|
|
31
|
-
disabled?: boolean;
|
|
32
26
|
/** Draggable */
|
|
33
27
|
draggable?: boolean;
|
|
34
28
|
};
|
package/card-container/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, NectaryElement } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block}#wrapper{height:100%;padding:20px 0;box-sizing:border-box;background-color:var(--sinch-color-
|
|
2
|
+
const templateHTML = '<style>:host{display:block}#wrapper{height:100%;padding:20px 0;box-sizing:border-box;background-color:var(--sinch-comp-card-color-white-default-background-initial);border-radius:var(--sinch-comp-card-shape-radius);border:1px solid var(--sinch-comp-card-color-white-default-border-initial)}#scroll{overflow:auto;height:100%;box-sizing:border-box;padding:4px 24px}</style><div id="wrapper"><div id="scroll"><slot></slot></div></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-card-container', class extends NectaryElement {
|
package/chat-block/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { typeValues } from '../chat-bubble/utils';
|
|
2
2
|
import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
3
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:column;gap:4px;align-items:flex-end;padding-left:72px}#stamp{display:flex;gap:4px;margin:0;font:var(--sinch-font-
|
|
3
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:column;gap:4px;align-items:flex-end;padding-left:72px}#stamp{display:flex;gap:4px;margin:0;font:var(--sinch-sys-font-body-xs);color:var(--sinch-sys-color-text-default)}#avatar{display:none;position:absolute;left:0;top:24px}:host([type=customer])>#wrapper{align-items:flex-start}:host([type=customer]) #avatar{display:block}</style><div id="wrapper"><div id="avatar"><slot name="avatar"></slot></div><p id="stamp"><span id="firstname"></span><span id="lastname"></span>•<span id="time"></span></p><slot name="bubble"></slot></div>';
|
|
4
4
|
const template = document.createElement('template');
|
|
5
5
|
template.innerHTML = templateHTML;
|
|
6
6
|
defineCustomElement('sinch-chat-block', class extends NectaryElement {
|
package/chat-bubble/index.d.ts
CHANGED
package/chat-bubble/index.js
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
import '../
|
|
2
|
-
|
|
3
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;padding:12px 16px;border-radius:16px;max-width:595px;box-sizing:border-box}:host([data-type=customer])>#wrapper{background-color:var(--sinch-color-snow-500);border-top-left-radius:0}:host([data-type=agent-prev])>#wrapper{background-color:var(--sinch-color-snow-700);border-top-right-radius:0}:host([data-type=agent])>#wrapper{background-color:var(--sinch-color-honey-200);border-top-right-radius:0}#text{font:var(--sinch-font-text-m);color:var(--sinch-color-stormy-500)}#icon{display:none;position:absolute;right:16px;bottom:12px;--sinch-size-icon:16px;--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-icon-font-variation-settings:var(--sinch-chat-icon-font-variation-settings)}:host([status=error]) #icon,:host([status=received]) #icon,:host([status=seen]) #icon,:host([status=sending]) #icon,:host([status=sent]) #icon{display:block}:host([status=seen]) #icon{--sinch-color-icon:var(--sinch-color-feedback-success-icon)}:host([status=error]) #icon{--sinch-color-icon:var(--sinch-color-feedback-invalid-icon)}:host([status]:not([status=""])) #wrapper{padding-right:42px}</style><div id="wrapper"><span id="text"></span><sinch-icon id="icon"></sinch-icon></div>';
|
|
1
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;padding:12px 16px;border-radius:16px;max-width:595px;box-sizing:border-box}:host([data-type=customer])>#wrapper{background-color:var(--sinch-sys-color-container-contrast-primary-default);border-top-left-radius:0}:host([data-type=agent-prev])>#wrapper{background-color:var(--sinch-sys-color-container-contrast-primary-active);border-top-right-radius:0}:host([data-type=agent])>#wrapper{background-color:var(--sinch-sys-color-container-complement-primary-hover);border-top-right-radius:0}#text{--sinch-global-color-text:var(--sinch-sys-color-text-default)}#icon-error,#icon-received,#icon-seen,#icon-sending,#icon-sent{display:none;position:absolute;right:16px;bottom:12px;height:16px}#icon-sending{fill:var(--sinch-sys-color-text-default)}#icon-sent{fill:var(--sinch-sys-color-text-default)}#icon-received{fill:var(--sinch-sys-color-text-default)}#icon-seen{fill:var(--sinch-sys-color-feedback-success-contrast)}#icon-error{fill:var(--sinch-sys-color-feedback-invalid-contrast)}:host([status=error]) #icon-error,:host([status=received]) #icon-received,:host([status=seen]) #icon-seen,:host([status=sending]) #icon-sending,:host([status=sent]) #icon-sent{display:block}:host([status]:not([status=""])) #wrapper{padding-right:42px}</style><div id="wrapper"><sinch-text id="text" type="m"></sinch-text><svg id="icon-sending" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2ZM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8Zm-.22-13h-.06c-.4 0-.72.32-.72.72v4.72c0 .35.18.68.49.86l4.15 2.49c.34.2.78.1.98-.24a.71.71 0 0 0-.25-.99l-3.87-2.3V7.72c0-.4-.32-.72-.72-.72Z"/></svg><svg id="icon-sent" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M9 16.17 5.53 12.7a.996.996 0 1 0-1.41 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L20.29 7.71a.996.996 0 1 0-1.41-1.41L9 16.17Z"/></svg><svg id="icon-received" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M17.3 6.3a.996.996 0 0 0-1.41 0l-5.64 5.64 1.41 1.41L17.3 7.7c.38-.38.38-1.02 0-1.4Zm4.24-.01-9.88 9.88-3.48-3.47a.996.996 0 1 0-1.41 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L22.95 7.71a.996.996 0 0 0 0-1.41h-.01a.975.975 0 0 0-1.4-.01ZM1.12 14.12 5.3 18.3c.39.39 1.02.39 1.41 0l.7-.7-4.88-4.9a.996.996 0 0 0-1.41 0c-.39.39-.39 1.03 0 1.42Z"/></svg><svg id="icon-seen" id="icon-received" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M17.3 6.3a.996.996 0 0 0-1.41 0l-5.64 5.64 1.41 1.41L17.3 7.7c.38-.38.38-1.02 0-1.4Zm4.24-.01-9.88 9.88-3.48-3.47a.996.996 0 1 0-1.41 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L22.95 7.71a.996.996 0 0 0 0-1.41h-.01a.975.975 0 0 0-1.4-.01ZM1.12 14.12 5.3 18.3c.39.39 1.02.39 1.41 0l.7-.7-4.88-4.9a.996.996 0 0 0-1.41 0c-.39.39-.39 1.03 0 1.42Z"/></svg><svg id="icon-error" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 7c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1s-1-.45-1-1V8c0-.55.45-1 1-1Zm-.01-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2ZM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8Zm1-3h-2v-2h2v2Z"/></svg></div>';
|
|
4
3
|
import { statusValues, typeValues } from './utils';
|
|
5
4
|
const template = document.createElement('template');
|
|
6
5
|
template.innerHTML = templateHTML;
|
|
7
6
|
defineCustomElement('sinch-chat-bubble', class extends NectaryElement {
|
|
8
7
|
#$text;
|
|
9
|
-
#$icon;
|
|
10
8
|
constructor() {
|
|
11
9
|
super();
|
|
12
10
|
const shadowRoot = this.attachShadow();
|
|
13
11
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
14
12
|
this.#$text = shadowRoot.querySelector('#text');
|
|
15
|
-
this.#$icon = shadowRoot.querySelector('#icon');
|
|
16
|
-
}
|
|
17
|
-
connectedCallback() {
|
|
18
|
-
super.connectedCallback();
|
|
19
|
-
this.#updateIcon();
|
|
20
|
-
}
|
|
21
|
-
disconnectedCallback() {
|
|
22
|
-
super.disconnectedCallback();
|
|
23
13
|
}
|
|
24
14
|
static get observedAttributes() {
|
|
25
|
-
return ['text'
|
|
15
|
+
return ['text'];
|
|
26
16
|
}
|
|
27
17
|
attributeChangedCallback(name, _, newVal) {
|
|
28
18
|
switch (name) {
|
|
@@ -31,11 +21,6 @@ defineCustomElement('sinch-chat-bubble', class extends NectaryElement {
|
|
|
31
21
|
this.#$text.textContent = newVal;
|
|
32
22
|
break;
|
|
33
23
|
}
|
|
34
|
-
case 'status':
|
|
35
|
-
{
|
|
36
|
-
this.#updateIcon();
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
24
|
}
|
|
40
25
|
}
|
|
41
26
|
set text(value) {
|
|
@@ -53,11 +38,4 @@ defineCustomElement('sinch-chat-bubble', class extends NectaryElement {
|
|
|
53
38
|
get status() {
|
|
54
39
|
return getLiteralAttribute(this, statusValues, 'status', null);
|
|
55
40
|
}
|
|
56
|
-
#updateIcon() {
|
|
57
|
-
if (!this.isConnected) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const status = this.status;
|
|
61
|
-
updateAttribute(this.#$icon, 'name', status !== null ? getCssVar(this, `--sinch-chat-icon-${status}`) : null);
|
|
62
|
-
}
|
|
63
41
|
});
|
package/checkbox/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{
|
|
2
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;--sinch-local-size:24px;--sinch-local-color-background:var(--sinch-comp-checkbox-color-default-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-checkbox-color-default-background-hover);--sinch-local-color-background-active:var(--sinch-comp-checkbox-color-default-background-active);--sinch-local-color-border:var(--sinch-comp-checkbox-color-default-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-checkbox-color-default-border-hover);--sinch-local-color-border-active:var(--sinch-comp-checkbox-color-default-border-active);--sinch-local-color-text:var(--sinch-comp-checkbox-color-default-text-initial)}:host([invalid])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-invalid-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-checkbox-color-invalid-background-hover);--sinch-local-color-background-active:var(--sinch-comp-checkbox-color-invalid-background-active);--sinch-local-color-border:var(--sinch-comp-checkbox-color-invalid-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-checkbox-color-invalid-border-hover);--sinch-local-color-border-active:var(--sinch-comp-checkbox-color-invalid-border-active);--sinch-local-color-text:var(--sinch-comp-checkbox-color-invalid-text-initial)}:host([checked])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-checked-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-checkbox-color-checked-background-hover);--sinch-local-color-background-active:var(--sinch-comp-checkbox-color-checked-background-active);--sinch-local-color-border:var(--sinch-comp-checkbox-color-checked-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-checkbox-color-checked-border-hover);--sinch-local-color-border-active:var(--sinch-comp-checkbox-color-checked-border-active)}:host([disabled])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-checkbox-color-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-checkbox-color-disabled-text-initial)}:host([disabled][checked])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-checked-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-checkbox-color-checked-disabled-border-initial)}#checkbox{all:initial;display:block;width:var(--sinch-local-size);height:var(--sinch-local-size);cursor:pointer}#checkbox:disabled{cursor:initial}#icon-container{position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);align-self:flex-start}#checkbox::before{content:"";position:absolute;top:0;left:0;width:var(--sinch-local-size);height:var(--sinch-local-size);border:2px solid var(--sinch-comp-checkbox-color-default-outline-focus);border-radius:calc(var(--sinch-comp-checkbox-shape-radius) + 3px);transition:opacity .1s linear;opacity:0;box-sizing:border-box;pointer-events:none}#checkbox:focus-visible::before{opacity:1}#checkbox::after{content:"";position:absolute;width:18px;height:18px;inset:0;margin:auto;background-color:var(--sinch-local-color-background);border:1px solid var(--sinch-local-color-border);border-radius:var(--sinch-comp-checkbox-shape-radius);transition:background-color .1s linear;box-sizing:border-box;pointer-events:none}#checkbox:enabled:hover::after{background-color:var(--sinch-local-color-background-hover);border-color:var(--sinch-local-color-border-hover)}#checkbox:enabled:active::after{background-color:var(--sinch-local-color-background-active);border-color:var(--sinch-local-color-border-active)}#icon-checkmark,#icon-indeterminate{position:absolute;left:4px;top:4px;width:16px;height:16px;transition:opacity .1s linear;opacity:0;pointer-events:none;fill:var(--sinch-sys-color-container-main-default)}@media (prefers-reduced-motion){#checkbox::after,#checkbox::before,#icon-checkmark,#icon-indeterminate{transition:none}}#label{display:none;flex:1;align-self:center;padding-left:7px;font:var(--sinch-comp-checkbox-font-label);color:var(--sinch-local-color-text);cursor:pointer}:host([disabled]) #label{cursor:initial}:host([text]:not([text=""])) #label{display:block}:host(:not([indeterminate])) #checkbox:checked~#icon-checkmark{opacity:1}:host([indeterminate]) #checkbox:checked~#icon-indeterminate{opacity:1}</style><div id="wrapper"><div id="icon-container"><input id="checkbox" type="checkbox"/><svg id="icon-checkmark" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 16.17 5.53 12.7a.996.996 0 1 0-1.41 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L20.29 7.71a.996.996 0 1 0-1.41-1.41L9 16.17Z"/></svg><svg id="icon-indeterminate" viewBox="0 0 24 24" aria-hidden="true"><path d="M18 13H6c-.55 0-1-.45-1-1s.45-1 1-1h12c.55 0 1 .45 1 1s-.45 1-1 1Z"/></svg></div><label for="checkbox" id="label"></label></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-checkbox', class extends NectaryElement {
|
|
@@ -7,9 +7,7 @@ defineCustomElement('sinch-checkbox', class extends NectaryElement {
|
|
|
7
7
|
#$label;
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
|
-
const shadowRoot = this.attachShadow(
|
|
11
|
-
delegatesFocus: true
|
|
12
|
-
});
|
|
10
|
+
const shadowRoot = this.attachShadow();
|
|
13
11
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
14
12
|
this.#$input = shadowRoot.querySelector('input');
|
|
15
13
|
this.#$label = shadowRoot.querySelector('label');
|
|
@@ -32,13 +30,37 @@ defineCustomElement('sinch-checkbox', class extends NectaryElement {
|
|
|
32
30
|
this.removeEventListener('-blur', this.#onBlurReactHandler);
|
|
33
31
|
}
|
|
34
32
|
static get observedAttributes() {
|
|
35
|
-
return ['checked', 'disabled', 'text'];
|
|
33
|
+
return ['checked', 'disabled', 'text', 'invalid', 'indeterminate'];
|
|
36
34
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
attributeChangedCallback(name, _, newVal) {
|
|
36
|
+
switch (name) {
|
|
37
|
+
case 'text':
|
|
38
|
+
{
|
|
39
|
+
this.#$label.textContent = newVal;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case 'checked':
|
|
43
|
+
{
|
|
44
|
+
const isChecked = isAttrTrue(newVal);
|
|
45
|
+
this.#$input.checked = isChecked;
|
|
46
|
+
updateExplicitBooleanAttribute(this, 'aria-checked', isChecked);
|
|
47
|
+
updateBooleanAttribute(this, 'checked', isChecked);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case 'disabled':
|
|
51
|
+
{
|
|
52
|
+
const isDisabled = isAttrTrue(newVal);
|
|
53
|
+
this.#$input.disabled = isDisabled;
|
|
54
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case 'invalid':
|
|
58
|
+
case 'indeterminate':
|
|
59
|
+
{
|
|
60
|
+
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
42
64
|
}
|
|
43
65
|
set checked(isChecked) {
|
|
44
66
|
updateBooleanAttribute(this, 'checked', isChecked);
|
|
@@ -70,29 +92,6 @@ defineCustomElement('sinch-checkbox', class extends NectaryElement {
|
|
|
70
92
|
get text() {
|
|
71
93
|
return getAttribute(this, 'text');
|
|
72
94
|
}
|
|
73
|
-
attributeChangedCallback(name, _, newVal) {
|
|
74
|
-
switch (name) {
|
|
75
|
-
case 'text':
|
|
76
|
-
{
|
|
77
|
-
this.#$label.textContent = newVal;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
case 'checked':
|
|
81
|
-
{
|
|
82
|
-
const isChecked = isAttrTrue(newVal);
|
|
83
|
-
this.#$input.checked = isChecked;
|
|
84
|
-
updateExplicitBooleanAttribute(this, 'aria-checked', isChecked);
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
case 'disabled':
|
|
88
|
-
{
|
|
89
|
-
const isDisabled = isAttrTrue(newVal);
|
|
90
|
-
this.#$input.disabled = isDisabled;
|
|
91
|
-
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
95
|
get focusable() {
|
|
97
96
|
return true;
|
|
98
97
|
}
|
package/checkbox/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
import type { SyntheticEvent } from 'react';
|
|
3
2
|
export type TSinchCheckboxElement = HTMLElement & {
|
|
4
3
|
/** Value */
|
|
5
4
|
checked: boolean;
|
|
@@ -41,8 +40,6 @@ export type TSinchCheckboxReact = TSinchElementReact<TSinchCheckboxElement> & {
|
|
|
41
40
|
text?: string;
|
|
42
41
|
/** Label that is used for a11y – might be different from `label` */
|
|
43
42
|
'aria-label': string;
|
|
44
|
-
/** @deprecated */
|
|
45
|
-
onChange?: (event: SyntheticEvent<TSinchCheckboxElement, CustomEvent<boolean>>) => void;
|
|
46
43
|
/** Change value handler */
|
|
47
44
|
'on-change'?: (e: CustomEvent<boolean>) => void;
|
|
48
45
|
/** Focus handler */
|