kemet-ui 3.0.0 → 3.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/custom-elements.json +1588 -871
- package/dist/components/kemet-accordion/docs/stories.d.ts +12 -0
- package/dist/components/kemet-accordion/docs/stories.js +99 -0
- package/dist/components/kemet-accordion/docs/stories.js.map +1 -0
- package/dist/components/kemet-accordion/kemet-accordion-panel.d.ts +2 -2
- package/dist/components/kemet-accordion/kemet-accordion-panel.js +1 -1
- package/dist/components/kemet-accordion/kemet-accordion-panel.js.map +1 -1
- package/dist/components/kemet-accordion/kemet-accordion.d.ts +3 -3
- package/dist/components/kemet-accordion/kemet-accordion.js +2 -1
- package/dist/components/kemet-accordion/kemet-accordion.js.map +1 -1
- package/dist/components/kemet-accordion/spec.d.ts +2 -0
- package/dist/components/kemet-accordion/spec.js +132 -0
- package/dist/components/kemet-accordion/spec.js.map +1 -0
- package/dist/components/kemet-alert/docs/stories.d.ts +1 -1
- package/dist/components/kemet-alert/docs/stories.js +20 -19
- package/dist/components/kemet-alert/docs/stories.js.map +1 -1
- package/dist/components/kemet-alert/kemet-alert.d.ts +2 -2
- package/dist/components/kemet-alert/kemet-alert.js.map +1 -1
- package/dist/components/kemet-alert/spec.d.ts +1 -0
- package/dist/components/kemet-alert/spec.js +35 -0
- package/dist/components/kemet-alert/spec.js.map +1 -0
- package/dist/components/kemet-alert/types.d.ts +1 -1
- package/dist/components/kemet-avatar/docs/stories.d.ts +1 -1
- package/dist/components/kemet-avatar/docs/stories.js.map +1 -1
- package/dist/components/kemet-avatar/kemet-avatar.js.map +1 -1
- package/dist/components/kemet-avatar/kemet-avatars.js.map +1 -1
- package/dist/components/kemet-avatar/spec.d.ts +1 -0
- package/dist/components/kemet-avatar/spec.js +26 -0
- package/dist/components/kemet-avatar/spec.js.map +1 -0
- package/dist/components/kemet-badge/docs/stories.d.ts +1 -1
- package/dist/components/kemet-badge/kemet-badge.js.map +1 -1
- package/dist/components/kemet-badge/spec.d.ts +1 -0
- package/dist/components/kemet-badge/spec.js +21 -0
- package/dist/components/kemet-badge/spec.js.map +1 -0
- package/dist/components/kemet-badge/types.d.ts +1 -1
- package/dist/components/kemet-button/docs/stories.d.ts +1 -1
- package/dist/components/kemet-button/kemet-button.d.ts +2 -2
- package/dist/components/kemet-button/kemet-button.js +10 -8
- package/dist/components/kemet-button/kemet-button.js.map +1 -1
- package/dist/components/kemet-button/spec.d.ts +1 -0
- package/dist/components/kemet-button/spec.js +49 -0
- package/dist/components/kemet-button/spec.js.map +1 -0
- package/dist/components/kemet-button/types.d.ts +1 -1
- package/dist/components/kemet-card/docs/stories.d.ts +1 -1
- package/dist/components/kemet-card/docs/stories.js.map +1 -1
- package/dist/components/kemet-card/kemet-card.d.ts +1 -1
- package/dist/components/kemet-card/kemet-card.js +1 -1
- package/dist/components/kemet-card/kemet-card.js.map +1 -1
- package/dist/components/kemet-card/spec.d.ts +1 -0
- package/dist/components/kemet-card/spec.js +31 -0
- package/dist/components/kemet-card/spec.js.map +1 -0
- package/dist/components/kemet-carousel/docs/stories.d.ts +1 -1
- package/dist/components/kemet-carousel/docs/stories.js.map +1 -1
- package/dist/components/kemet-carousel/kemet-carousel-current.d.ts +1 -1
- package/dist/components/kemet-carousel/kemet-carousel-current.js.map +1 -1
- package/dist/components/kemet-carousel/kemet-carousel-first.d.ts +1 -0
- package/dist/components/kemet-carousel/kemet-carousel-first.js +11 -4
- package/dist/components/kemet-carousel/kemet-carousel-first.js.map +1 -1
- package/dist/components/kemet-carousel/kemet-carousel-last.d.ts +2 -1
- package/dist/components/kemet-carousel/kemet-carousel-last.js +12 -5
- package/dist/components/kemet-carousel/kemet-carousel-last.js.map +1 -1
- package/dist/components/kemet-carousel/kemet-carousel-link.d.ts +1 -0
- package/dist/components/kemet-carousel/kemet-carousel-link.js +14 -4
- package/dist/components/kemet-carousel/kemet-carousel-link.js.map +1 -1
- package/dist/components/kemet-carousel/kemet-carousel-next.d.ts +1 -0
- package/dist/components/kemet-carousel/kemet-carousel-next.js +11 -4
- package/dist/components/kemet-carousel/kemet-carousel-next.js.map +1 -1
- package/dist/components/kemet-carousel/kemet-carousel-prev.d.ts +1 -0
- package/dist/components/kemet-carousel/kemet-carousel-prev.js +11 -4
- package/dist/components/kemet-carousel/kemet-carousel-prev.js.map +1 -1
- package/dist/components/kemet-carousel/kemet-carousel-slide.js +5 -5
- package/dist/components/kemet-carousel/kemet-carousel-slide.js.map +1 -1
- package/dist/components/kemet-carousel/kemet-carousel-total.js.map +1 -1
- package/dist/components/kemet-carousel/kemet-carousel.d.ts +18 -14
- package/dist/components/kemet-carousel/kemet-carousel.js +32 -13
- package/dist/components/kemet-carousel/kemet-carousel.js.map +1 -1
- package/dist/components/kemet-carousel/spec.d.ts +10 -0
- package/dist/components/kemet-carousel/spec.js +168 -0
- package/dist/components/kemet-carousel/spec.js.map +1 -0
- package/dist/components/kemet-checkbox/docs/stories.d.ts +1 -1
- package/dist/components/kemet-checkbox/kemet-checkbox.d.ts +4 -4
- package/dist/components/kemet-checkbox/kemet-checkbox.js +4 -4
- package/dist/components/kemet-checkbox/kemet-checkbox.js.map +1 -1
- package/dist/components/kemet-checkbox/spec.d.ts +1 -0
- package/dist/components/kemet-checkbox/spec.js +33 -0
- package/dist/components/kemet-checkbox/spec.js.map +1 -0
- package/dist/components/kemet-checkbox/types.d.ts +1 -1
- package/dist/components/kemet-combo/docs/stories.d.ts +1 -1
- package/dist/components/kemet-combo/kemet-combo.d.ts +9 -8
- package/dist/components/kemet-combo/kemet-combo.js +18 -17
- package/dist/components/kemet-combo/kemet-combo.js.map +1 -1
- package/dist/components/kemet-combo/spec.d.ts +3 -0
- package/dist/components/kemet-combo/spec.js +46 -0
- package/dist/components/kemet-combo/spec.js.map +1 -0
- package/dist/components/kemet-count/docs/stories.d.ts +1 -1
- package/dist/components/kemet-count/kemet-count.d.ts +1 -1
- package/dist/components/kemet-count/kemet-count.js +1 -1
- package/dist/components/kemet-count/kemet-count.js.map +1 -1
- package/dist/components/kemet-count/spec.d.ts +4 -0
- package/dist/components/kemet-count/spec.js +45 -0
- package/dist/components/kemet-count/spec.js.map +1 -0
- package/dist/components/kemet-draggable/docs/stories.d.ts +1 -1
- package/dist/components/kemet-draggable/kemet-draggable.d.ts +3 -3
- package/dist/components/kemet-draggable/kemet-draggable.js +6 -5
- package/dist/components/kemet-draggable/kemet-draggable.js.map +1 -1
- package/dist/components/kemet-draggable/spec.d.ts +1 -0
- package/dist/components/kemet-draggable/spec.js +30 -0
- package/dist/components/kemet-draggable/spec.js.map +1 -0
- package/dist/components/kemet-drawer/docs/stories.d.ts +1 -1
- package/dist/components/kemet-drawer/kemet-drawer.d.ts +2 -2
- package/dist/components/kemet-drawer/kemet-drawer.js +2 -2
- package/dist/components/kemet-drawer/kemet-drawer.js.map +1 -1
- package/dist/components/kemet-drawer/spec.d.ts +1 -0
- package/dist/components/kemet-drawer/spec.js +21 -0
- package/dist/components/kemet-drawer/spec.js.map +1 -0
- package/dist/components/kemet-drawer/styles.js +1 -0
- package/dist/components/kemet-drawer/styles.js.map +1 -1
- package/dist/components/kemet-drawer/types.d.ts +2 -2
- package/dist/components/kemet-fab/docs/stories.d.ts +1 -1
- package/dist/components/kemet-fab/kemet-fab.d.ts +1 -1
- package/dist/components/kemet-fab/kemet-fab.js +4 -10
- package/dist/components/kemet-fab/kemet-fab.js.map +1 -1
- package/dist/components/kemet-fab/spec.d.ts +2 -0
- package/dist/components/kemet-fab/spec.js +43 -0
- package/dist/components/kemet-fab/spec.js.map +1 -0
- package/dist/components/kemet-field/docs/stories.d.ts +1 -1
- package/dist/components/kemet-field/kemet-field.d.ts +7 -7
- package/dist/components/kemet-field/kemet-field.js +9 -14
- package/dist/components/kemet-field/kemet-field.js.map +1 -1
- package/dist/components/kemet-field/spec.d.ts +2 -0
- package/dist/components/kemet-field/spec.js +38 -0
- package/dist/components/kemet-field/spec.js.map +1 -0
- package/dist/components/kemet-field/types.d.ts +1 -1
- package/dist/components/kemet-flipcard/docs/stories.d.ts +1 -1
- package/dist/components/kemet-flipcard/kemet-flipcard-trigger.d.ts +1 -1
- package/dist/components/kemet-flipcard/kemet-flipcard-trigger.js +2 -3
- package/dist/components/kemet-flipcard/kemet-flipcard-trigger.js.map +1 -1
- package/dist/components/kemet-flipcard/kemet-flipcard.d.ts +2 -2
- package/dist/components/kemet-flipcard/kemet-flipcard.js +3 -5
- package/dist/components/kemet-flipcard/kemet-flipcard.js.map +1 -1
- package/dist/components/kemet-flipcard/spec.d.ts +3 -0
- package/dist/components/kemet-flipcard/spec.js +38 -0
- package/dist/components/kemet-flipcard/spec.js.map +1 -0
- package/dist/components/kemet-icon/docs/stories.d.ts +1 -1
- package/dist/components/kemet-icon/kemet-icon.js +1 -1
- package/dist/components/kemet-icon/kemet-icon.js.map +1 -1
- package/dist/components/kemet-icon/spec.d.ts +1 -0
- package/dist/components/kemet-icon/spec.js +69 -0
- package/dist/components/kemet-icon/spec.js.map +1 -0
- package/dist/components/kemet-input/docs/stories.d.ts +1 -1
- package/dist/components/kemet-input/kemet-input.d.ts +3 -22
- package/dist/components/kemet-input/kemet-input.js +3 -23
- package/dist/components/kemet-input/kemet-input.js.map +1 -1
- package/dist/components/kemet-input/spec.d.ts +1 -0
- package/dist/components/kemet-input/spec.js +83 -0
- package/dist/components/kemet-input/spec.js.map +1 -0
- package/dist/components/kemet-input/types.d.ts +3 -3
- package/dist/components/kemet-modal/docs/stories.d.ts +1 -1
- package/dist/components/kemet-modal/docs/stories.js.map +1 -1
- package/dist/components/kemet-modal/kemet-modal-close.js.map +1 -1
- package/dist/components/kemet-modal/kemet-modal.d.ts +4 -4
- package/dist/components/kemet-modal/kemet-modal.js +3 -3
- package/dist/components/kemet-modal/kemet-modal.js.map +1 -1
- package/dist/components/kemet-modal/types.d.ts +1 -1
- package/dist/components/kemet-multi-input/docs/stories.d.ts +8 -0
- package/dist/components/kemet-multi-input/docs/stories.js +33 -0
- package/dist/components/kemet-multi-input/docs/stories.js.map +1 -0
- package/dist/components/kemet-multi-input/kemet-multi-input.d.ts +116 -0
- package/dist/components/kemet-multi-input/kemet-multi-input.js +193 -0
- package/dist/components/kemet-multi-input/kemet-multi-input.js.map +1 -0
- package/dist/components/kemet-multi-input/styles.d.ts +1 -0
- package/dist/components/kemet-multi-input/styles.js +87 -0
- package/dist/components/kemet-multi-input/styles.js.map +1 -0
- package/dist/components/kemet-multi-input/types.d.ts +5 -0
- package/dist/components/kemet-multi-input/types.js +2 -0
- package/dist/components/kemet-multi-input/types.js.map +1 -0
- package/dist/components/kemet-password/docs/stories.d.ts +1 -1
- package/dist/components/kemet-password/kemet-password.d.ts +14 -8
- package/dist/components/kemet-password/kemet-password.js +4 -33
- package/dist/components/kemet-password/kemet-password.js.map +1 -1
- package/dist/components/kemet-password/types.d.ts +1 -1
- package/dist/components/kemet-popper/docs/stories.d.ts +1 -1
- package/dist/components/kemet-popper/kemet-popper-close.d.ts +1 -1
- package/dist/components/kemet-popper/kemet-popper-close.js +2 -3
- package/dist/components/kemet-popper/kemet-popper-close.js.map +1 -1
- package/dist/components/kemet-popper/kemet-popper.d.ts +18 -7
- package/dist/components/kemet-popper/kemet-popper.js +21 -25
- package/dist/components/kemet-popper/kemet-popper.js.map +1 -1
- package/dist/components/kemet-popper/types.d.ts +3 -3
- package/dist/components/kemet-radio/docs/stories.d.ts +1 -1
- package/dist/components/kemet-radio/kemet-radio.js.map +1 -1
- package/dist/components/kemet-radio/kemet-radios.d.ts +5 -4
- package/dist/components/kemet-radio/kemet-radios.js +10 -4
- package/dist/components/kemet-radio/kemet-radios.js.map +1 -1
- package/dist/components/kemet-radio/spec.d.ts +3 -0
- package/dist/components/kemet-radio/spec.js +67 -0
- package/dist/components/kemet-radio/spec.js.map +1 -0
- package/dist/components/kemet-radio/types.d.ts +2 -2
- package/dist/components/kemet-rotator/docs/stories.d.ts +1 -1
- package/dist/components/kemet-rotator/kemet-rotator.d.ts +1 -1
- package/dist/components/kemet-rotator/kemet-rotator.js +1 -2
- package/dist/components/kemet-rotator/kemet-rotator.js.map +1 -1
- package/dist/components/kemet-rotator/types.d.ts +1 -1
- package/dist/components/kemet-scroll-link/docs/stories.d.ts +1 -1
- package/dist/components/kemet-scroll-link/kemet-scroll-link.d.ts +2 -2
- package/dist/components/kemet-scroll-link/kemet-scroll-link.js +11 -10
- package/dist/components/kemet-scroll-link/kemet-scroll-link.js.map +1 -1
- package/dist/components/kemet-scroll-nav/docs/stories.d.ts +1 -1
- package/dist/components/kemet-scroll-nav/kemet-scroll-nav.d.ts +2 -2
- package/dist/components/kemet-scroll-nav/kemet-scroll-nav.js +2 -7
- package/dist/components/kemet-scroll-nav/kemet-scroll-nav.js.map +1 -1
- package/dist/components/kemet-scroll-nav/types.d.ts +1 -1
- package/dist/components/kemet-scroll-snap/docs/stories.d.ts +1 -1
- package/dist/components/kemet-scroll-snap/docs/stories.js.map +1 -1
- package/dist/components/kemet-scroll-snap/kemet-scroll-snap-paginator.d.ts +5 -4
- package/dist/components/kemet-scroll-snap/kemet-scroll-snap-paginator.js +1 -1
- package/dist/components/kemet-scroll-snap/kemet-scroll-snap-paginator.js.map +1 -1
- package/dist/components/kemet-scroll-snap/kemet-scroll-snap-slide.d.ts +1 -1
- package/dist/components/kemet-scroll-snap/kemet-scroll-snap-slide.js +1 -1
- package/dist/components/kemet-scroll-snap/kemet-scroll-snap-slide.js.map +1 -1
- package/dist/components/kemet-scroll-snap/kemet-scroll-snap.d.ts +3 -2
- package/dist/components/kemet-scroll-snap/kemet-scroll-snap.js +2 -7
- package/dist/components/kemet-scroll-snap/kemet-scroll-snap.js.map +1 -1
- package/dist/components/kemet-scroll-snap/types.d.ts +2 -2
- package/dist/components/kemet-select/docs/stories.d.ts +1 -1
- package/dist/components/kemet-select/kemet-option.d.ts +1 -1
- package/dist/components/kemet-select/kemet-option.js +1 -1
- package/dist/components/kemet-select/kemet-option.js.map +1 -1
- package/dist/components/kemet-select/kemet-select.d.ts +19 -10
- package/dist/components/kemet-select/kemet-select.js +3 -44
- package/dist/components/kemet-select/kemet-select.js.map +1 -1
- package/dist/components/kemet-select/spec.d.ts +3 -0
- package/dist/components/kemet-select/spec.js +53 -0
- package/dist/components/kemet-select/spec.js.map +1 -0
- package/dist/components/kemet-sortable/docs/stories.d.ts +1 -1
- package/dist/components/kemet-sortable/docs/stories.js.map +1 -1
- package/dist/components/kemet-sortable/kemet-sortable-item.js.map +1 -1
- package/dist/components/kemet-sortable/kemet-sortable.d.ts +5 -5
- package/dist/components/kemet-sortable/kemet-sortable.js +5 -5
- package/dist/components/kemet-sortable/kemet-sortable.js.map +1 -1
- package/dist/components/kemet-svgs/docs/stories.d.ts +1 -1
- package/dist/components/kemet-svgs/docs/stories.js.map +1 -1
- package/dist/components/kemet-svgs/kemet-svg.js.map +1 -1
- package/dist/components/kemet-svgs/kemet-svgs.d.ts +1 -1
- package/dist/components/kemet-svgs/kemet-svgs.js +1 -1
- package/dist/components/kemet-svgs/kemet-svgs.js.map +1 -1
- package/dist/components/kemet-tabs/docs/stories.d.ts +1 -1
- package/dist/components/kemet-tabs/docs/stories.js.map +1 -1
- package/dist/components/kemet-tabs/kemet-tab-panel.d.ts +1 -0
- package/dist/components/kemet-tabs/kemet-tab-panel.js +3 -0
- package/dist/components/kemet-tabs/kemet-tab-panel.js.map +1 -1
- package/dist/components/kemet-tabs/kemet-tab.d.ts +1 -0
- package/dist/components/kemet-tabs/kemet-tab.js +4 -1
- package/dist/components/kemet-tabs/kemet-tab.js.map +1 -1
- package/dist/components/kemet-tabs/kemet-tabs.d.ts +23 -14
- package/dist/components/kemet-tabs/kemet-tabs.js +3 -47
- package/dist/components/kemet-tabs/kemet-tabs.js.map +1 -1
- package/dist/components/kemet-tabs/types.d.ts +3 -3
- package/dist/components/kemet-textarea/docs/stories.d.ts +1 -1
- package/dist/components/kemet-textarea/kemet-textarea.js.map +1 -1
- package/dist/components/kemet-textarea/spec.d.ts +3 -0
- package/dist/components/kemet-textarea/spec.js +69 -0
- package/dist/components/kemet-textarea/spec.js.map +1 -0
- package/dist/components/kemet-textarea/types.d.ts +1 -1
- package/dist/components/kemet-timer/docs/stories.d.ts +10 -0
- package/dist/components/kemet-timer/docs/stories.js +40 -0
- package/dist/components/kemet-timer/docs/stories.js.map +1 -0
- package/dist/components/kemet-timer/kemet-timer-display.d.ts +25 -0
- package/dist/components/kemet-timer/kemet-timer-display.js +65 -0
- package/dist/components/kemet-timer/kemet-timer-display.js.map +1 -0
- package/dist/components/kemet-timer/kemet-timer.d.ts +36 -0
- package/dist/components/kemet-timer/kemet-timer.js +103 -0
- package/dist/components/kemet-timer/kemet-timer.js.map +1 -0
- package/dist/components/kemet-timer/styles.d.ts +2 -0
- package/dist/components/kemet-timer/styles.js +12 -0
- package/dist/components/kemet-timer/styles.js.map +1 -0
- package/dist/components/kemet-timer/types.d.ts +1 -0
- package/dist/components/kemet-timer/types.js +2 -0
- package/dist/components/kemet-timer/types.js.map +1 -0
- package/dist/components/kemet-toggle/docs/stories.d.ts +1 -1
- package/dist/components/kemet-toggle/kemet-toggle.d.ts +3 -3
- package/dist/components/kemet-toggle/kemet-toggle.js +3 -3
- package/dist/components/kemet-toggle/kemet-toggle.js.map +1 -1
- package/dist/components/kemet-toggle/spec.d.ts +1 -0
- package/dist/components/kemet-toggle/spec.js +46 -0
- package/dist/components/kemet-toggle/spec.js.map +1 -0
- package/dist/components/kemet-tooltip/docs/stories.d.ts +1 -1
- package/dist/components/kemet-tooltip/kemet-tooltip.d.ts +2 -2
- package/dist/components/kemet-tooltip/kemet-tooltip.js +13 -12
- package/dist/components/kemet-tooltip/kemet-tooltip.js.map +1 -1
- package/dist/components/kemet-tooltip/types.d.ts +3 -3
- package/dist/components/kemet-tracker/docs/stories.d.ts +1 -1
- package/dist/components/kemet-tracker/docs/stories.js.map +1 -1
- package/dist/components/kemet-tracker/kemet-tracker-step.d.ts +2 -2
- package/dist/components/kemet-tracker/kemet-tracker-step.js +2 -2
- package/dist/components/kemet-tracker/kemet-tracker-step.js.map +1 -1
- package/dist/components/kemet-tracker/kemet-tracker.d.ts +2 -1
- package/dist/components/kemet-tracker/kemet-tracker.js.map +1 -1
- package/dist/components/kemet-upload/docs/stories.d.ts +1 -1
- package/dist/components/kemet-upload/kemet-upload-file.js +1 -2
- package/dist/components/kemet-upload/kemet-upload-file.js.map +1 -1
- package/dist/components/kemet-upload/kemet-upload.d.ts +3 -3
- package/dist/components/kemet-upload/kemet-upload.js +3 -8
- package/dist/components/kemet-upload/kemet-upload.js.map +1 -1
- package/dist/kemet-components.bundle.js +82 -86
- package/dist/kemet-components.bundle.js.map +1 -1
- package/dist/kemet-components.cjs +3320 -2985
- package/dist/kemet-components.js +3320 -2985
- package/dist/styles/kemet.base.css +24 -2
- package/dist/styles/kemet.base.css.map +1 -1
- package/dist/styles/kemet.core.css +266 -562
- package/dist/styles/kemet.core.css.map +1 -1
- package/dist/styles/shared/_config.scss +25 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/controllers/forms.js +16 -18
- package/dist/utilities/controllers/forms.js.map +1 -1
- package/dist/utilities/controllers/forms.spec.d.ts +2 -0
- package/dist/utilities/controllers/forms.spec.js +36 -0
- package/dist/utilities/controllers/forms.spec.js.map +1 -0
- package/dist/utilities/misc/drag.d.ts +6 -0
- package/dist/utilities/misc/drag.js +63 -0
- package/dist/utilities/misc/drag.js.map +1 -0
- package/package.json +50 -35
- package/dist/components/kemet-accordion/stories.d.ts +0 -12
- package/dist/components/kemet-accordion/stories.js +0 -47
- package/dist/components/kemet-accordion/stories.js.map +0 -1
|
@@ -43,6 +43,7 @@ let KemetCombo = class KemetCombo extends LitElement {
|
|
|
43
43
|
this.slug = this.field.slug || 'slug';
|
|
44
44
|
// events listeners
|
|
45
45
|
this.input.addEventListener('kemet-input-input', this.handleInput.bind(this));
|
|
46
|
+
this.input.addEventListener('kemet-multi-input-focus', this.handleFocus.bind(this));
|
|
46
47
|
this.input.addEventListener('keydown', event => this.handleInputKeyDown(event));
|
|
47
48
|
}
|
|
48
49
|
render() {
|
|
@@ -66,42 +67,42 @@ let KemetCombo = class KemetCombo extends LitElement {
|
|
|
66
67
|
makeOptions() {
|
|
67
68
|
if (this.input) {
|
|
68
69
|
this.filteredOptions = this.options.filter(option => { var _a; return option.toLowerCase().indexOf((_a = this.input.value) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== -1; });
|
|
69
|
-
|
|
70
|
+
return this.filteredOptions.map((option, index) => html `<li
|
|
70
71
|
id="${this.slug}-option-${index}"
|
|
71
72
|
role="option"
|
|
72
73
|
tabindex="0"
|
|
73
74
|
aria-selected="false"
|
|
74
|
-
@click=${event => this.handleSelection(event)}
|
|
75
|
-
@keydown=${event => this.handleOptionKeyDown(event)}
|
|
75
|
+
@click=${(event) => this.handleSelection(event)}
|
|
76
|
+
@keydown=${(event) => this.handleOptionKeyDown(event)}
|
|
76
77
|
>
|
|
77
78
|
${option}
|
|
78
79
|
</li>`);
|
|
79
|
-
return options;
|
|
80
80
|
}
|
|
81
81
|
return null;
|
|
82
82
|
}
|
|
83
83
|
handleInput(event) {
|
|
84
84
|
this.makeOptions();
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
85
|
+
this.show = event.detail.length > 0;
|
|
86
|
+
}
|
|
87
|
+
handleFocus() {
|
|
88
|
+
this.makeOptions();
|
|
89
|
+
this.show = true;
|
|
91
90
|
}
|
|
92
91
|
handleSelection(event) {
|
|
93
|
-
|
|
92
|
+
const target = event.target;
|
|
93
|
+
this.input.value = target.innerText;
|
|
94
94
|
this.show = false;
|
|
95
|
-
emitEvent(this, 'kemet-combo-
|
|
96
|
-
element:
|
|
97
|
-
text:
|
|
98
|
-
id:
|
|
95
|
+
emitEvent(this, 'kemet-combo-selection', {
|
|
96
|
+
element: target,
|
|
97
|
+
text: target.innerText,
|
|
98
|
+
id: target.getAttribute('id'),
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
handleOptionKeyDown(event) {
|
|
102
102
|
event.preventDefault();
|
|
103
|
+
const target = event.target;
|
|
103
104
|
if (event.code === 'ArrowDown') {
|
|
104
|
-
const next =
|
|
105
|
+
const next = target.nextElementSibling;
|
|
105
106
|
if (next) {
|
|
106
107
|
next.focus();
|
|
107
108
|
}
|
|
@@ -110,7 +111,7 @@ let KemetCombo = class KemetCombo extends LitElement {
|
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
if (event.code === 'ArrowUp') {
|
|
113
|
-
const previous =
|
|
114
|
+
const previous = target.previousElementSibling;
|
|
114
115
|
const lastChild = this.shadowRoot.querySelector('li:last-child');
|
|
115
116
|
if (previous) {
|
|
116
117
|
previous.focus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kemet-combo.js","sourceRoot":"","sources":["../../../src/components/kemet-combo/kemet-combo.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"kemet-combo.js","sourceRoot":"","sources":["../../../src/components/kemet-combo/kemet-combo.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGY,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QAOb,YAAO,GAAa,EAAE,CAAC;IAuIzB,CAAC;IAzHC,YAAY;QACV,sBAAsB;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAExD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AAI,EAAE,CAAC;wCAC7B;AAGd;IADC,KAAK,EAAE;mDACkB;AAG1B;IADC,KAAK,EAAE;yCACU;AAGlB;IADC,KAAK,EAAE;yCACgB;AAnBL,UAAU;IAD9B,aAAa,CAAC,aAAa,CAAC;GACR,UAAU,CA8I9B;eA9IoB,UAAU","sourcesContent":["import { html, LitElement } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { emitEvent } from '../../utilities/misc/events';\nimport { stylesBase } from './styles';\nimport type KemetField from '../kemet-field/kemet-field';\n\n/**\n * @since 1.0.0\n * @status stable\n *\n * @tagname kemet-combo\n * @summary Allows the user to select a choice filtered through an Input. May only be used as a component of Field.\n *\n * @prop {string} slug - Uniquely identifies the component. Should match the slug used in a control.\n * @prop {array} options - An array of items listed for the combo box\n * @prop {boolean} show - Controls the display of the combo box\n *\n * @csspart combobox - The combo's container element.\n * @csspart listbox - The list element in the combo.\n *\n * @cssproperty --kemet-combo-width - The width of the combo box.\n * @cssproperty --kemet-combo-margin - The margins on the combo box.\n * @cssproperty --kemet-combo-max-height - The max height of the combo box.\n * @cssproperty --kemet-combo-border - The border of the combo box.\n * @cssproperty --kemet-combo-border-radius - The border radius of the combo box.\n * @cssproperty --kemet-combo-background-color - The background color of the combo box.\n * @cssproperty --kemet-combo-shadow - The shadow of the combo box.\n * @cssproperty --kemet-combo-hover-color - The hover item's text color.\n * @cssproperty --kemet-combo-hover-background-color - The hover item's background color.\n *\n * @event kemet-combo-selection - Fires when a selection has been made\n *\n */\n\n@customElement('kemet-combo')\nexport default class KemetCombo extends LitElement {\n static styles = [stylesBase];\n\n @property({ type: String })\n slug: string;\n\n @property({ type: Array })\n options: string[] = [];\n\n @property({ type: Boolean, reflect: true })\n show: boolean;\n\n @state()\n filteredOptions: string[];\n\n @state()\n field: KemetField;\n\n @state()\n input: HTMLInputElement;\n\n firstUpdated() {\n // standard properties\n this.field = this.closest('kemet-field');\n this.input = this.field.querySelector('[slot=\"input\"]');\n\n // managed properties\n this.slug = this.field.slug || 'slug';\n\n // events listeners\n this.input.addEventListener('kemet-input-input', this.handleInput.bind(this));\n this.input.addEventListener('kemet-multi-input-focus', this.handleFocus.bind(this));\n this.input.addEventListener('keydown', event => this.handleInputKeyDown(event));\n }\n\n render() {\n return html`\n <div\n role=\"combobox\"\n part=\"combobox\"\n aria-expanded=${this.show}\n aria-controls=\"${this.slug}-listbox\"\n aria-haspopup=\"listbox\"\n id=\"${this.slug}-combobox\"\n aria-label=\"${this.field?.label}\"\n >\n <ul role=\"listbox\" aria-labelledby=\"${this.slug}-label\" id=\"${this.slug}-listbox\" part=\"listbox\">\n ${this.makeOptions()}\n </ul>\n </div>\n `;\n }\n\n makeOptions() {\n if (this.input) {\n this.filteredOptions = this.options.filter(\n option => option.toLowerCase().indexOf(this.input.value?.toLowerCase()) !== -1,\n );\n\n return this.filteredOptions.map(\n (option, index) => html`<li\n id=\"${this.slug}-option-${index}\"\n role=\"option\"\n tabindex=\"0\"\n aria-selected=\"false\"\n @click=${(event: KeyboardEvent) => this.handleSelection(event)}\n @keydown=${(event: KeyboardEvent) => this.handleOptionKeyDown(event)}\n >\n ${option}\n </li>`,\n );\n }\n\n return null;\n }\n\n handleInput(event: CustomEvent) {\n this.makeOptions();\n this.show = event.detail.length > 0;\n }\n\n handleFocus() {\n this.makeOptions();\n this.show = true;\n }\n\n handleSelection(event: KeyboardEvent) {\n const target = event.target as HTMLElement;\n this.input.value = target.innerText;\n this.show = false;\n\n emitEvent(this, 'kemet-combo-selection', {\n element: target,\n text: target.innerText,\n id: target.getAttribute('id'),\n });\n }\n\n handleOptionKeyDown(event: KeyboardEvent) {\n event.preventDefault();\n const target = event.target as HTMLElement;\n\n if (event.code === 'ArrowDown') {\n const next = target.nextElementSibling as HTMLElement;\n\n if (next) {\n next.focus();\n } else {\n this.shadowRoot.querySelector('li').focus();\n }\n }\n\n if (event.code === 'ArrowUp') {\n const previous = target.previousElementSibling as HTMLElement;\n const lastChild = this.shadowRoot.querySelector('li:last-child') as HTMLElement;\n\n if (previous) {\n previous.focus();\n } else {\n lastChild.focus();\n }\n }\n\n if (event.code === 'Escape' || event.code === 'Tab') {\n this.show = false;\n this.input.focus();\n }\n\n if (event.code === 'Enter' || event.code === 'Space') {\n this.handleSelection(event);\n }\n }\n\n handleInputKeyDown(event: KeyboardEvent) {\n if (event.code === 'ArrowDown') {\n this.shadowRoot.querySelector('li').focus();\n }\n\n if (event.code === 'Escape') {\n this.show = false;\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kemet-combo': KemetCombo\n }\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { html, render } from 'lit';
|
|
2
|
+
import { Key } from 'webdriverio';
|
|
3
|
+
import { expect } from '@wdio/globals';
|
|
4
|
+
import { waitFor } from '@testing-library/dom';
|
|
5
|
+
import './kemet-combo';
|
|
6
|
+
import '../kemet-field/kemet-field';
|
|
7
|
+
import '../kemet-input/kemet-input';
|
|
8
|
+
import userEvent from '@testing-library/user-event';
|
|
9
|
+
describe('Combo', () => {
|
|
10
|
+
const options = ['Item 1', 'Item 2', 'Item 3'];
|
|
11
|
+
const templates = {
|
|
12
|
+
default: html `
|
|
13
|
+
<kemet-field label="Combo">
|
|
14
|
+
<kemet-input slot="input" name="input"></kemet-input>
|
|
15
|
+
<kemet-combo slot="component" .options=${options}></kemet-combo>
|
|
16
|
+
</kemet-field>
|
|
17
|
+
`,
|
|
18
|
+
};
|
|
19
|
+
it('selects from combo list box', async () => {
|
|
20
|
+
render(templates.default, document.body);
|
|
21
|
+
await waitFor(async () => {
|
|
22
|
+
const combo = document.body.querySelector('kemet-combo');
|
|
23
|
+
const input = document.body.querySelector('kemet-input').shadowRoot.querySelector('input');
|
|
24
|
+
await userEvent.type(input, 'Item');
|
|
25
|
+
const listboxItem = combo.shadowRoot.querySelector('li');
|
|
26
|
+
await userEvent.click(listboxItem);
|
|
27
|
+
expect(input.value).toBe('Item 1');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
it('selects from combo list box using a keyboard', async () => {
|
|
31
|
+
render(templates.default, document.body);
|
|
32
|
+
await waitFor(async () => {
|
|
33
|
+
const combo = document.body.querySelector('kemet-combo');
|
|
34
|
+
const input = document.body.querySelector('kemet-input').shadowRoot.querySelector('input');
|
|
35
|
+
combo.show = true;
|
|
36
|
+
await browser.keys([Key.Tab]);
|
|
37
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
38
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
39
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
40
|
+
await userEvent.keyboard('{ArrowUp}');
|
|
41
|
+
await userEvent.keyboard('{Enter}');
|
|
42
|
+
expect(input.value).toBe('Item 1');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../src/components/kemet-combo/spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,eAAe,CAAC;AACvB,OAAO,4BAA4B,CAAC;AACpC,OAAO,4BAA4B,CAAC;AACpC,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAEpD,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,MAAM,OAAO,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAE/C,MAAM,SAAS,GAAG;QAChB,OAAO,EAAE,IAAI,CAAA;;;iDAGgC,OAAO;;KAEnD;KACF,CAAC;IAEF,EAAE,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC3C,MA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AC;YACxC,MAAM,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YACxC,MAAM,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YACtC,MAAM,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YACpC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { html, render } from 'lit';\nimport { Key } from 'webdriverio';\nimport { expect } from '@wdio/globals';\nimport { waitFor } from '@testing-library/dom';\n\nimport './kemet-combo';\nimport '../kemet-field/kemet-field';\nimport '../kemet-input/kemet-input';\nimport userEvent from '@testing-library/user-event';\n\ndescribe('Combo', () => {\n const options = ['Item 1', 'Item 2', 'Item 3'];\n\n const templates = {\n default: html`\n <kemet-field label=\"Combo\">\n <kemet-input slot=\"input\" name=\"input\"></kemet-input>\n <kemet-combo slot=\"component\" .options=${options}></kemet-combo>\n </kemet-field>\n `,\n };\n\n it('selects from combo list box', async () => {\n render(templates.default, document.body);\n await waitFor(async () => {\n const combo = document.body.querySelector('kemet-combo');\n const input = document.body.querySelector('kemet-input').shadowRoot.querySelector('input');\n await userEvent.type(input, 'Item');\n const listboxItem = combo.shadowRoot.querySelector('li');\n await userEvent.click(listboxItem);\n expect(input.value).toBe('Item 1');\n });\n });\n\n it('selects from combo list box using a keyboard', async () => {\n render(templates.default, document.body);\n await waitFor(async () => {\n const combo = document.body.querySelector('kemet-combo');\n const input = document.body.querySelector('kemet-input').shadowRoot.querySelector('input');\n combo.show = true;\n await browser.keys([Key.Tab]);\n await userEvent.keyboard('{ArrowDown}');\n await userEvent.keyboard('{ArrowDown}');\n await userEvent.keyboard('{ArrowDown}');\n await userEvent.keyboard('{ArrowUp}');\n await userEvent.keyboard('{Enter}');\n expect(input.value).toBe('Item 1');\n });\n });\n});\n"]}
|
|
@@ -7,7 +7,7 @@ import { KemetTextareaInterface } from '../kemet-textarea/types';
|
|
|
7
7
|
* @status stable
|
|
8
8
|
*
|
|
9
9
|
* @tagname kemet-count
|
|
10
|
-
* @summary Maintains a character count for
|
|
10
|
+
* @summary Maintains a character count for an input field. Is to be used only in the component slot of a Field component.
|
|
11
11
|
*
|
|
12
12
|
* @prop {string} message - The text label shown to users
|
|
13
13
|
* @prop {number} remaining - The number of characters remaining
|
|
@@ -7,7 +7,7 @@ import { emitEvent } from '../../utilities/misc/events';
|
|
|
7
7
|
* @status stable
|
|
8
8
|
*
|
|
9
9
|
* @tagname kemet-count
|
|
10
|
-
* @summary Maintains a character count for
|
|
10
|
+
* @summary Maintains a character count for an input field. Is to be used only in the component slot of a Field component.
|
|
11
11
|
*
|
|
12
12
|
* @prop {string} message - The text label shown to users
|
|
13
13
|
* @prop {number} remaining - The number of characters remaining
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kemet-count.js","sourceRoot":"","sources":["../../../src/components/kemet-count/kemet-count.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAKxD;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"kemet-count.js","sourceRoot":"","sources":["../../../src/components/kemet-count/kemet-count.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAKxD;;;;;;;;;;;;;;;;GAgBG;AAGY,IAAM,UAAU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,SAAS;qBACxB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC9D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACtE,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;IACjD,CAAC;;AA9EM,iBAAM,GAAG;IACd,GAAG,CAAA;;;;;;KAMF;CACF,AARY,CAQX;AAGF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACX;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACT;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCACb;AAGd;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,CAAC;uDAClC;AAG7B;IADC,KAAK,EAAE;yCACmB;AAG3B;IADC,KAAK,EAAE;6CACgD;AAGxD;IADC,KAAK,EAAE;yCACgB;AAGxB;IADC,KAAK,EAAE;4CACsB;AAjCX,UAAU;IAD9B,aAAa,CAAC,aAAa,CAAC;GACR,UAAU,CAgF9B;eAhFoB,UAAU","sourcesContent":["import { html, css, LitElement } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { emitEvent } from '../../utilities/misc/events';\nimport { KemetFieldInterface } from '../kemet-field/types';\nimport { KemetInputInterface } from '../kemet-input/types';\nimport { KemetTextareaInterface } from '../kemet-textarea/types';\n\n/**\n * @since 1.0.0\n * @status stable\n *\n * @tagname kemet-count\n * @summary Maintains a character count for an input field. Is to be used only in the component slot of a Field component.\n *\n * @prop {string} message - The text label shown to users\n * @prop {number} remaining - The number of characters remaining\n * @prop {number} limit - The maximum number of characters allowed\n * @prop {boolean} validateImmediately - Set to true if the field should validate as soon as the character limit is reached\n *\n * @cssproperty --kemet-count-font-size - The font size. Default: 90%.\n *\n * @event kemet-count-status - Fires when there's a change in status.\n *\n */\n\n@customElement('kemet-count')\nexport default class KemetCount extends LitElement {\n static styles = [\n css`\n :host {\n display: block;\n font-size: var(--kemet-count-font-size, 90%);\n margin-top: 0.8rem;\n }\n `,\n ];\n\n @property({ type: String })\n message: string;\n\n @property({ type: Number })\n remaining: number;\n\n @property({ type: Number })\n limit: number;\n\n @property({ type: Boolean, attribute: 'validate-immediately' })\n validateImmediately: boolean;\n\n @state()\n field: KemetFieldInterface;\n\n @state()\n inputSlot: KemetInputInterface | KemetTextareaInterface;\n\n @state()\n input: HTMLInputElement;\n\n @state()\n textarea: HTMLTextAreaElement;\n\n firstUpdated() {\n this.field = this.closest('kemet-field');\n this.inputSlot = this.field.querySelector('[slot=\"input\"]');\n\n this.remaining = this.limit - this.field.length;\n\n this.field.addEventListener('kemet-field-input', (event: CustomEvent) => {\n this.remaining = this.limit - event.detail;\n\n const nativeElement = this.input || this.textarea;\n\n if (nativeElement) {\n if (this.remaining < 0) {\n // nativeElement.validity.passedLimit = true;\n\n if (this.validateImmediately) {\n this.inputSlot.status = 'error';\n this.inputSlot.invalid = true;\n\n emitEvent(this, 'kemet-count-status', {\n status: 'error',\n validity: nativeElement.validity,\n element: this.inputSlot,\n });\n }\n } else {\n this.inputSlot.status = 'standard';\n nativeElement.checkValidity();\n\n emitEvent(this, 'kemet-count-status', {\n status: 'standard',\n validity: nativeElement.validity,\n element: this.inputSlot,\n });\n }\n }\n });\n\n this.input = this.inputSlot.shadowRoot.querySelector('input');\n this.textarea = this.inputSlot.shadowRoot.querySelector('textarea');\n }\n\n render() {\n return html`${this.remaining} ${this.message}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kemet-count': KemetCount\n }\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { html, render } from 'lit';
|
|
2
|
+
import { expect } from '@wdio/globals';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { waitFor } from '@testing-library/dom';
|
|
5
|
+
import '../kemet-input/kemet-input';
|
|
6
|
+
import '../kemet-textarea/kemet-textarea';
|
|
7
|
+
import '../kemet-field/kemet-field';
|
|
8
|
+
import './kemet-count';
|
|
9
|
+
describe('Field', () => {
|
|
10
|
+
const templates = {
|
|
11
|
+
default: html `
|
|
12
|
+
<kemet-field>
|
|
13
|
+
<kemet-input slot="input" name="input"></kemet-input>
|
|
14
|
+
<kemet-count slot="component" message="characters remaining." limit="6" validate-immediately></kemet-count>
|
|
15
|
+
</kemet-field>
|
|
16
|
+
`,
|
|
17
|
+
textarea: html `
|
|
18
|
+
<kemet-field>
|
|
19
|
+
<kemet-textarea slot="input" name="textarea"></kemet-textarea>
|
|
20
|
+
<kemet-count slot="component" message="characters remaining." limit="6" validate-immediately></kemet-count>
|
|
21
|
+
</kemet-field>
|
|
22
|
+
`,
|
|
23
|
+
};
|
|
24
|
+
it('should count characters remaining', async () => {
|
|
25
|
+
render(templates.default, document.body);
|
|
26
|
+
const kemetInput = document.querySelector('kemet-input');
|
|
27
|
+
const kemetCount = document.querySelector('kemet-count');
|
|
28
|
+
await waitFor(async () => {
|
|
29
|
+
const input = kemetInput.shadowRoot.querySelector('input');
|
|
30
|
+
await userEvent.type(input, 'abcdefgh');
|
|
31
|
+
expect(kemetCount.remaining).toBe(-2);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
it('should count characters remaining in a textarea', async () => {
|
|
35
|
+
render(templates.textarea, document.body);
|
|
36
|
+
const kemetTextarea = document.querySelector('kemet-textarea');
|
|
37
|
+
const kemetCount = document.querySelector('kemet-count');
|
|
38
|
+
await waitFor(async () => {
|
|
39
|
+
const textarea = kemetTextarea.shadowRoot.querySelector('textarea');
|
|
40
|
+
await userEvent.type(textarea, 'abcdefgh');
|
|
41
|
+
expect(kemetCount.remaining).toBe(-2);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../src/components/kemet-count/spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,4BAA4B,CAAC;AACpC,OAAO,kCAAkC,CAAC;AAC1C,OAAO,4BAA4B,CAAC;AACpC,OAAO,eAAe,CAAC;AAEvB,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,MAAM,SAAS,GAAG;QAChB,OAAO,EAAE,IAAI,CAAA;;;;;KAKZ;QACD,QAAQ,EAAE,IAAI,CAAA;;;;;KAKb;KACF,CAAC;IAEF,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QACzD,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAEzD,MAAM,OAAO,CAAC,KAAK,IAAI,EAAE;YACvB,MAAM,KAAK,GAAG,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAC3D,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;YACxC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAC/D,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAEzD,MAAM,OAAO,CAAC,KAAK,IAAI,EAAE;YACvB,MAAM,QAAQ,GAAG,aAAa,CAAC,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YACpE,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;YAC3C,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { html, render } from 'lit';\nimport { expect } from '@wdio/globals';\nimport userEvent from '@testing-library/user-event';\nimport { waitFor } from '@testing-library/dom';\n\nimport '../kemet-input/kemet-input';\nimport '../kemet-textarea/kemet-textarea';\nimport '../kemet-field/kemet-field';\nimport './kemet-count';\n\ndescribe('Field', () => {\n const templates = {\n default: html`\n <kemet-field>\n <kemet-input slot=\"input\" name=\"input\"></kemet-input>\n <kemet-count slot=\"component\" message=\"characters remaining.\" limit=\"6\" validate-immediately></kemet-count>\n </kemet-field>\n `,\n textarea: html`\n <kemet-field>\n <kemet-textarea slot=\"input\" name=\"textarea\"></kemet-textarea>\n <kemet-count slot=\"component\" message=\"characters remaining.\" limit=\"6\" validate-immediately></kemet-count>\n </kemet-field>\n `,\n };\n\n it('should count characters remaining', async () => {\n render(templates.default, document.body);\n const kemetInput = document.querySelector('kemet-input');\n const kemetCount = document.querySelector('kemet-count');\n\n await waitFor(async () => {\n const input = kemetInput.shadowRoot.querySelector('input');\n await userEvent.type(input, 'abcdefgh');\n expect(kemetCount.remaining).toBe(-2);\n });\n });\n\n it('should count characters remaining in a textarea', async () => {\n render(templates.textarea, document.body);\n const kemetTextarea = document.querySelector('kemet-textarea');\n const kemetCount = document.querySelector('kemet-count');\n\n await waitFor(async () => {\n const textarea = kemetTextarea.shadowRoot.querySelector('textarea');\n await userEvent.type(textarea, 'abcdefgh');\n expect(kemetCount.remaining).toBe(-2);\n });\n });\n});\n"]}
|
|
@@ -30,15 +30,15 @@ export default class KemetDraggable extends LitElement {
|
|
|
30
30
|
/** @internal */
|
|
31
31
|
position4: number;
|
|
32
32
|
/** @internal */
|
|
33
|
-
mouseMove: (event:
|
|
33
|
+
mouseMove: (event: MouseEvent) => void;
|
|
34
34
|
/** @internal */
|
|
35
35
|
mouseUp: () => void;
|
|
36
36
|
/** @internal */
|
|
37
37
|
draggableElement: HTMLElement;
|
|
38
38
|
firstUpdated(): void;
|
|
39
39
|
render(): import("lit-html").TemplateResult<1>;
|
|
40
|
-
startDrag(event:
|
|
41
|
-
drag(event:
|
|
40
|
+
startDrag(event: MouseEvent): void;
|
|
41
|
+
drag(event: MouseEvent): void;
|
|
42
42
|
stopDrag(): void;
|
|
43
43
|
measureContent(): void;
|
|
44
44
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { html, css, LitElement } from 'lit';
|
|
3
|
-
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
3
|
+
import { customElement, property, query, state, } from 'lit/decorators.js';
|
|
4
4
|
import { emitEvent } from '../../utilities/misc/events';
|
|
5
5
|
/**
|
|
6
6
|
* @since 1.0.0
|
|
@@ -45,7 +45,7 @@ let KemetDraggable = class KemetDraggable extends LitElement {
|
|
|
45
45
|
}
|
|
46
46
|
render() {
|
|
47
47
|
return html `
|
|
48
|
-
<div id="draggable" @mousedown=${event => this.startDrag(event)} style="top:${this.top}; left:${this.left}">
|
|
48
|
+
<div id="draggable" @mousedown=${(event) => this.startDrag(event)} style="top:${this.top}; left:${this.left}">
|
|
49
49
|
<slot></slot>
|
|
50
50
|
</div>
|
|
51
51
|
`;
|
|
@@ -61,14 +61,15 @@ let KemetDraggable = class KemetDraggable extends LitElement {
|
|
|
61
61
|
emitEvent(this, 'kemet-draggable-start', this);
|
|
62
62
|
}
|
|
63
63
|
drag(event) {
|
|
64
|
-
var _a, _b;
|
|
65
64
|
event.preventDefault();
|
|
66
65
|
this.position1 = this.position3 - event.clientX;
|
|
67
66
|
this.position2 = this.position4 - event.clientY;
|
|
68
67
|
this.position3 = event.clientX;
|
|
69
68
|
this.position4 = event.clientY;
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
if (this.draggableElement) {
|
|
70
|
+
this.top = `${this.draggableElement.offsetTop - this.position2}px`;
|
|
71
|
+
this.left = `${this.draggableElement.offsetLeft - this.position1}px`;
|
|
72
|
+
}
|
|
72
73
|
}
|
|
73
74
|
stopDrag() {
|
|
74
75
|
document.removeEventListener('mouseup', this.mouseUp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kemet-draggable.js","sourceRoot":"","sources":["../../../src/components/kemet-draggable/kemet-draggable.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"kemet-draggable.js","sourceRoot":"","sources":["../../../src/components/kemet-draggable/kemet-draggable.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EACN,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GACrC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD;;;;;;;;;;;;;;;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AEF,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;QACnE,CAAC;QAED,SAAS,CAAC,IAAI,EAAE,sBAAsB,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,cAAc;;QACZ,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,MAAA,IAAI,CAAC,gBAAgB,0CAAE,WAAW,IAAI,CAAC;QAC7D,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,MAAA,IAAI,CAAC,gBAAgB,0CAAE,YAAY,IAAI,CAAC;IACjE,CAAC;;AA/HM,qBAAM,GAAG,CAAC,GAAG,CAAA;;;;;;;;GAQnB,CAAC,AARW,CAQV;AAGH;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACZ;AAGf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACN;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CACL;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CACH;AAIzB;IADC,KAAK,EAAE;iDACU;AAIlB;IADC,KAAK,EAAE;iDACU;AAIlB;IADC,KAAK,EAAE;iDACU;AAIlB;IADC,KAAK,EAAE;iDACU;AAIlB;IADC,KAAK,EAAE;iDAC+B;AAIvC;IADC,KAAK,EAAE;+CACY;AAIpB;IADC,KAAK,CAAC,YAAY,CAAC;wDACU;AAjDX,cAAc;IADlC,aAAa,CAAC,iBAAiB,CAAC;GACZ,cAAc,CAiIlC;eAjIoB,cAAc","sourcesContent":["import { html, css, LitElement } from 'lit';\nimport {\n customElement, property, query, state,\n} from 'lit/decorators.js';\nimport { emitEvent } from '../../utilities/misc/events';\n\n/**\n * @since 1.0.0\n * @status stable\n *\n * @tagname kemet-draggable\n * @summary A draggable element with the ability to remember its position.\n *\n * @prop {string} memory - A unique identifier used to store the element's position in local storage.\n * @prop {string} top - The elements top position in pixels.\n * @prop {string} left - The element's left position in pixels.\n * @prop {boolean} measure - If set to true, will measure the width and height of the element's content and apply it to the host element.\n *\n * @event kemet-draggable-start\n * @event kemet-draggable-stop\n *\n */\n\n@customElement('kemet-draggable')\nexport default class KemetDraggable extends LitElement {\n static styles = [css`\n :host {\n display: inline-block;\n }\n\n #draggable {\n position: absolute;\n }\n `];\n\n @property({ type: String })\n memory: string;\n\n @property({ type: String })\n top: string = 'auto';\n\n @property({ type: String })\n left: string = 'auto';\n\n @property({ type: Boolean })\n measure: boolean = false;\n\n /** @internal */\n @state()\n position1: number;\n\n /** @internal */\n @state()\n position2: number;\n\n /** @internal */\n @state()\n position3: number;\n\n /** @internal */\n @state()\n position4: number;\n\n /** @internal */\n @state()\n mouseMove: (event: MouseEvent) => void;\n\n /** @internal */\n @state()\n mouseUp: () => void;\n\n /** @internal */\n @query('#draggable')\n draggableElement: HTMLElement;\n\n firstUpdated() {\n // standard properties\n /** @internal */\n this.position1 = 0;\n this.position2 = 0;\n this.position3 = 0;\n this.position4 = 0;\n this.mouseMove = event => this.drag(event);\n this.mouseUp = () => this.stopDrag();\n\n const savedPosition = JSON.parse(localStorage.getItem(this.memory));\n\n if (savedPosition) {\n this.top = savedPosition.top;\n this.left = savedPosition.left;\n }\n\n if (this.measure) {\n this.measureContent();\n }\n }\n\n render() {\n return html`\n <div id=\"draggable\" @mousedown=${(event: MouseEvent) => this.startDrag(event)} style=\"top:${this.top}; left:${this.left}\">\n <slot></slot>\n </div>\n `;\n }\n\n startDrag(event: MouseEvent) {\n if (event) {\n event.preventDefault();\n\n this.position3 = event.clientX;\n this.position4 = event.clientY;\n }\n\n document.addEventListener('mouseup', this.mouseUp);\n document.addEventListener('mousemove', this.mouseMove);\n\n emitEvent(this, 'kemet-draggable-start', this);\n }\n\n drag(event: MouseEvent) {\n event.preventDefault();\n\n this.position1 = this.position3 - event.clientX;\n this.position2 = this.position4 - event.clientY;\n this.position3 = event.clientX;\n this.position4 = event.clientY;\n\n if (this.draggableElement) {\n this.top = `${this.draggableElement.offsetTop - this.position2}px`;\n this.left = `${this.draggableElement.offsetLeft - this.position1}px`;\n }\n }\n\n stopDrag() {\n document.removeEventListener('mouseup', this.mouseUp);\n document.removeEventListener('mousemove', this.mouseMove);\n\n if (this.memory) {\n const savedPosition = {\n top: this.top,\n left: this.left,\n };\n\n localStorage.setItem(this.memory, JSON.stringify(savedPosition));\n }\n\n emitEvent(this, 'kemet-draggable-stop', this);\n }\n\n measureContent() {\n this.style.width = `${this.draggableElement?.offsetWidth}px`;\n this.style.height = `${this.draggableElement?.offsetHeight}px`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kemet-draggable': KemetDraggable\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './kemet-draggable';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { html, render } from 'lit';
|
|
2
|
+
import { expect } from '@wdio/globals';
|
|
3
|
+
import { waitFor } from '@testing-library/dom';
|
|
4
|
+
import './kemet-draggable';
|
|
5
|
+
import drag from '../../utilities/misc/drag';
|
|
6
|
+
describe('Draggable', () => {
|
|
7
|
+
const templates = {
|
|
8
|
+
default: html `
|
|
9
|
+
<kemet-draggable measure memory="memory">
|
|
10
|
+
<kemet-button>Drag Me!</kemet-button>
|
|
11
|
+
</kemet-draggable>
|
|
12
|
+
`,
|
|
13
|
+
};
|
|
14
|
+
it('should drag the component', async () => {
|
|
15
|
+
render(templates.default, document.body);
|
|
16
|
+
const kemetDraggable = document.querySelector('kemet-draggable');
|
|
17
|
+
const initialX = kemetDraggable.left;
|
|
18
|
+
const initialY = kemetDraggable.top;
|
|
19
|
+
await waitFor(async () => {
|
|
20
|
+
const draggable = kemetDraggable.shadowRoot.querySelector('#draggable');
|
|
21
|
+
await drag(draggable, {
|
|
22
|
+
to: { x: 0, y: 0 },
|
|
23
|
+
delta: { x: 100, y: 100 },
|
|
24
|
+
});
|
|
25
|
+
expect(kemetDraggable.style.left).not.toBe(initialX);
|
|
26
|
+
expect(kemetDraggable.style.top).not.toBe(initialY);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../src/components/kemet-draggable/spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,mBAAmB,CAAC;AAC3B,OAAO,IAAI,MAAM,2BAA2B,CAAC;AAE7C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,MAAM,SAAS,GAAG;QAChB,OAAO,EAAE,IAAI,CAAA;;;;KAIZ;KACF,CAAC;IAEF,EAAE,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,cAAc,GAAG,QAAQ,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;QACjE,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC;QACrC,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC;QAEpC,MAAM,OAAO,CAAC,KAAK,IAAI,EAAE;YACvB,MAAM,SAAS,GAAG,cAAc,CAAC,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;YAExE,MAAM,IAAI,CAAC,SAAS,EAAE;gBACpB,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;gBAClB,KAAK,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE;aAC1B,CAAC,CAAC;YAEH,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { html, render } from 'lit';\nimport { expect } from '@wdio/globals';\nimport { waitFor } from '@testing-library/dom';\n\nimport './kemet-draggable';\nimport drag from '../../utilities/misc/drag';\n\ndescribe('Draggable', () => {\n const templates = {\n default: html`\n <kemet-draggable measure memory=\"memory\">\n <kemet-button>Drag Me!</kemet-button>\n </kemet-draggable>\n `,\n };\n\n it('should drag the component', async () => {\n render(templates.default, document.body);\n const kemetDraggable = document.querySelector('kemet-draggable');\n const initialX = kemetDraggable.left;\n const initialY = kemetDraggable.top;\n\n await waitFor(async () => {\n const draggable = kemetDraggable.shadowRoot.querySelector('#draggable');\n\n await drag(draggable, {\n to: { x: 0, y: 0 },\n delta: { x: 100, y: 100 },\n });\n\n expect(kemetDraggable.style.left).not.toBe(initialX);\n expect(kemetDraggable.style.top).not.toBe(initialY);\n });\n });\n});\n"]}
|
|
@@ -6,7 +6,7 @@ import '../../kemet-tabs/kemet-tab';
|
|
|
6
6
|
import '../../kemet-tabs/kemet-tab-panel';
|
|
7
7
|
declare const meta: Meta;
|
|
8
8
|
export default meta;
|
|
9
|
-
|
|
9
|
+
type Story = StoryObj;
|
|
10
10
|
export declare const Standard: Story;
|
|
11
11
|
export declare const Overlay: Story;
|
|
12
12
|
export declare const Top: Story;
|
|
@@ -10,7 +10,7 @@ import { TypeEffect, TypeSide } from './types';
|
|
|
10
10
|
* @prop {boolean} opened - Determines if the drawer is opened or not.
|
|
11
11
|
* @prop {string} effect - The animation effect for opening and closing the drawer. Values include: (slide | reveal | push | scale)
|
|
12
12
|
* @prop {string} side - Allows you to control which side the drawer opens from. Values include: (left | right | top | bottom)
|
|
13
|
-
* @prop {boolean} overlay - Adds
|
|
13
|
+
* @prop {boolean} overlay - Adds an overlay over the content section of the Drawer when opened
|
|
14
14
|
*
|
|
15
15
|
* @slot navigation - The off-screen nav area of your app or site
|
|
16
16
|
* @slot content - The main content area of your app or site.
|
|
@@ -38,7 +38,7 @@ export default class KemetDrawer extends LitElement {
|
|
|
38
38
|
side: TypeSide;
|
|
39
39
|
overlay: boolean;
|
|
40
40
|
firstUpdated(): void;
|
|
41
|
-
updated(prevProps:
|
|
41
|
+
updated(prevProps: Map<string, never>): void;
|
|
42
42
|
render(): import("lit-html").TemplateResult<1>;
|
|
43
43
|
}
|
|
44
44
|
declare global {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { LitElement, html } from 'lit';
|
|
3
|
-
import { stylesBase, stylesEffects } from './styles';
|
|
4
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
5
4
|
import { emitEvent } from '../../utilities/misc/events';
|
|
5
|
+
import { stylesBase, stylesEffects } from './styles';
|
|
6
6
|
/**
|
|
7
7
|
* @since 1.0.0
|
|
8
8
|
* @status stable
|
|
@@ -13,7 +13,7 @@ import { emitEvent } from '../../utilities/misc/events';
|
|
|
13
13
|
* @prop {boolean} opened - Determines if the drawer is opened or not.
|
|
14
14
|
* @prop {string} effect - The animation effect for opening and closing the drawer. Values include: (slide | reveal | push | scale)
|
|
15
15
|
* @prop {string} side - Allows you to control which side the drawer opens from. Values include: (left | right | top | bottom)
|
|
16
|
-
* @prop {boolean} overlay - Adds
|
|
16
|
+
* @prop {boolean} overlay - Adds an overlay over the content section of the Drawer when opened
|
|
17
17
|
*
|
|
18
18
|
* @slot navigation - The off-screen nav area of your app or site
|
|
19
19
|
* @slot content - The main content area of your app or site.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kemet-drawer.js","sourceRoot":"","sources":["../../../src/components/kemet-drawer/kemet-drawer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"kemet-drawer.js","sourceRoot":"","sources":["../../../src/components/kemet-drawer/kemet-drawer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGY,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAIb,WAAM,GAAY,SAAS,CAAC;QAG5B,WAAM,GAAe,OAAO,CAAC;QAG7B,SAAI,GAAa,MAAM,CAAC;QAGxB,YAAO,GAAY,KAAK,CAAC;IAqC3B,CAAC;IAnCC,YAAY;QACV,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACvC,MAAM,aAAa,GAAG,KAAK,CAAC,MAAqB,CAAC;YAClD,IAAI,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,cAAc,EAAE,CAAC;gBAC1E,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YACtB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,SAA6B;QACnC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACrD,SAAS,CAAC,IAAI,EAAE,qBAAqB,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YACrD,SAAS,CAAC,IAAI,EAAE,qBAAqB,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;;;;;;;KAaV,CAAC;IACJ,CAAC;;AAhDM,kBAAM,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,AAA9B,CAA+B;AAG5C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACf;AAG5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACb;AAG7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAClB;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAClB;AAbN,WAAW;IAD/B,aAAa,CAAC,cAAc,CAAC;GACT,WAAW,CAkD/B;eAlDoB,WAAW","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { emitEvent } from '../../utilities/misc/events';\nimport { TypeEffect, TypeSide } from './types';\nimport { stylesBase, stylesEffects } from './styles';\n\n/**\n * @since 1.0.0\n * @status stable\n *\n * @tagname kemet-drawer\n * @summary A component that adds an off-canvas menu with different effects.\n *\n * @prop {boolean} opened - Determines if the drawer is opened or not.\n * @prop {string} effect - The animation effect for opening and closing the drawer. Values include: (slide | reveal | push | scale)\n * @prop {string} side - Allows you to control which side the drawer opens from. Values include: (left | right | top | bottom)\n * @prop {boolean} overlay - Adds an overlay over the content section of the Drawer when opened\n *\n * @slot navigation - The off-screen nav area of your app or site\n * @slot content - The main content area of your app or site.\n *\n * @csspart container\n * @csspart drawer\n * @csspart pusher\n * @csspart content\n * @csspart wrapper\n *\n * @cssproperty --kemet-drawer-width - The width of the drawer.\n * @cssproperty --kemet-drawer-height - The height of the drawer.\n * @cssproperty --kemet-drawer-color - The text color of the drawer.\n * @cssproperty --kemet-drawer-background-color - The background color of the drawer.\n * @cssproperty --kemet-drawer-overlay-color - The color of the overlay.\n *\n * @event kemet-drawer-opened - Fires when the drawer opens.\n * @event kemet-drawer-closed - Fires when the drawer closes.\n *\n */\n\n@customElement('kemet-drawer')\nexport default class KemetDrawer extends LitElement {\n static styles = [stylesBase, stylesEffects];\n\n @property({ type: Boolean, reflect: true })\n opened: boolean = undefined;\n\n @property({ type: String, reflect: true })\n effect: TypeEffect = 'slide';\n\n @property({ type: String, reflect: true })\n side: TypeSide = 'left';\n\n @property({ type: Boolean, reflect: true })\n overlay: boolean = false;\n\n firstUpdated() {\n this.addEventListener('click', (event) => {\n const targetElement = event.target as HTMLElement;\n if (this.opened && targetElement.tagName.toLowerCase() === 'kemet-drawer') {\n this.opened = false;\n }\n });\n }\n\n updated(prevProps: Map<string, never>) {\n if (!prevProps.get('opened') && this.opened === true) {\n emitEvent(this, 'kemet-drawer-opened', this);\n }\n\n if (prevProps.get('opened') && this.opened === false) {\n emitEvent(this, 'kemet-drawer-closed', this);\n }\n }\n\n render() {\n return html`\n <section class=\"off-canvas\" part=\"container\">\n <nav class=\"off-canvas__nav\" part=\"drawer\" title=\"Drawer\">\n <slot name=\"navigation\"></slot>\n </nav>\n <div class=\"off-canvas__pusher\" part=\"pusher\">\n <div class=\"off-canvas__content\" part=\"content\">\n <div class=\"off-canvas__wrapper\" part=\"wrapper\">\n <slot name=\"content\"></slot>\n </div>\n </div>\n </div>\n </section>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kemet-drawer': KemetDrawer\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './kemet-drawer';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { html, render } from 'lit';
|
|
2
|
+
import { expect } from '@wdio/globals';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import './kemet-drawer';
|
|
5
|
+
describe('Drawer', () => {
|
|
6
|
+
const templates = {
|
|
7
|
+
default: html `
|
|
8
|
+
<kemet-drawer opened>
|
|
9
|
+
<nav slot="navigation">Your navigation goes here.</nav>
|
|
10
|
+
<section slot="content">Your content goes here.</section>
|
|
11
|
+
</kemet-drawer>
|
|
12
|
+
`,
|
|
13
|
+
};
|
|
14
|
+
it('should close when self is clicked', async () => {
|
|
15
|
+
render(templates.default, document.body);
|
|
16
|
+
const kemetDrawer = document.querySelector('kemet-drawer');
|
|
17
|
+
await userEvent.click(kemetDrawer);
|
|
18
|
+
expect(kemetDrawer.opened).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../src/components/kemet-drawer/spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAEpD,OAAO,gBAAgB,CAAC;AAExB,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,MAAM,SAAS,GAAG;QAChB,OAAO,EAAE,IAAI,CAAA;;;;;KAKZ;KACF,CAAC;IAEF,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAC3D,MAAM,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACnC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { html, render } from 'lit';\nimport { expect } from '@wdio/globals';\nimport userEvent from '@testing-library/user-event';\n\nimport './kemet-drawer';\n\ndescribe('Drawer', () => {\n const templates = {\n default: html`\n <kemet-drawer opened>\n <nav slot=\"navigation\">Your navigation goes here.</nav>\n <section slot=\"content\">Your content goes here.</section>\n </kemet-drawer>\n `,\n };\n\n it('should close when self is clicked', async () => {\n render(templates.default, document.body);\n const kemetDrawer = document.querySelector('kemet-drawer');\n await userEvent.click(kemetDrawer);\n expect(kemetDrawer.opened).toBe(false);\n });\n});\n"]}
|