@aquera/nile-elements 1.5.2 → 1.5.3
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/README.md +6 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +239 -195
- package/dist/nile-auto-complete/nile-auto-complete.cjs.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.cjs.js.map +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.css.cjs.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.css.cjs.js.map +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.css.esm.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.esm.js +1 -1
- package/dist/nile-file-preview/nile-file-preview.cjs.js +1 -1
- package/dist/nile-file-preview/nile-file-preview.cjs.js.map +1 -1
- package/dist/nile-file-preview/nile-file-preview.css.cjs.js +1 -1
- package/dist/nile-file-preview/nile-file-preview.css.cjs.js.map +1 -1
- package/dist/nile-file-preview/nile-file-preview.css.esm.js +2 -2
- package/dist/nile-file-preview/nile-file-preview.esm.js +1 -1
- package/dist/nile-file-preview/nile-file-preview.template.cjs.js +1 -1
- package/dist/nile-file-preview/nile-file-preview.template.cjs.js.map +1 -1
- package/dist/nile-file-preview/nile-file-preview.template.esm.js +55 -25
- package/dist/nile-file-preview/utils/index.cjs.js +1 -1
- package/dist/nile-file-preview/utils/index.esm.js +1 -1
- package/dist/nile-file-preview/utils/nile-file-preview.util.cjs.js +1 -1
- package/dist/nile-file-preview/utils/nile-file-preview.util.cjs.js.map +1 -1
- package/dist/nile-file-preview/utils/nile-file-preview.util.esm.js +1 -1
- package/dist/nile-file-upload/nile-file-upload.cjs.js +1 -1
- package/dist/nile-file-upload/nile-file-upload.cjs.js.map +1 -1
- package/dist/nile-file-upload/nile-file-upload.css.cjs.js +1 -1
- package/dist/nile-file-upload/nile-file-upload.css.cjs.js.map +1 -1
- package/dist/nile-file-upload/nile-file-upload.css.esm.js +15 -5
- package/dist/nile-file-upload/nile-file-upload.esm.js +2 -2
- package/dist/nile-file-upload/nile-file-upload.template.cjs.js +2 -2
- package/dist/nile-file-upload/nile-file-upload.template.cjs.js.map +1 -1
- package/dist/nile-file-upload/nile-file-upload.template.esm.js +36 -32
- package/dist/nile-file-upload/types/file-upload.enums.cjs.js +1 -1
- package/dist/nile-file-upload/types/file-upload.enums.cjs.js.map +1 -1
- package/dist/nile-file-upload/types/file-upload.enums.esm.js +1 -1
- package/dist/nile-file-upload/types/index.cjs.js +1 -1
- package/dist/nile-file-upload/types/index.esm.js +1 -1
- package/dist/nile-file-upload/utils/drag-drop.util.cjs.js +1 -1
- package/dist/nile-file-upload/utils/drag-drop.util.cjs.js.map +1 -1
- package/dist/nile-file-upload/utils/drag-drop.util.esm.js +1 -1
- package/dist/nile-file-upload/utils/file-validation.util.cjs.js +4 -2
- package/dist/nile-file-upload/utils/file-validation.util.cjs.js.map +1 -1
- package/dist/nile-file-upload/utils/file-validation.util.esm.js +1 -1
- package/dist/nile-grid/nile-grid-head-item/nile-grid-head-item.cjs.js +1 -1
- package/dist/nile-grid/nile-grid-head-item/nile-grid-head-item.cjs.js.map +1 -1
- package/dist/nile-grid/nile-grid-head-item/nile-grid-head-item.esm.js +3 -3
- package/dist/nile-grid/nile-grid-head-item/nile-grid-head-item.utils.cjs.js +1 -1
- package/dist/nile-grid/nile-grid-head-item/nile-grid-head-item.utils.cjs.js.map +1 -1
- package/dist/nile-grid/nile-grid-head-item/nile-grid-head-item.utils.esm.js +1 -1
- package/dist/nile-grid/nile-grid.cjs.js +1 -1
- package/dist/nile-grid/nile-grid.cjs.js.map +1 -1
- package/dist/nile-grid/nile-grid.esm.js +2 -2
- package/dist/nile-grid/nile-grid.layout.cjs.js +1 -1
- package/dist/nile-grid/nile-grid.layout.esm.js +1 -1
- package/dist/nile-grid/nile-grid.resize.cjs.js +1 -1
- package/dist/nile-grid/nile-grid.resize.esm.js +1 -1
- package/dist/nile-grid/nile-grid.utils.cjs.js +1 -1
- package/dist/nile-grid/nile-grid.utils.esm.js +1 -1
- package/dist/nile-grid/nile-grid.width.cjs.js +1 -1
- package/dist/nile-grid/nile-grid.width.cjs.js.map +1 -1
- package/dist/nile-grid/nile-grid.width.esm.js +1 -1
- package/dist/nile-input/nile-input.cjs.js +1 -1
- package/dist/nile-input/nile-input.cjs.js.map +1 -1
- package/dist/nile-input/nile-input.esm.js +1 -1
- package/dist/nile-popover/index.cjs.js +1 -1
- package/dist/nile-popover/index.esm.js +1 -1
- package/dist/nile-popover/nile-popover.cjs.js +4 -4
- package/dist/nile-popover/nile-popover.cjs.js.map +1 -1
- package/dist/nile-popover/nile-popover.esm.js +11 -6
- package/dist/src/nile-accordion/nile-accordian.test.js +101 -99
- package/dist/src/nile-accordion/nile-accordian.test.js.map +1 -1
- package/dist/src/nile-auto-complete/nile-auto-complete.css.js +1 -1
- package/dist/src/nile-auto-complete/nile-auto-complete.css.js.map +1 -1
- package/dist/src/nile-auto-complete/nile-auto-complete.js +1 -1
- package/dist/src/nile-auto-complete/nile-auto-complete.js.map +1 -1
- package/dist/src/nile-auto-complete/nile-auto-complete.test.js +104 -112
- package/dist/src/nile-auto-complete/nile-auto-complete.test.js.map +1 -1
- package/dist/src/nile-avatar/nile-avatar.test.d.ts +0 -1
- package/dist/src/nile-avatar/nile-avatar.test.js +103 -87
- package/dist/src/nile-avatar/nile-avatar.test.js.map +1 -1
- package/dist/src/nile-badge/nile-badge.test.js +554 -35
- package/dist/src/nile-badge/nile-badge.test.js.map +1 -1
- package/dist/src/nile-breadcrumb/nile-breadcrumb.test.d.ts +2 -0
- package/dist/src/nile-breadcrumb/nile-breadcrumb.test.js +106 -0
- package/dist/src/nile-breadcrumb/nile-breadcrumb.test.js.map +1 -0
- package/dist/src/nile-breadcrumb-item/nile-breadcrumb-item.test.d.ts +1 -0
- package/dist/src/nile-breadcrumb-item/nile-breadcrumb-item.test.js +108 -0
- package/dist/src/nile-breadcrumb-item/nile-breadcrumb-item.test.js.map +1 -0
- package/dist/src/nile-button/nile-button.test.js +499 -39
- package/dist/src/nile-button/nile-button.test.js.map +1 -1
- package/dist/src/nile-button-filter/nile-button-filter.test.d.ts +1 -0
- package/dist/src/nile-button-filter/nile-button-filter.test.js +108 -0
- package/dist/src/nile-button-filter/nile-button-filter.test.js.map +1 -0
- package/dist/src/nile-button-toggle/nile-button-toggle.test.d.ts +1 -0
- package/dist/src/nile-button-toggle/nile-button-toggle.test.js +108 -0
- package/dist/src/nile-button-toggle/nile-button-toggle.test.js.map +1 -0
- package/dist/src/nile-button-toggle-group/nile-button-toggle-group.test.d.ts +1 -1
- package/dist/src/nile-button-toggle-group/nile-button-toggle-group.test.js +105 -104
- package/dist/src/nile-button-toggle-group/nile-button-toggle-group.test.js.map +1 -1
- package/dist/src/nile-calendar/nile-calendar.test.d.ts +0 -6
- package/dist/src/nile-calendar/nile-calendar.test.js +103 -318
- package/dist/src/nile-calendar/nile-calendar.test.js.map +1 -1
- package/dist/src/nile-card/nile-card.test.js +102 -66
- package/dist/src/nile-card/nile-card.test.js.map +1 -1
- package/dist/src/nile-checkbox/nile-checkbox.test.js +547 -108
- package/dist/src/nile-checkbox/nile-checkbox.test.js.map +1 -1
- package/dist/src/nile-chip/nile-chip.test.d.ts +0 -2
- package/dist/src/nile-chip/nile-chip.test.js +101 -102
- package/dist/src/nile-chip/nile-chip.test.js.map +1 -1
- package/dist/src/nile-circular-progressbar/nile-circular-progressbar.test.d.ts +1 -0
- package/dist/src/nile-circular-progressbar/nile-circular-progressbar.test.js +108 -0
- package/dist/src/nile-circular-progressbar/nile-circular-progressbar.test.js.map +1 -0
- package/dist/src/nile-date-picker/nile-date-picker.test.d.ts +1 -0
- package/dist/src/nile-date-picker/nile-date-picker.test.js +108 -0
- package/dist/src/nile-date-picker/nile-date-picker.test.js.map +1 -0
- package/dist/src/nile-dialog/nile-dialog.test.d.ts +0 -1
- package/dist/src/nile-dialog/nile-dialog.test.js +104 -126
- package/dist/src/nile-dialog/nile-dialog.test.js.map +1 -1
- package/dist/src/nile-divider/nile-divider.test.d.ts +1 -0
- package/dist/src/nile-divider/nile-divider.test.js +560 -0
- package/dist/src/nile-divider/nile-divider.test.js.map +1 -0
- package/dist/src/nile-drawer/nile-drawer.test.js +106 -86
- package/dist/src/nile-drawer/nile-drawer.test.js.map +1 -1
- package/dist/src/nile-dropdown/nile-dropdown.test.js +104 -148
- package/dist/src/nile-dropdown/nile-dropdown.test.js.map +1 -1
- package/dist/src/nile-empty-state/nile-empty-state.test.js +107 -59
- package/dist/src/nile-empty-state/nile-empty-state.test.js.map +1 -1
- package/dist/src/nile-error-message/nile-error-message.test.js +105 -55
- package/dist/src/nile-error-message/nile-error-message.test.js.map +1 -1
- package/dist/src/nile-error-notification/nile-error-notification.test.d.ts +1 -0
- package/dist/src/nile-error-notification/nile-error-notification.test.js +108 -0
- package/dist/src/nile-error-notification/nile-error-notification.test.js.map +1 -0
- package/dist/src/nile-file-preview/nile-file-preview.css.js +2 -2
- package/dist/src/nile-file-preview/nile-file-preview.css.js.map +1 -1
- package/dist/src/nile-file-preview/nile-file-preview.d.ts +1 -4
- package/dist/src/nile-file-preview/nile-file-preview.js +21 -47
- package/dist/src/nile-file-preview/nile-file-preview.js.map +1 -1
- package/dist/src/nile-file-preview/nile-file-preview.template.d.ts +6 -6
- package/dist/src/nile-file-preview/nile-file-preview.template.js +53 -23
- package/dist/src/nile-file-preview/nile-file-preview.template.js.map +1 -1
- package/dist/src/nile-file-preview/nile-file-preview.test.d.ts +0 -6
- package/dist/src/nile-file-preview/nile-file-preview.test.js +106 -28
- package/dist/src/nile-file-preview/nile-file-preview.test.js.map +1 -1
- package/dist/src/nile-file-preview/utils/nile-file-preview.util.d.ts +3 -2
- package/dist/src/nile-file-preview/utils/nile-file-preview.util.js +32 -7
- package/dist/src/nile-file-preview/utils/nile-file-preview.util.js.map +1 -1
- package/dist/src/nile-file-upload/nile-file-upload.css.js +15 -5
- package/dist/src/nile-file-upload/nile-file-upload.css.js.map +1 -1
- package/dist/src/nile-file-upload/nile-file-upload.d.ts +4 -1
- package/dist/src/nile-file-upload/nile-file-upload.js +13 -1
- package/dist/src/nile-file-upload/nile-file-upload.js.map +1 -1
- package/dist/src/nile-file-upload/nile-file-upload.template.js +19 -15
- package/dist/src/nile-file-upload/nile-file-upload.template.js.map +1 -1
- package/dist/src/nile-file-upload/nile-file-upload.test.d.ts +0 -6
- package/dist/src/nile-file-upload/nile-file-upload.test.js +106 -28
- package/dist/src/nile-file-upload/nile-file-upload.test.js.map +1 -1
- package/dist/src/nile-file-upload/types/file-upload.enums.d.ts +17 -3
- package/dist/src/nile-file-upload/types/file-upload.enums.js +17 -1
- package/dist/src/nile-file-upload/types/file-upload.enums.js.map +1 -1
- package/dist/src/nile-file-upload/utils/drag-drop.util.d.ts +2 -0
- package/dist/src/nile-file-upload/utils/drag-drop.util.js +14 -8
- package/dist/src/nile-file-upload/utils/drag-drop.util.js.map +1 -1
- package/dist/src/nile-file-upload/utils/file-validation.util.js +89 -10
- package/dist/src/nile-file-upload/utils/file-validation.util.js.map +1 -1
- package/dist/src/nile-filter-chip/nile-filter-chip.test.js +102 -77
- package/dist/src/nile-filter-chip/nile-filter-chip.test.js.map +1 -1
- package/dist/src/nile-form-error-message/nile-form-error-message.test.d.ts +1 -0
- package/dist/src/nile-form-error-message/nile-form-error-message.test.js +108 -0
- package/dist/src/nile-form-error-message/nile-form-error-message.test.js.map +1 -0
- package/dist/src/nile-form-group/nile-form-group.test.js +104 -51
- package/dist/src/nile-form-group/nile-form-group.test.js.map +1 -1
- package/dist/src/nile-form-help-text/nile-form-help-text.test.js +104 -84
- package/dist/src/nile-form-help-text/nile-form-help-text.test.js.map +1 -1
- package/dist/src/nile-format-date/nile-format-date.test.d.ts +1 -0
- package/dist/src/nile-format-date/nile-format-date.test.js +108 -0
- package/dist/src/nile-format-date/nile-format-date.test.js.map +1 -0
- package/dist/src/nile-grid/nile-grid-head-item/nile-grid-head-item.js +6 -5
- package/dist/src/nile-grid/nile-grid-head-item/nile-grid-head-item.js.map +1 -1
- package/dist/src/nile-grid/nile-grid-head-item/nile-grid-head-item.utils.d.ts +14 -0
- package/dist/src/nile-grid/nile-grid-head-item/nile-grid-head-item.utils.js +24 -0
- package/dist/src/nile-grid/nile-grid-head-item/nile-grid-head-item.utils.js.map +1 -1
- package/dist/src/nile-grid/nile-grid.d.ts +1 -0
- package/dist/src/nile-grid/nile-grid.js +5 -1
- package/dist/src/nile-grid/nile-grid.js.map +1 -1
- package/dist/src/nile-grid/nile-grid.utils.d.ts +6 -0
- package/dist/src/nile-grid/nile-grid.utils.js +13 -0
- package/dist/src/nile-grid/nile-grid.utils.js.map +1 -1
- package/dist/src/nile-heading/nile-heading.test.d.ts +1 -0
- package/dist/src/nile-heading/nile-heading.test.js +108 -0
- package/dist/src/nile-heading/nile-heading.test.js.map +1 -0
- package/dist/src/nile-hero/nile-hero.test.js +101 -38
- package/dist/src/nile-hero/nile-hero.test.js.map +1 -1
- package/dist/src/nile-icon/nile-icon.test.js +103 -40
- package/dist/src/nile-icon/nile-icon.test.js.map +1 -1
- package/dist/src/nile-icon-button/nile-icon-button.test.d.ts +1 -0
- package/dist/src/nile-icon-button/nile-icon-button.test.js +568 -0
- package/dist/src/nile-icon-button/nile-icon-button.test.js.map +1 -0
- package/dist/src/nile-inline-edit/nile-inline-edit.test.d.ts +1 -0
- package/dist/src/nile-inline-edit/nile-inline-edit.test.js +108 -0
- package/dist/src/nile-inline-edit/nile-inline-edit.test.js.map +1 -0
- package/dist/src/nile-input/nile-input.js +1 -1
- package/dist/src/nile-input/nile-input.js.map +1 -1
- package/dist/src/nile-input/nile-input.test.js +109 -139
- package/dist/src/nile-input/nile-input.test.js.map +1 -1
- package/dist/src/nile-link/nile-link.test.js +103 -67
- package/dist/src/nile-link/nile-link.test.js.map +1 -1
- package/dist/src/nile-list/nile-list.test.d.ts +1 -0
- package/dist/src/nile-list/nile-list.test.js +108 -0
- package/dist/src/nile-list/nile-list.test.js.map +1 -0
- package/dist/src/nile-list-item/nile-list-item.test.d.ts +1 -0
- package/dist/src/nile-list-item/nile-list-item.test.js +108 -0
- package/dist/src/nile-list-item/nile-list-item.test.js.map +1 -0
- package/dist/src/nile-lite-tooltip/nile-lite-tooltip.test.d.ts +2 -0
- package/dist/src/nile-lite-tooltip/nile-lite-tooltip.test.js +109 -0
- package/dist/src/nile-lite-tooltip/nile-lite-tooltip.test.js.map +1 -0
- package/dist/src/nile-loader/nile-loader.test.js +107 -40
- package/dist/src/nile-loader/nile-loader.test.js.map +1 -1
- package/dist/src/nile-menu/nile-menu.test.d.ts +1 -0
- package/dist/src/nile-menu/nile-menu.test.js +113 -0
- package/dist/src/nile-menu/nile-menu.test.js.map +1 -0
- package/dist/src/nile-menu-item/nile-menu-item.test.d.ts +1 -0
- package/dist/src/nile-menu-item/nile-menu-item.test.js +113 -0
- package/dist/src/nile-menu-item/nile-menu-item.test.js.map +1 -0
- package/dist/src/nile-option/nile-option.test.d.ts +1 -0
- package/dist/src/nile-option/nile-option.test.js +108 -0
- package/dist/src/nile-option/nile-option.test.js.map +1 -0
- package/dist/src/nile-option-group/nile-option-group.test.d.ts +1 -0
- package/dist/src/nile-option-group/nile-option-group.test.js +108 -0
- package/dist/src/nile-option-group/nile-option-group.test.js.map +1 -0
- package/dist/src/nile-page-header/nile-page-header.test.d.ts +1 -0
- package/dist/src/nile-page-header/nile-page-header.test.js +108 -0
- package/dist/src/nile-page-header/nile-page-header.test.js.map +1 -0
- package/dist/src/nile-pagination/nile-pagination.test.d.ts +1 -0
- package/dist/src/nile-pagination/nile-pagination.test.js +108 -0
- package/dist/src/nile-pagination/nile-pagination.test.js.map +1 -0
- package/dist/src/nile-popover/nile-popover.test.js +103 -68
- package/dist/src/nile-popover/nile-popover.test.js.map +1 -1
- package/dist/src/nile-popup/nile-popup.test.js +104 -65
- package/dist/src/nile-popup/nile-popup.test.js.map +1 -1
- package/dist/src/nile-progress-bar/nile-progress-bar.test.js +104 -44
- package/dist/src/nile-progress-bar/nile-progress-bar.test.js.map +1 -1
- package/dist/src/nile-radio/nile-radio.test.js +103 -66
- package/dist/src/nile-radio/nile-radio.test.js.map +1 -1
- package/dist/src/nile-radio-group/nile-radio-group.test.d.ts +0 -1
- package/dist/src/nile-radio-group/nile-radio-group.test.js +105 -171
- package/dist/src/nile-radio-group/nile-radio-group.test.js.map +1 -1
- package/dist/src/nile-section-message/nile-section-message.test.d.ts +1 -0
- package/dist/src/nile-section-message/nile-section-message.test.js +108 -0
- package/dist/src/nile-section-message/nile-section-message.test.js.map +1 -0
- package/dist/src/nile-select/nile-select.test.d.ts +0 -5
- package/dist/src/nile-select/nile-select.test.js +105 -244
- package/dist/src/nile-select/nile-select.test.js.map +1 -1
- package/dist/src/nile-skeleton-loader/nile-skeleton-loader.test.d.ts +1 -0
- package/dist/src/nile-skeleton-loader/nile-skeleton-loader.test.js +108 -0
- package/dist/src/nile-skeleton-loader/nile-skeleton-loader.test.js.map +1 -0
- package/dist/src/nile-slide-toggle/nile-slide-toggle.test.js +104 -50
- package/dist/src/nile-slide-toggle/nile-slide-toggle.test.js.map +1 -1
- package/dist/src/nile-slider/nile-slider.test.d.ts +1 -0
- package/dist/src/nile-slider/nile-slider.test.js +108 -0
- package/dist/src/nile-slider/nile-slider.test.js.map +1 -0
- package/dist/src/nile-spinner/nile-spinner.test.d.ts +1 -0
- package/dist/src/nile-spinner/nile-spinner.test.js +569 -0
- package/dist/src/nile-spinner/nile-spinner.test.js.map +1 -0
- package/dist/src/nile-split-panel/nile-split-panel.test.d.ts +1 -0
- package/dist/src/nile-split-panel/nile-split-panel.test.js +108 -0
- package/dist/src/nile-split-panel/nile-split-panel.test.js.map +1 -0
- package/dist/src/nile-stepper/nile-stepper.test.d.ts +2 -0
- package/dist/src/nile-stepper/nile-stepper.test.js +109 -0
- package/dist/src/nile-stepper/nile-stepper.test.js.map +1 -0
- package/dist/src/nile-stepper-item/nile-stepper-item.test.d.ts +1 -0
- package/dist/src/nile-stepper-item/nile-stepper-item.test.js +108 -0
- package/dist/src/nile-stepper-item/nile-stepper-item.test.js.map +1 -0
- package/dist/src/nile-tab/nile-tab.test.d.ts +1 -0
- package/dist/src/nile-tab/nile-tab.test.js +108 -0
- package/dist/src/nile-tab/nile-tab.test.js.map +1 -0
- package/dist/src/nile-tab-group/nile-tab-group.test.js +105 -172
- package/dist/src/nile-tab-group/nile-tab-group.test.js.map +1 -1
- package/dist/src/nile-tab-panel/nile-tab-panel.test.d.ts +1 -0
- package/dist/src/nile-tab-panel/nile-tab-panel.test.js +108 -0
- package/dist/src/nile-tab-panel/nile-tab-panel.test.js.map +1 -0
- package/dist/src/nile-tag/nile-tag.test.d.ts +1 -0
- package/dist/src/nile-tag/nile-tag.test.js +574 -0
- package/dist/src/nile-tag/nile-tag.test.js.map +1 -0
- package/dist/src/nile-textarea/nile-textarea.test.d.ts +1 -1
- package/dist/src/nile-textarea/nile-textarea.test.js +105 -84
- package/dist/src/nile-textarea/nile-textarea.test.js.map +1 -1
- package/dist/src/nile-title/nile-title.test.d.ts +1 -0
- package/dist/src/nile-title/nile-title.test.js +108 -0
- package/dist/src/nile-title/nile-title.test.js.map +1 -0
- package/dist/src/nile-toast/nile-toast.test.d.ts +1 -0
- package/dist/src/nile-toast/nile-toast.test.js +526 -0
- package/dist/src/nile-toast/nile-toast.test.js.map +1 -0
- package/dist/src/nile-toolbar/nile-toolbar.test.d.ts +1 -0
- package/dist/src/nile-toolbar/nile-toolbar.test.js +108 -0
- package/dist/src/nile-toolbar/nile-toolbar.test.js.map +1 -0
- package/dist/src/nile-tooltip/nile-tooltip.test.d.ts +1 -0
- package/dist/src/nile-tooltip/nile-tooltip.test.js +546 -0
- package/dist/src/nile-tooltip/nile-tooltip.test.js.map +1 -0
- package/dist/src/nile-virtual-select/nile-virtual-select.test.d.ts +1 -7
- package/dist/src/nile-virtual-select/nile-virtual-select.test.js +105 -628
- package/dist/src/nile-virtual-select/nile-virtual-select.test.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/rollup.config.js +7 -1
- package/src/nile-accordion/nile-accordian.test.ts +102 -116
- package/src/nile-auto-complete/nile-auto-complete.css.ts +1 -1
- package/src/nile-auto-complete/nile-auto-complete.test.ts +102 -145
- package/src/nile-auto-complete/nile-auto-complete.ts +1 -1
- package/src/nile-avatar/nile-avatar.test.ts +102 -112
- package/src/nile-badge/nile-badge.test.ts +642 -30
- package/src/nile-breadcrumb/nile-breadcrumb.test.ts +107 -0
- package/src/nile-breadcrumb-item/nile-breadcrumb-item.test.ts +106 -0
- package/src/nile-button/nile-button.test.ts +593 -61
- package/src/nile-button-filter/nile-button-filter.test.ts +106 -0
- package/src/nile-button-toggle/nile-button-toggle.test.ts +106 -0
- package/src/nile-button-toggle-group/nile-button-toggle-group.test.ts +104 -126
- package/src/nile-calendar/nile-calendar.test.ts +102 -406
- package/src/nile-card/nile-card.test.ts +103 -71
- package/src/nile-checkbox/nile-checkbox.test.ts +614 -108
- package/src/nile-chip/nile-chip.test.ts +102 -136
- package/src/nile-circular-progressbar/nile-circular-progressbar.test.ts +106 -0
- package/src/nile-date-picker/nile-date-picker.test.ts +106 -0
- package/src/nile-dialog/nile-dialog.test.ts +102 -164
- package/src/nile-divider/nile-divider.test.ts +659 -0
- package/src/nile-drawer/nile-drawer.test.ts +105 -105
- package/src/nile-dropdown/nile-dropdown.test.ts +102 -190
- package/src/nile-empty-state/nile-empty-state.test.ts +104 -67
- package/src/nile-error-message/nile-error-message.test.ts +104 -67
- package/src/nile-error-notification/nile-error-notification.test.ts +106 -0
- package/src/nile-file-preview/nile-file-preview.css.ts +2 -2
- package/src/nile-file-preview/nile-file-preview.template.ts +59 -23
- package/src/nile-file-preview/nile-file-preview.test.ts +105 -37
- package/src/nile-file-preview/nile-file-preview.ts +23 -56
- package/src/nile-file-preview/utils/nile-file-preview.util.ts +37 -8
- package/src/nile-file-upload/nile-file-upload.css.ts +15 -5
- package/src/nile-file-upload/nile-file-upload.template.ts +22 -18
- package/src/nile-file-upload/nile-file-upload.test.ts +105 -37
- package/src/nile-file-upload/nile-file-upload.ts +11 -3
- package/src/nile-file-upload/types/file-upload.enums.ts +20 -4
- package/src/nile-file-upload/utils/drag-drop.util.ts +20 -11
- package/src/nile-file-upload/utils/file-validation.util.ts +104 -22
- package/src/nile-filter-chip/nile-filter-chip.test.ts +103 -89
- package/src/nile-form-error-message/nile-form-error-message.test.ts +106 -0
- package/src/nile-form-group/nile-form-group.test.ts +103 -60
- package/src/nile-form-help-text/nile-form-help-text.test.ts +102 -106
- package/src/nile-format-date/nile-format-date.test.ts +106 -0
- package/src/nile-grid/nile-grid-head-item/nile-grid-head-item.ts +7 -5
- package/src/nile-grid/nile-grid-head-item/nile-grid-head-item.utils.ts +28 -0
- package/src/nile-grid/nile-grid.ts +6 -1
- package/src/nile-grid/nile-grid.utils.ts +18 -1
- package/src/nile-heading/nile-heading.test.ts +106 -0
- package/src/nile-hero/nile-hero.test.ts +103 -42
- package/src/nile-icon/nile-icon.test.ts +103 -50
- package/src/nile-icon-button/nile-icon-button.test.ts +667 -0
- package/src/nile-inline-edit/nile-inline-edit.test.ts +106 -0
- package/src/nile-input/nile-input.test.ts +105 -164
- package/src/nile-input/nile-input.ts +1 -1
- package/src/nile-link/nile-link.test.ts +104 -81
- package/src/nile-list/nile-list.test.ts +106 -0
- package/src/nile-list-item/nile-list-item.test.ts +106 -0
- package/src/nile-lite-tooltip/nile-lite-tooltip.test.ts +107 -0
- package/src/nile-loader/nile-loader.test.ts +103 -48
- package/src/nile-menu/nile-menu.test.ts +106 -0
- package/src/nile-menu-item/nile-menu-item.test.ts +106 -0
- package/src/nile-option/nile-option.test.ts +106 -0
- package/src/nile-option-group/nile-option-group.test.ts +106 -0
- package/src/nile-page-header/nile-page-header.test.ts +106 -0
- package/src/nile-pagination/nile-pagination.test.ts +106 -0
- package/src/nile-popover/nile-popover.test.ts +103 -83
- package/src/nile-popup/nile-popup.test.ts +102 -82
- package/src/nile-progress-bar/nile-progress-bar.test.ts +103 -52
- package/src/nile-radio/nile-radio.test.ts +103 -78
- package/src/nile-radio-group/nile-radio-group.test.ts +104 -213
- package/src/nile-section-message/nile-section-message.test.ts +106 -0
- package/src/nile-select/nile-select.test.ts +105 -308
- package/src/nile-skeleton-loader/nile-skeleton-loader.test.ts +106 -0
- package/src/nile-slide-toggle/nile-slide-toggle.test.ts +103 -58
- package/src/nile-slider/nile-slider.test.ts +106 -0
- package/src/nile-spinner/nile-spinner.test.ts +668 -0
- package/src/nile-split-panel/nile-split-panel.test.ts +106 -0
- package/src/nile-stepper/nile-stepper.test.ts +107 -0
- package/src/nile-stepper-item/nile-stepper-item.test.ts +106 -0
- package/src/nile-tab/nile-tab.test.ts +106 -0
- package/src/nile-tab-group/nile-tab-group.test.ts +104 -211
- package/src/nile-tab-panel/nile-tab-panel.test.ts +106 -0
- package/src/nile-tag/nile-tag.test.ts +675 -0
- package/src/nile-textarea/nile-textarea.test.ts +104 -100
- package/src/nile-title/nile-title.test.ts +106 -0
- package/src/nile-toast/nile-toast.test.ts +625 -0
- package/src/nile-toolbar/nile-toolbar.test.ts +106 -0
- package/src/nile-tooltip/nile-tooltip.test.ts +645 -0
- package/src/nile-virtual-select/nile-virtual-select.test.ts +104 -772
- package/vscode-html-custom-data.json +8 -3
- package/web-test-runner.config.mjs +4 -2
- package/dist/axe.min-2720cd56.esm.js +0 -1
- package/dist/axe.min-69d47269.cjs.js +0 -2
- package/dist/axe.min-69d47269.cjs.js.map +0 -1
- package/dist/css-tag-bb10c0fa.cjs.js +0 -6
- package/dist/css-tag-bb10c0fa.cjs.js.map +0 -1
- package/dist/css-tag-dc564feb.esm.js +0 -6
- package/dist/fixture-958445f8.cjs.js +0 -395
- package/dist/fixture-958445f8.cjs.js.map +0 -1
- package/dist/fixture-985bba12.esm.js +0 -569
- package/dist/nile-accordion/nile-accordian.test.cjs.js +0 -2
- package/dist/nile-accordion/nile-accordian.test.cjs.js.map +0 -1
- package/dist/nile-accordion/nile-accordian.test.esm.js +0 -1
- package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +0 -2
- package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js.map +0 -1
- package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +0 -9
- package/dist/nile-avatar/nile-avatar.test.cjs.js +0 -2
- package/dist/nile-avatar/nile-avatar.test.cjs.js.map +0 -1
- package/dist/nile-avatar/nile-avatar.test.esm.js +0 -11
- package/dist/nile-badge/nile-badge.test.cjs.js +0 -2
- package/dist/nile-badge/nile-badge.test.cjs.js.map +0 -1
- package/dist/nile-badge/nile-badge.test.esm.js +0 -1
- package/dist/nile-button/nile-button.test.cjs.js +0 -2
- package/dist/nile-button/nile-button.test.cjs.js.map +0 -1
- package/dist/nile-button/nile-button.test.esm.js +0 -4
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js +0 -2
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js.map +0 -1
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.esm.js +0 -49
- package/dist/nile-calendar/nile-calendar.test.cjs.js +0 -2
- package/dist/nile-calendar/nile-calendar.test.cjs.js.map +0 -1
- package/dist/nile-calendar/nile-calendar.test.esm.js +0 -11
- package/dist/nile-card/nile-card.test.cjs.js +0 -2
- package/dist/nile-card/nile-card.test.cjs.js.map +0 -1
- package/dist/nile-card/nile-card.test.esm.js +0 -51
- package/dist/nile-checkbox/nile-checkbox.test.cjs.js +0 -2
- package/dist/nile-checkbox/nile-checkbox.test.cjs.js.map +0 -1
- package/dist/nile-checkbox/nile-checkbox.test.esm.js +0 -17
- package/dist/nile-chip/nile-chip.test.cjs.js +0 -2
- package/dist/nile-chip/nile-chip.test.cjs.js.map +0 -1
- package/dist/nile-chip/nile-chip.test.esm.js +0 -1
- package/dist/nile-dialog/nile-dialog.test.cjs.js +0 -2
- package/dist/nile-dialog/nile-dialog.test.cjs.js.map +0 -1
- package/dist/nile-dialog/nile-dialog.test.esm.js +0 -7
- package/dist/nile-drawer/nile-drawer.test.cjs.js +0 -2
- package/dist/nile-drawer/nile-drawer.test.cjs.js.map +0 -1
- package/dist/nile-drawer/nile-drawer.test.esm.js +0 -17
- package/dist/nile-dropdown/nile-dropdown.test.cjs.js +0 -2
- package/dist/nile-dropdown/nile-dropdown.test.cjs.js.map +0 -1
- package/dist/nile-dropdown/nile-dropdown.test.esm.js +0 -28
- package/dist/nile-empty-state/nile-empty-state.test.cjs.js +0 -2
- package/dist/nile-empty-state/nile-empty-state.test.cjs.js.map +0 -1
- package/dist/nile-empty-state/nile-empty-state.test.esm.js +0 -9
- package/dist/nile-error-message/nile-error-message.test.cjs.js +0 -2
- package/dist/nile-error-message/nile-error-message.test.cjs.js.map +0 -1
- package/dist/nile-error-message/nile-error-message.test.esm.js +0 -1
- package/dist/nile-file-preview/nile-file-preview.test.cjs.js +0 -2
- package/dist/nile-file-preview/nile-file-preview.test.cjs.js.map +0 -1
- package/dist/nile-file-preview/nile-file-preview.test.esm.js +0 -1
- package/dist/nile-file-upload/nile-file-upload.test.cjs.js +0 -2
- package/dist/nile-file-upload/nile-file-upload.test.cjs.js.map +0 -1
- package/dist/nile-file-upload/nile-file-upload.test.esm.js +0 -1
- package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js +0 -2
- package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js.map +0 -1
- package/dist/nile-filter-chip/nile-filter-chip.test.esm.js +0 -20
- package/dist/nile-form-group/nile-form-group.test.cjs.js +0 -2
- package/dist/nile-form-group/nile-form-group.test.cjs.js.map +0 -1
- package/dist/nile-form-group/nile-form-group.test.esm.js +0 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +0 -2
- package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js.map +0 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +0 -1
- package/dist/nile-hero/nile-hero.test.cjs.js +0 -2
- package/dist/nile-hero/nile-hero.test.cjs.js.map +0 -1
- package/dist/nile-hero/nile-hero.test.esm.js +0 -14
- package/dist/nile-icon/nile-icon.test.cjs.js +0 -2
- package/dist/nile-icon/nile-icon.test.cjs.js.map +0 -1
- package/dist/nile-icon/nile-icon.test.esm.js +0 -1
- package/dist/nile-input/nile-input.test.cjs.js +0 -2
- package/dist/nile-input/nile-input.test.cjs.js.map +0 -1
- package/dist/nile-input/nile-input.test.esm.js +0 -17
- package/dist/nile-link/nile-link.test.cjs.js +0 -2
- package/dist/nile-link/nile-link.test.cjs.js.map +0 -1
- package/dist/nile-link/nile-link.test.esm.js +0 -1
- package/dist/nile-loader/nile-loader.test.cjs.js +0 -2
- package/dist/nile-loader/nile-loader.test.cjs.js.map +0 -1
- package/dist/nile-loader/nile-loader.test.esm.js +0 -1
- package/dist/nile-popover/nile-popover.test.cjs.js +0 -2
- package/dist/nile-popover/nile-popover.test.cjs.js.map +0 -1
- package/dist/nile-popover/nile-popover.test.esm.js +0 -21
- package/dist/nile-popup/nile-popup.test.cjs.js +0 -2
- package/dist/nile-popup/nile-popup.test.cjs.js.map +0 -1
- package/dist/nile-popup/nile-popup.test.esm.js +0 -1
- package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js +0 -2
- package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js.map +0 -1
- package/dist/nile-progress-bar/nile-progress-bar.test.esm.js +0 -1
- package/dist/nile-radio/nile-radio.test.cjs.js +0 -2
- package/dist/nile-radio/nile-radio.test.cjs.js.map +0 -1
- package/dist/nile-radio/nile-radio.test.esm.js +0 -1
- package/dist/nile-radio-group/nile-radio-group.test.cjs.js +0 -2
- package/dist/nile-radio-group/nile-radio-group.test.cjs.js.map +0 -1
- package/dist/nile-radio-group/nile-radio-group.test.esm.js +0 -57
- package/dist/nile-select/nile-select.test.cjs.js +0 -2
- package/dist/nile-select/nile-select.test.cjs.js.map +0 -1
- package/dist/nile-select/nile-select.test.esm.js +0 -55
- package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js +0 -2
- package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js.map +0 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.test.esm.js +0 -1
- package/dist/nile-tab-group/nile-tab-group.test.cjs.js +0 -2
- package/dist/nile-tab-group/nile-tab-group.test.cjs.js.map +0 -1
- package/dist/nile-tab-group/nile-tab-group.test.esm.js +0 -65
- package/dist/nile-textarea/nile-textarea.test.cjs.js +0 -2
- package/dist/nile-textarea/nile-textarea.test.cjs.js.map +0 -1
- package/dist/nile-textarea/nile-textarea.test.esm.js +0 -1
- package/dist/nile-virtual-select/nile-virtual-select.test.cjs.js +0 -2
- package/dist/nile-virtual-select/nile-virtual-select.test.cjs.js.map +0 -1
- package/dist/nile-virtual-select/nile-virtual-select.test.esm.js +0 -93
- package/dist/scopedElementsWrapper-31107e48.esm.js +0 -1
- package/dist/scopedElementsWrapper-9b188ea6.cjs.js +0 -2
- package/dist/scopedElementsWrapper-9b188ea6.cjs.js.map +0 -1
- package/dist/sinon-esm-68c8e378.esm.js +0 -1
- package/dist/sinon-esm-97570c13.cjs.js +0 -2
- package/dist/sinon-esm-97570c13.cjs.js.map +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { FileUploadState } from "../types";
|
|
2
2
|
export declare class DragHandler {
|
|
3
3
|
private currentState;
|
|
4
|
+
private isDisabledCallback?;
|
|
4
5
|
private stateChangeCallback?;
|
|
5
6
|
private fileDropCallback?;
|
|
6
7
|
private errorMessageCallback?;
|
|
7
8
|
constructor();
|
|
8
9
|
setErrorMessage(callback: (errorMessage: string) => void): void;
|
|
10
|
+
setIsDisabled(callback: () => boolean): void;
|
|
9
11
|
setValuesInDragHandler(state: FileUploadState): void;
|
|
10
12
|
onFileDrop(callback: (files: File[]) => void): void;
|
|
11
13
|
onStateChange(callback: (state: FileUploadState) => void): void;
|
|
@@ -7,6 +7,9 @@ export class DragHandler {
|
|
|
7
7
|
setErrorMessage(callback) {
|
|
8
8
|
this.errorMessageCallback = callback;
|
|
9
9
|
}
|
|
10
|
+
setIsDisabled(callback) {
|
|
11
|
+
this.isDisabledCallback = callback;
|
|
12
|
+
}
|
|
10
13
|
setValuesInDragHandler(state) {
|
|
11
14
|
this.currentState = state;
|
|
12
15
|
}
|
|
@@ -17,40 +20,43 @@ export class DragHandler {
|
|
|
17
20
|
this.stateChangeCallback = callback;
|
|
18
21
|
}
|
|
19
22
|
setState(state) {
|
|
20
|
-
if (this.currentState === FileUploadState.DISABLED)
|
|
23
|
+
if (this.currentState === FileUploadState.DISABLED || this.isDisabledCallback?.())
|
|
21
24
|
return;
|
|
22
25
|
this.currentState = state;
|
|
23
26
|
this.stateChangeCallback?.(state);
|
|
24
27
|
}
|
|
25
28
|
dragEnter(e) {
|
|
26
29
|
preventDefaultAndStopPropagation(e);
|
|
27
|
-
if (this.currentState === FileUploadState.DISABLED)
|
|
30
|
+
if (this.currentState === FileUploadState.DISABLED || this.isDisabledCallback?.()) {
|
|
28
31
|
return;
|
|
29
|
-
|
|
32
|
+
}
|
|
30
33
|
this.setState(FileUploadState.DRAG);
|
|
31
34
|
}
|
|
32
35
|
dragLeave(e) {
|
|
33
36
|
preventDefaultAndStopPropagation(e);
|
|
34
|
-
if (this.currentState === FileUploadState.DISABLED)
|
|
37
|
+
if (this.currentState === FileUploadState.DISABLED || this.isDisabledCallback?.()) {
|
|
35
38
|
return;
|
|
39
|
+
}
|
|
36
40
|
this.setState(FileUploadState.DEFAULT);
|
|
37
41
|
}
|
|
38
42
|
dragOver(e) {
|
|
39
43
|
preventDefaultAndStopPropagation(e);
|
|
40
|
-
if (this.currentState === FileUploadState.DISABLED)
|
|
44
|
+
if (this.currentState === FileUploadState.DISABLED || this.isDisabledCallback?.()) {
|
|
41
45
|
return;
|
|
46
|
+
}
|
|
42
47
|
}
|
|
43
48
|
drop(e) {
|
|
44
49
|
preventDefaultAndStopPropagation(e);
|
|
45
|
-
if (this.currentState === FileUploadState.DISABLED)
|
|
50
|
+
if (this.currentState === FileUploadState.DISABLED || this.isDisabledCallback?.()) {
|
|
46
51
|
return;
|
|
52
|
+
}
|
|
47
53
|
this.setState(FileUploadState.DEFAULT);
|
|
48
54
|
this.handleFiles(e);
|
|
49
55
|
}
|
|
50
56
|
handleDocumentDrop(e) {
|
|
57
|
+
preventDefaultAndStopPropagation(e);
|
|
51
58
|
if (this.currentState === FileUploadState.DISABLED)
|
|
52
59
|
return;
|
|
53
|
-
preventDefaultAndStopPropagation(e);
|
|
54
60
|
this.setState(FileUploadState.DEFAULT);
|
|
55
61
|
}
|
|
56
62
|
preventDragOver(e) {
|
|
@@ -61,7 +67,7 @@ export class DragHandler {
|
|
|
61
67
|
}
|
|
62
68
|
handleFiles(e) {
|
|
63
69
|
preventDefaultAndStopPropagation(e);
|
|
64
|
-
if (this.currentState === FileUploadState.DISABLED)
|
|
70
|
+
if (this.currentState === FileUploadState.DISABLED || this.isDisabledCallback?.())
|
|
65
71
|
return;
|
|
66
72
|
let files = null;
|
|
67
73
|
if ('dataTransfer' in e && e.dataTransfer) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drag-drop.util.js","sourceRoot":"","sources":["../../../../src/nile-file-upload/utils/drag-drop.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,OAAO,WAAW;
|
|
1
|
+
{"version":3,"file":"drag-drop.util.js","sourceRoot":"","sources":["../../../../src/nile-file-upload/utils/drag-drop.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,OAAO,WAAW;IAQtB;QAPQ,iBAAY,GAAoB,eAAe,CAAC,OAAO,CAAC;IAOjD,CAAC;IAET,eAAe,CAAC,QAAwC;QAC7D,IAAI,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AAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACzB,CAAC;QAED,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAEnC,IAAI,CAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;QAED,IAAG,CAAC,CAAC,MAAM,YAAY,gBAAgB,EAAE,CAAC;YACxC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;CACF","sourcesContent":["import { preventDefaultAndStopPropagation } from \"./file-validation.util\";\nimport { FileUploadState } from \"../types\";\n\nexport class DragHandler {\n private currentState: FileUploadState = FileUploadState.DEFAULT;\n private isDisabledCallback?: () => boolean;\n\n private stateChangeCallback?: (state: FileUploadState) => void;\n private fileDropCallback?: (files: File[]) => void;\n private errorMessageCallback?: (errorMessage: string) => void;\n\n constructor() {}\n\n public setErrorMessage(callback: (errorMessage: string) => void): void {\n this.errorMessageCallback = callback;\n }\n\n public setIsDisabled(callback: () => boolean): void {\n this.isDisabledCallback = callback;\n }\n\n public setValuesInDragHandler(state: FileUploadState): void {\n this.currentState = state;\n }\n\n public onFileDrop(callback: (files: File[]) => void): void {\n this.fileDropCallback = callback;\n }\n\n public onStateChange(callback: (state: FileUploadState) => void): void {\n this.stateChangeCallback = callback;\n }\n\n private setState(state: FileUploadState): void {\n if (this.currentState === FileUploadState.DISABLED || this.isDisabledCallback?.()) return;\n\n this.currentState = state;\n this.stateChangeCallback?.(state);\n }\n\n public dragEnter(e: DragEvent): void {\n preventDefaultAndStopPropagation(e);\n if (this.currentState === FileUploadState.DISABLED || this.isDisabledCallback?.()) {\n return;\n }\n\n this.setState(FileUploadState.DRAG);\n }\n\n public dragLeave(e: DragEvent): void {\n preventDefaultAndStopPropagation(e);\n if (this.currentState === FileUploadState.DISABLED || this.isDisabledCallback?.()) {\n return;\n }\n \n this.setState(FileUploadState.DEFAULT);\n }\n\n public dragOver(e: DragEvent): void {\n preventDefaultAndStopPropagation(e);\n if (this.currentState === FileUploadState.DISABLED || this.isDisabledCallback?.()) {\n return;\n }\n }\n\n public drop(e: DragEvent): void {\n preventDefaultAndStopPropagation(e);\n if (this.currentState === FileUploadState.DISABLED || this.isDisabledCallback?.()) {\n return;\n }\n \n this.setState(FileUploadState.DEFAULT);\n this.handleFiles(e);\n }\n\n public handleDocumentDrop(e: DragEvent): void {\n preventDefaultAndStopPropagation(e);\n if (this.currentState === FileUploadState.DISABLED) return;\n\n this.setState(FileUploadState.DEFAULT);\n }\n\n public preventDragOver(e: DragEvent): void {\n preventDefaultAndStopPropagation(e); \n }\n\n public preventDrop(e: DragEvent): void {\n preventDefaultAndStopPropagation(e); \n }\n\n public handleFiles(e: Event | DragEvent): void {\n preventDefaultAndStopPropagation(e);\n if (this.currentState === FileUploadState.DISABLED || this.isDisabledCallback?.()) return;\n\n let files: FileList | null = null;\n\n if ('dataTransfer' in e && e.dataTransfer) {\n files = e.dataTransfer.files;\n }\n\n if (!files && e.target instanceof HTMLInputElement) {\n files = e.target.files;\n }\n\n if (files && files.length > 0) {\n const newFiles = Array.from(files);\n\n this.fileDropCallback?.(newFiles);\n }\n\n if(e.target instanceof HTMLInputElement) {\n e.target.value = \"\";\n }\n }\n}\n"]}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import { FileUploadState, FileUploadError, FileUploadEvent } from "../types";
|
|
1
|
+
import { FileUploadState, FileUploadError, FileUploadEvent, FileUploadErrorReason } from "../types";
|
|
2
|
+
import { ErrorType } from "../types";
|
|
2
3
|
export const setUpDragHandler = (nileFileUpload, dragHandler) => {
|
|
4
|
+
dragHandler.setIsDisabled(() => {
|
|
5
|
+
return nileFileUpload.state === FileUploadState.DISABLED;
|
|
6
|
+
});
|
|
3
7
|
dragHandler.onStateChange((newState) => {
|
|
4
8
|
nileFileUpload.state = newState;
|
|
5
9
|
});
|
|
6
10
|
dragHandler.onFileDrop((files) => {
|
|
11
|
+
if (nileFileUpload.state === FileUploadState.DISABLED)
|
|
12
|
+
return;
|
|
13
|
+
nileFileUpload.errorMessage = '';
|
|
7
14
|
const maxSize = parseSize(nileFileUpload.size);
|
|
8
15
|
const uploadedFiles = nileFileUpload.uploadedFiles;
|
|
9
16
|
if (!nileFileUpload.allowMultiple && (uploadedFiles.length + files.length > 1)) {
|
|
10
17
|
nileFileUpload.errorMessage = FileUploadError.MULTIPLE_NOT_ALLOWED;
|
|
11
|
-
console.error(nileFileUpload.errorMessage);
|
|
12
18
|
nileFileUpload.requestUpdate();
|
|
13
19
|
return;
|
|
14
20
|
}
|
|
@@ -36,22 +42,39 @@ export const setUpDragHandler = (nileFileUpload, dragHandler) => {
|
|
|
36
42
|
}
|
|
37
43
|
if (sizeExceeded) {
|
|
38
44
|
nileFileUpload.errorMessage = FileUploadError.SIZE_LIMIT_EXCEEDED;
|
|
39
|
-
|
|
40
|
-
nileFileUpload.
|
|
45
|
+
const sizeExceededFiles = rejectedFiles.filter(file => file.size > maxSize);
|
|
46
|
+
nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_ERROR, {
|
|
47
|
+
detail: {
|
|
48
|
+
files: sizeExceededFiles,
|
|
49
|
+
type: FileUploadErrorReason.SIZE_LIMIT_EXCEEDED,
|
|
50
|
+
errorType: ErrorType.VALIDATION,
|
|
51
|
+
message: FileUploadError.SIZE_LIMIT_EXCEEDED,
|
|
52
|
+
},
|
|
53
|
+
bubbles: true,
|
|
54
|
+
composed: true,
|
|
55
|
+
}));
|
|
41
56
|
nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_SIZE_EXCEED_FILES, {
|
|
42
57
|
detail: { files: rejectedFiles }
|
|
43
58
|
}));
|
|
59
|
+
nileFileUpload.requestUpdate();
|
|
44
60
|
}
|
|
45
61
|
if (duplicatesFound && newFiles.length === 0) {
|
|
46
62
|
nileFileUpload.errorMessage = FileUploadError.DUPLICATES_NOT_ALLOWED;
|
|
47
|
-
console.error(nileFileUpload.errorMessage);
|
|
48
63
|
nileFileUpload.requestUpdate();
|
|
49
64
|
}
|
|
50
|
-
|
|
65
|
+
let updatedFiles = [];
|
|
66
|
+
for (const file of newFiles) {
|
|
67
|
+
if (nileFileUpload.allowedTypes.includes(file.type)) {
|
|
68
|
+
updatedFiles.push(file);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
nileFileUpload.errorMessage = FileUploadError.INVALID_FORMAT;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
nileFileUpload.uploadedFiles = [...uploadedFiles, ...updatedFiles];
|
|
51
75
|
nileFileUpload.requestUpdate();
|
|
52
76
|
});
|
|
53
77
|
dragHandler.setErrorMessage((errorMessage) => {
|
|
54
|
-
console.error(nileFileUpload.errorMessage);
|
|
55
78
|
nileFileUpload.errorMessage = errorMessage;
|
|
56
79
|
});
|
|
57
80
|
};
|
|
@@ -66,6 +89,18 @@ export const addInternalListeners = (nileFileUpload, dragHandler, uploadRequests
|
|
|
66
89
|
nileFileUpload.addEventListener('dragleave', (e) => dragHandler.dragLeave(e));
|
|
67
90
|
nileFileUpload.addEventListener('dragover', (e) => dragHandler.dragOver(e));
|
|
68
91
|
nileFileUpload.addEventListener('drop', (e) => dragHandler.drop(e));
|
|
92
|
+
const clickHandler = nileFileUpload.browseFiles.bind(nileFileUpload);
|
|
93
|
+
const observer = new ResizeObserver(entries => {
|
|
94
|
+
for (const entry of entries) {
|
|
95
|
+
if (entry.contentRect.width < 400) {
|
|
96
|
+
nileFileUpload.horizontalDiv.addEventListener('click', clickHandler);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
nileFileUpload.horizontalDiv.removeEventListener('click', clickHandler);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
observer.observe(nileFileUpload.horizontalDiv);
|
|
69
104
|
cancelFileUpload(nileFileUpload, uploadRequests);
|
|
70
105
|
removeFile(nileFileUpload.uploadedFiles, nileFileUpload);
|
|
71
106
|
};
|
|
@@ -86,6 +121,10 @@ export function uploadFiles(nileFileUpload) {
|
|
|
86
121
|
for (const file of uploadedFiles) {
|
|
87
122
|
if (uploadRequests.has(file))
|
|
88
123
|
continue;
|
|
124
|
+
if (nileFileUpload.doNotUpload.includes(file))
|
|
125
|
+
continue;
|
|
126
|
+
if (file.errorMessage)
|
|
127
|
+
continue;
|
|
89
128
|
const formData = new FormData();
|
|
90
129
|
formData.append('file', file);
|
|
91
130
|
const xhr = new XMLHttpRequest();
|
|
@@ -94,26 +133,55 @@ export function uploadFiles(nileFileUpload) {
|
|
|
94
133
|
xhr.upload.onprogress = (e) => {
|
|
95
134
|
const percent = Math.floor((e.loaded / e.total) * 100);
|
|
96
135
|
nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_UPLOAD_PROGRESS, {
|
|
97
|
-
detail: { file, progress: percent }
|
|
136
|
+
detail: { file, progress: percent },
|
|
137
|
+
bubbles: true,
|
|
138
|
+
composed: true,
|
|
98
139
|
}));
|
|
99
140
|
};
|
|
100
141
|
xhr.onload = () => {
|
|
101
142
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
102
143
|
nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_UPLOAD_SUCCESS, {
|
|
103
|
-
detail: { file, response: xhr.response }
|
|
144
|
+
detail: { file, response: xhr.response },
|
|
145
|
+
bubbles: true,
|
|
146
|
+
composed: true,
|
|
104
147
|
}));
|
|
105
148
|
}
|
|
106
149
|
else {
|
|
107
150
|
nileFileUpload.errorMessage = FileUploadError.SERVER_SIDE_ERROR;
|
|
108
|
-
nileFileUpload.requestUpdate();
|
|
109
151
|
nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.SERVER_SIDE_ERROR, {
|
|
110
152
|
detail: { file, status: xhr.status, response: xhr.response }
|
|
111
153
|
}));
|
|
154
|
+
nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_ERROR, {
|
|
155
|
+
detail: {
|
|
156
|
+
type: FileUploadErrorReason.SERVER_SIDE_ERROR,
|
|
157
|
+
file,
|
|
158
|
+
status: xhr?.status || 0,
|
|
159
|
+
response: xhr?.response,
|
|
160
|
+
message: FileUploadError.SERVER_SIDE_ERROR,
|
|
161
|
+
errorType: ErrorType.SERVER,
|
|
162
|
+
},
|
|
163
|
+
bubbles: true,
|
|
164
|
+
composed: true,
|
|
165
|
+
}));
|
|
166
|
+
nileFileUpload.requestUpdate();
|
|
112
167
|
}
|
|
113
168
|
};
|
|
114
169
|
xhr.onerror = () => {
|
|
115
170
|
uploadRequests.delete(file);
|
|
171
|
+
nileFileUpload.doNotUpload.push(file);
|
|
116
172
|
nileFileUpload.errorMessage = FileUploadError.NETWORK_ERROR;
|
|
173
|
+
nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_ERROR, {
|
|
174
|
+
detail: {
|
|
175
|
+
type: FileUploadErrorReason.NETWORK_ERROR,
|
|
176
|
+
file,
|
|
177
|
+
status: xhr.status,
|
|
178
|
+
response: xhr.response,
|
|
179
|
+
errorType: ErrorType.NETWORK,
|
|
180
|
+
message: FileUploadError.NETWORK_ERROR,
|
|
181
|
+
},
|
|
182
|
+
bubbles: true,
|
|
183
|
+
composed: true,
|
|
184
|
+
}));
|
|
117
185
|
nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_NETWORK_ERROR, {
|
|
118
186
|
detail: { file, status: xhr.status, response: xhr.response },
|
|
119
187
|
bubbles: true,
|
|
@@ -133,6 +201,16 @@ export const cancelFileUpload = (nileFileUpload, uploadRequests) => {
|
|
|
133
201
|
}
|
|
134
202
|
uploadRequests.delete(fileToCancel);
|
|
135
203
|
nileFileUpload.uploadedFiles = nileFileUpload.uploadedFiles.filter(file => file !== fileToCancel);
|
|
204
|
+
nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_ERROR, {
|
|
205
|
+
detail: {
|
|
206
|
+
type: FileUploadErrorReason.UPLOAD_CANCELLED,
|
|
207
|
+
file: fileToCancel,
|
|
208
|
+
message: FileUploadError.UPLOAD_CANCELLED,
|
|
209
|
+
errorType: ErrorType.UPLOAD_CANCELLED,
|
|
210
|
+
},
|
|
211
|
+
bubbles: true,
|
|
212
|
+
composed: true,
|
|
213
|
+
}));
|
|
136
214
|
nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_UPLOAD_CANCELLED, {
|
|
137
215
|
detail: { file: fileToCancel }
|
|
138
216
|
}));
|
|
@@ -154,6 +232,7 @@ export const removeFile = (uploadedFiles, nileFileUpload) => {
|
|
|
154
232
|
const { value } = e.detail;
|
|
155
233
|
uploadedFiles = uploadedFiles.filter(file => file !== value);
|
|
156
234
|
nileFileUpload.uploadedFiles = uploadedFiles;
|
|
235
|
+
nileFileUpload.errorMessage = '';
|
|
157
236
|
nileFileUpload.requestUpdate();
|
|
158
237
|
});
|
|
159
238
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-validation.util.js","sourceRoot":"","sources":["../../../../src/nile-file-upload/utils/file-validation.util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,cAA8B,EAC9B,WAAwB,EAClB,EAAE;IACR,WAAW,CAAC,aAAa,CAAC,CAAC,QAAyB,EAAE,EAAE;QACtD,cAAc,CAAC,KAAK,GAAG,QAAQ,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,WAAW,CAAC,UAAU,CAAC,CAAC,KAAa,EAAE,EAAE;QACvC,MAAM,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,aAAa,GAAG,cAAc,CAAC,aAAa,CAAC;QAEnD,IAAI,CAAC,cAAc,CAAC,aAAa,IAAI,CAAC,aAAa,CAAC,MAAM,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AC,MAAM,CAAC;QAC3B,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC;QAC7D,cAAc,CAAC,aAAa,GAAG,aAAa,CAAC;QAC7C,cAAc,CAAC,aAAa,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,cAA8B,EAAQ,EAAE;IACrE,IAAG,cAAc,CAAC,OAAO,KAAK,UAAU,IAAI,cAAc,CAAC,YAAY,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACpF,cAAc,CAAC,iBAAiB,GAAG,IAAI,CAAC;QACxC,cAAc,CAAC,aAAa,EAAE,CAAC;IACjC,CAAC;SAAM,IAAG,cAAc,CAAC,OAAO,KAAK,YAAY,IAAI,cAAc,CAAC,YAAY,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QAC7F,cAAc,CAAC,iBAAiB,GAAG,IAAI,CAAC;QACxC,cAAc,CAAC,aAAa,EAAE,CAAC;IACjC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { DragHandler } from \"./drag-drop.util\";\nimport { FileUploadState, FileUploadError, FileUploadEvent } from \"../types\";\nimport { NileFileUpload } from \"../nile-file-upload\";\nimport { RemoveFileDetail } from \"../../nile-file-preview/types\";\n\nexport const setUpDragHandler = (\n nileFileUpload: NileFileUpload,\n dragHandler: DragHandler,\n): void => {\n dragHandler.onStateChange((newState: FileUploadState) => {\n nileFileUpload.state = newState;\n });\n\n dragHandler.onFileDrop((files: File[]) => {\n const maxSize = parseSize(nileFileUpload.size);\n const uploadedFiles = nileFileUpload.uploadedFiles;\n \n if (!nileFileUpload.allowMultiple && (uploadedFiles.length + files.length > 1)) {\n nileFileUpload.errorMessage = FileUploadError.MULTIPLE_NOT_ALLOWED;\n console.error(nileFileUpload.errorMessage);\n nileFileUpload.requestUpdate();\n return;\n }\n \n let sizeExceeded = false;\n let duplicatesFound = false;\n const newFiles: File[] = [];\n const rejectedFiles: File[] = [];\n \n for (const file of files) {\n if (file.size > maxSize) {\n sizeExceeded = true;\n rejectedFiles.push(file);\n continue;\n }\n \n if (\n !nileFileUpload.allowDuplicates &&\n uploadedFiles.some(\n (uploaded) =>\n uploaded.name === file.name &&\n uploaded.size === file.size &&\n uploaded.type === file.type\n )\n ) {\n duplicatesFound = true;\n rejectedFiles.push(file);\n continue;\n }\n \n if(!rejectedFiles.includes(file)) {\n newFiles.push(file);\n }\n }\n\n if (sizeExceeded) {\n nileFileUpload.errorMessage = FileUploadError.SIZE_LIMIT_EXCEEDED;\n console.error(nileFileUpload.errorMessage);\n nileFileUpload.requestUpdate();\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_SIZE_EXCEED_FILES, {\n detail: { files: rejectedFiles }\n }));\n }\n \n if (duplicatesFound && newFiles.length === 0) {\n nileFileUpload.errorMessage = FileUploadError.DUPLICATES_NOT_ALLOWED;\n console.error(nileFileUpload.errorMessage);\n nileFileUpload.requestUpdate();\n }\n \n nileFileUpload.uploadedFiles = [...uploadedFiles, ...newFiles];\n nileFileUpload.requestUpdate();\n });\n \n\n dragHandler.setErrorMessage((errorMessage: string) => {\n console.error(nileFileUpload.errorMessage);\n nileFileUpload.errorMessage = errorMessage;\n });\n};\n\nexport const addGlobalListeners = (dragHandler: DragHandler): void => {\n document.addEventListener('dragover', dragHandler.preventDragOver, { passive: false });\n document.addEventListener('drop', dragHandler.preventDrop, { passive: false });\n}\n\nexport const addInternalListeners = (nileFileUpload: NileFileUpload, dragHandler: DragHandler, uploadRequests: any): void => {\n nileFileUpload.addEventListener('mouseenter', (e) => handleHoverIn(nileFileUpload.setState, nileFileUpload.state));\n nileFileUpload.addEventListener('mouseleave', (e) => handleHoverOut(nileFileUpload.setState, nileFileUpload.state));\n nileFileUpload.addEventListener('dragenter', (e) => dragHandler.dragEnter(e));\n nileFileUpload.addEventListener('dragleave', (e) => dragHandler.dragLeave(e));\n nileFileUpload.addEventListener('dragover', (e) => dragHandler.dragOver(e));\n nileFileUpload.addEventListener('drop', (e) => dragHandler.drop(e)); \n\n cancelFileUpload(nileFileUpload, uploadRequests);\n removeFile(nileFileUpload.uploadedFiles, nileFileUpload);\n}\n\nexport function handleHoverIn(\n setState: (state: FileUploadState) => void,\n currentState: FileUploadState\n): void {\n if (currentState === FileUploadState.DEFAULT) {\n setState(FileUploadState.HOVER);\n }\n}\n\nexport function handleHoverOut(\n setState: (state: FileUploadState) => void,\n currentState: FileUploadState\n): void {\n if (currentState === FileUploadState.HOVER) {\n setState(FileUploadState.DEFAULT);\n }\n}\n\nexport function uploadFiles(nileFileUpload: NileFileUpload) {\n const { uploadedFiles, fileUploadUrl, uploadRequests } = nileFileUpload;\n if (!fileUploadUrl || !uploadedFiles?.length) return;\n\n for (const file of uploadedFiles) {\n if (uploadRequests.has(file)) continue;\n \n const formData = new FormData();\n formData.append('file', file);\n\n const xhr = new XMLHttpRequest();\n uploadRequests.set(file, xhr);\n\n nileFileUpload.emit(FileUploadEvent.NILE_UPLOADING);\n\n xhr.upload.onprogress = (e) => {\n const percent = Math.floor((e.loaded / e.total) * 100);\n \n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_UPLOAD_PROGRESS, {\n detail: { file, progress: percent }\n }));\n };\n\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_UPLOAD_SUCCESS, {\n detail: { file, response: xhr.response }\n }));\n } else {\n nileFileUpload.errorMessage = FileUploadError.SERVER_SIDE_ERROR;\n nileFileUpload.requestUpdate();\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.SERVER_SIDE_ERROR, {\n detail: { file, status: xhr.status, response: xhr.response }\n }));\n }\n };\n\n xhr.onerror = () => {\n uploadRequests.delete(file);\n nileFileUpload.errorMessage = FileUploadError.NETWORK_ERROR;\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_NETWORK_ERROR, {\n detail: { file, status: xhr.status, response: xhr.response },\n bubbles: true,\n composed: true,\n }));\n };\n\n xhr.open('POST', fileUploadUrl);\n xhr.send(formData);\n }\n}\n\nexport const cancelFileUpload = (nileFileUpload: NileFileUpload, uploadRequests: Map<File, XMLHttpRequest>) => {\n document.addEventListener(FileUploadEvent.NILE_CANCEL_UPLOAD, (e: CustomEvent) => {\n const fileToCancel = e.detail.file;\n const xhr = uploadRequests.get(fileToCancel);\n\n if (xhr) {\n xhr.abort();\n }\n uploadRequests.delete(fileToCancel);\n nileFileUpload.uploadedFiles = nileFileUpload.uploadedFiles.filter(file => file !== fileToCancel);\n\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_UPLOAD_CANCELLED, {\n detail: { file: fileToCancel }\n }));\n });\n};\n\nfunction parseSize(sizeStr: string): number {\n const units = { B: 1, KB: 1024, MB: 1024 ** 2, GB: 1024 ** 3 };\n const num = parseFloat(sizeStr);\n const unit = sizeStr.replace(/[0-9.\\s]/g, '').toUpperCase();\n const multiplier = units[unit as keyof typeof units] || 1;\n return num * multiplier;\n}\n\nexport const preventDefaultAndStopPropagation = (event: Event | DragEvent): void => {\n event.preventDefault?.();\n event.stopPropagation();\n}\n\nexport const removeFile = (uploadedFiles: File[], nileFileUpload: NileFileUpload) => {\n document.addEventListener('nile-remove', (e: CustomEvent<RemoveFileDetail>) => {\n const { value } = e.detail;\n uploadedFiles = uploadedFiles.filter(file => file !== value);\n nileFileUpload.uploadedFiles = uploadedFiles;\n nileFileUpload.requestUpdate();\n });\n}\n\nexport const truncateString = (nileFileUpload: NileFileUpload): void => {\n if(nileFileUpload.variant === 'vertical' && nileFileUpload.errorMessage.length > 34) {\n nileFileUpload.isStringTruncated = true;\n nileFileUpload.requestUpdate();\n } else if(nileFileUpload.variant === 'horizontal' && nileFileUpload.errorMessage.length > 96) {\n nileFileUpload.isStringTruncated = true;\n nileFileUpload.requestUpdate();\n }\n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OAAO,KAAK,UAAU,IAAI,cAAc,CAAC,YAAY,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACpF,cAAc,CAAC,iBAAiB,GAAG,IAAI,CAAC;QACxC,cAAc,CAAC,aAAa,EAAE,CAAC;IACjC,CAAC;SAAM,IAAG,cAAc,CAAC,OAAO,KAAK,YAAY,IAAI,cAAc,CAAC,YAAY,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QAC7F,cAAc,CAAC,iBAAiB,GAAG,IAAI,CAAC;QACxC,cAAc,CAAC,aAAa,EAAE,CAAC;IACjC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { DragHandler } from \"./drag-drop.util\";\nimport { FileUploadState, FileUploadError, FileUploadEvent, FileUploadErrorReason } from \"../types\";\nimport { NileFileUpload } from \"../nile-file-upload\";\nimport { RemoveFileDetail } from \"../../nile-file-preview/types\";\nimport { ErrorType } from \"../types\";\n\nexport const setUpDragHandler = (\n nileFileUpload: NileFileUpload,\n dragHandler: DragHandler,\n): void => {\n dragHandler.setIsDisabled(() => {\n return nileFileUpload.state === FileUploadState.DISABLED;\n });\n\n dragHandler.onStateChange((newState: FileUploadState) => {\n nileFileUpload.state = newState;\n });\n\n dragHandler.onFileDrop((files: File[]) => {\n if (nileFileUpload.state === FileUploadState.DISABLED) return;\n nileFileUpload.errorMessage = '';\n const maxSize = parseSize(nileFileUpload.size);\n const uploadedFiles = nileFileUpload.uploadedFiles;\n\n if (!nileFileUpload.allowMultiple && (uploadedFiles.length + files.length > 1)) {\n nileFileUpload.errorMessage = FileUploadError.MULTIPLE_NOT_ALLOWED;\n nileFileUpload.requestUpdate();\n return;\n }\n\n let sizeExceeded = false;\n let duplicatesFound = false;\n const newFiles: File[] = [];\n const rejectedFiles: File[] = [];\n\n for (const file of files) {\n if (file.size > maxSize) {\n sizeExceeded = true;\n rejectedFiles.push(file);\n continue;\n }\n\n if (\n !nileFileUpload.allowDuplicates &&\n uploadedFiles.some(\n (uploaded) =>\n uploaded.name === file.name &&\n uploaded.size === file.size &&\n uploaded.type === file.type\n )\n ) {\n duplicatesFound = true;\n rejectedFiles.push(file);\n continue;\n }\n\n if(!rejectedFiles.includes(file)) {\n newFiles.push(file);\n }\n }\n\n if (sizeExceeded) {\n nileFileUpload.errorMessage = FileUploadError.SIZE_LIMIT_EXCEEDED;\n const sizeExceededFiles = rejectedFiles.filter(file => file.size > maxSize);\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_ERROR, {\n detail: { \n files: sizeExceededFiles,\n type: FileUploadErrorReason.SIZE_LIMIT_EXCEEDED,\n errorType: ErrorType.VALIDATION,\n message: FileUploadError.SIZE_LIMIT_EXCEEDED,\n },\n bubbles: true,\n composed: true,\n }));\n\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_SIZE_EXCEED_FILES, {\n detail: { files: rejectedFiles }\n }));\n nileFileUpload.requestUpdate();\n }\n\n if (duplicatesFound && newFiles.length === 0) {\n nileFileUpload.errorMessage = FileUploadError.DUPLICATES_NOT_ALLOWED;\n nileFileUpload.requestUpdate();\n }\n\n let updatedFiles = [];\n for (const file of newFiles) {\n if(nileFileUpload.allowedTypes.includes(file.type)) {\n updatedFiles.push(file);\n } else {\n nileFileUpload.errorMessage = FileUploadError.INVALID_FORMAT;\n }\n }\n\n nileFileUpload.uploadedFiles = [...uploadedFiles, ...updatedFiles];\n nileFileUpload.requestUpdate();\n });\n\n\n dragHandler.setErrorMessage((errorMessage: string) => {\n nileFileUpload.errorMessage = errorMessage;\n });\n};\n\nexport const addGlobalListeners = (dragHandler: DragHandler): void => {\n document.addEventListener('dragover', dragHandler.preventDragOver, { passive: false });\n document.addEventListener('drop', dragHandler.preventDrop, { passive: false });\n}\n\nexport const addInternalListeners = (nileFileUpload: NileFileUpload, dragHandler: DragHandler, uploadRequests: any): void => {\n nileFileUpload.addEventListener('mouseenter', (e) => handleHoverIn(nileFileUpload.setState, nileFileUpload.state));\n nileFileUpload.addEventListener('mouseleave', (e) => handleHoverOut(nileFileUpload.setState, nileFileUpload.state));\n nileFileUpload.addEventListener('dragenter', (e) => dragHandler.dragEnter(e));\n nileFileUpload.addEventListener('dragleave', (e) => dragHandler.dragLeave(e));\n nileFileUpload.addEventListener('dragover', (e) => dragHandler.dragOver(e));\n nileFileUpload.addEventListener('drop', (e) => dragHandler.drop(e));\n const clickHandler = nileFileUpload.browseFiles.bind(nileFileUpload);\n\n const observer = new ResizeObserver(entries => {\n for (const entry of entries) {\n if (entry.contentRect.width < 400) {\n nileFileUpload.horizontalDiv.addEventListener('click', clickHandler);\n } else {\n nileFileUpload.horizontalDiv.removeEventListener('click', clickHandler);\n }\n }\n });\n observer.observe(nileFileUpload.horizontalDiv);\n\n cancelFileUpload(nileFileUpload, uploadRequests);\n removeFile(nileFileUpload.uploadedFiles, nileFileUpload);\n}\n\nexport function handleHoverIn(\n setState: (state: FileUploadState) => void,\n currentState: FileUploadState\n): void {\n if (currentState === FileUploadState.DEFAULT) {\n setState(FileUploadState.HOVER);\n }\n}\n\nexport function handleHoverOut(\n setState: (state: FileUploadState) => void,\n currentState: FileUploadState\n): void {\n if (currentState === FileUploadState.HOVER) {\n setState(FileUploadState.DEFAULT);\n }\n}\n\nexport function uploadFiles(nileFileUpload: NileFileUpload) {\n const { uploadedFiles, fileUploadUrl, uploadRequests } = nileFileUpload;\n if (!fileUploadUrl || !uploadedFiles?.length) return;\n\n for (const file of uploadedFiles) {\n if (uploadRequests.has(file)) continue;\n if (nileFileUpload.doNotUpload.includes(file)) continue;\n\n if((file as any).errorMessage) continue;\n\n const formData = new FormData();\n formData.append('file', file);\n\n const xhr = new XMLHttpRequest();\n uploadRequests.set(file, xhr);\n\n nileFileUpload.emit(FileUploadEvent.NILE_UPLOADING);\n\n xhr.upload.onprogress = (e) => {\n const percent = Math.floor((e.loaded / e.total) * 100);\n\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_UPLOAD_PROGRESS, {\n detail: { file, progress: percent },\n bubbles: true,\n composed: true,\n }));\n };\n\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_UPLOAD_SUCCESS, {\n detail: { file, response: xhr.response },\n bubbles: true,\n composed: true,\n }));\n } else {\n nileFileUpload.errorMessage = FileUploadError.SERVER_SIDE_ERROR;\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.SERVER_SIDE_ERROR, {\n detail: { file, status: xhr.status, response: xhr.response }\n }));\n\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_ERROR, {\n detail: { \n type: FileUploadErrorReason.SERVER_SIDE_ERROR, \n file, \n status: xhr?.status || 0, \n response: xhr?.response,\n message: FileUploadError.SERVER_SIDE_ERROR,\n errorType: ErrorType.SERVER,\n },\n bubbles: true,\n composed: true,\n }));\n nileFileUpload.requestUpdate();\n }\n };\n\n xhr.onerror = () => {\n uploadRequests.delete(file);\n nileFileUpload.doNotUpload.push(file);\n nileFileUpload.errorMessage = FileUploadError.NETWORK_ERROR;\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_ERROR, {\n detail: { \n type: FileUploadErrorReason.NETWORK_ERROR,\n file,\n status: xhr.status,\n response: xhr.response,\n errorType: ErrorType.NETWORK,\n message: FileUploadError.NETWORK_ERROR,\n },\n bubbles: true,\n composed: true,\n }));\n\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_NETWORK_ERROR, {\n detail: { file, status: xhr.status, response: xhr.response },\n bubbles: true,\n composed: true,\n }));\n };\n\n xhr.open('POST', fileUploadUrl);\n xhr.send(formData);\n }\n}\n\nexport const cancelFileUpload = (nileFileUpload: NileFileUpload, uploadRequests: Map<File, XMLHttpRequest>) => {\n document.addEventListener(FileUploadEvent.NILE_CANCEL_UPLOAD, (e: CustomEvent) => {\n const fileToCancel = e.detail.file;\n const xhr = uploadRequests.get(fileToCancel);\n\n if (xhr) {\n xhr.abort();\n }\n uploadRequests.delete(fileToCancel);\n nileFileUpload.uploadedFiles = nileFileUpload.uploadedFiles.filter(file => file !== fileToCancel);\n\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_ERROR, {\n detail: { \n type: FileUploadErrorReason.UPLOAD_CANCELLED, \n file: fileToCancel,\n message: FileUploadError.UPLOAD_CANCELLED,\n errorType: ErrorType.UPLOAD_CANCELLED,\n },\n bubbles: true,\n composed: true,\n }));\n\n nileFileUpload.dispatchEvent(new CustomEvent(FileUploadEvent.NILE_UPLOAD_CANCELLED, {\n detail: { file: fileToCancel }\n }));\n });\n};\n\nfunction parseSize(sizeStr: string): number {\n const units = { B: 1, KB: 1024, MB: 1024 ** 2, GB: 1024 ** 3 };\n const num = parseFloat(sizeStr);\n const unit = sizeStr.replace(/[0-9.\\s]/g, '').toUpperCase();\n const multiplier = units[unit as keyof typeof units] || 1;\n return num * multiplier;\n}\n\nexport const preventDefaultAndStopPropagation = (event: Event | DragEvent): void => {\n event.preventDefault?.();\n event.stopPropagation();\n}\n\nexport const removeFile = (uploadedFiles: File[], nileFileUpload: NileFileUpload) => {\n document.addEventListener('nile-remove', (e: CustomEvent<RemoveFileDetail>) => {\n const { value } = e.detail;\n uploadedFiles = uploadedFiles.filter(file => file !== value);\n nileFileUpload.uploadedFiles = uploadedFiles;\n nileFileUpload.errorMessage = '';\n nileFileUpload.requestUpdate();\n });\n}\n\nexport const truncateString = (nileFileUpload: NileFileUpload): void => {\n if(nileFileUpload.variant === 'vertical' && nileFileUpload.errorMessage.length > 34) {\n nileFileUpload.isStringTruncated = true;\n nileFileUpload.requestUpdate();\n } else if(nileFileUpload.variant === 'horizontal' && nileFileUpload.errorMessage.length > 96) {\n nileFileUpload.isStringTruncated = true;\n nileFileUpload.requestUpdate();\n }\n}\n"]}
|
|
@@ -1,80 +1,105 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
2
2
|
import './nile-filter-chip';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
it('
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
it('
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
it('
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
it('
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
it('
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
it('
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
it('
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
it('
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
3
|
+
describe('NileFilterChip', () => {
|
|
4
|
+
it('1. renders', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el).to.exist; });
|
|
5
|
+
it('2. shadow root', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot).to.not.be.null; });
|
|
6
|
+
it('3. tag name', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.tagName.toLowerCase()).to.equal('nile-filter-chip'); });
|
|
7
|
+
it('4. label defaults empty', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.label).to.equal(''); });
|
|
8
|
+
it('5. value defaults empty', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.value).to.equal(''); });
|
|
9
|
+
it('6. viewMoreCount defaults 0', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.viewMoreCount).to.equal(0); });
|
|
10
|
+
it('7. editable defaults false', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.editable).to.be.false; });
|
|
11
|
+
it('8. closable defaults false', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.closable).to.be.false; });
|
|
12
|
+
it('9. icon defaults empty', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.icon).to.equal(''); });
|
|
13
|
+
it('10. removeIcon defaults empty', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.removeIcon).to.equal(''); });
|
|
14
|
+
it('11. active defaults false', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.active).to.be.false; });
|
|
15
|
+
it('12. chip class', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('.chip')).to.exist; });
|
|
16
|
+
it('13. label part', async () => { const el = await fixture(html `<nile-filter-chip label="L"></nile-filter-chip>`); expect(el.shadowRoot.querySelector('[part="label"]')).to.exist; });
|
|
17
|
+
it('14. value part', async () => { const el = await fixture(html `<nile-filter-chip value="V"></nile-filter-chip>`); expect(el.shadowRoot.querySelector('[part="value"]')).to.exist; });
|
|
18
|
+
it('15. label text', async () => { const el = await fixture(html `<nile-filter-chip label="Status"></nile-filter-chip>`); expect(el.shadowRoot.querySelector('[part="label"]').textContent).to.contain('Status'); });
|
|
19
|
+
it('16. value text', async () => { const el = await fixture(html `<nile-filter-chip value="Active"></nile-filter-chip>`); expect(el.shadowRoot.querySelector('[part="value"]').textContent).to.contain('Active'); });
|
|
20
|
+
it('17. label slot', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('slot[name="label"]')).to.exist; });
|
|
21
|
+
it('18. value slot', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('slot[name="value"]')).to.exist; });
|
|
22
|
+
it('19. icon slot', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('slot[name="icon"]')).to.exist; });
|
|
23
|
+
it('20. suffix slot', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('slot[name="suffix"]')).to.exist; });
|
|
24
|
+
it('21. content slot', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('slot[name="content"]')).to.exist; });
|
|
25
|
+
it('22. close icon shown', async () => { const el = await fixture(html `<nile-filter-chip closable></nile-filter-chip>`); expect(el.shadowRoot.querySelector('.close-icon')).to.exist; });
|
|
26
|
+
it('23. no close icon', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('.close-icon')).to.be.null; });
|
|
27
|
+
it('24. badge with viewMoreCount', async () => { const el = await fixture(html `<nile-filter-chip .viewMoreCount=${3}></nile-filter-chip>`); expect(el.shadowRoot.querySelector('nile-badge')).to.exist; });
|
|
28
|
+
it('25. no badge without viewMoreCount', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('nile-badge')).to.be.null; });
|
|
29
|
+
it('26. icon span shown', async () => { const el = await fixture(html `<nile-filter-chip icon="star"></nile-filter-chip>`); expect(el.shadowRoot.querySelector('.icon')).to.exist; });
|
|
30
|
+
it('27. no icon span default', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('.icon')).to.be.null; });
|
|
31
|
+
it('28. active reflected', async () => { const el = await fixture(html `<nile-filter-chip active></nile-filter-chip>`); expect(el.hasAttribute('active')).to.be.true; });
|
|
32
|
+
it('29. nile-click event', async () => { const el = await fixture(html `<nile-filter-chip value="V"></nile-filter-chip>`); let detail; el.addEventListener('nile-click', ((e) => { detail = e.detail; })); el.shadowRoot.querySelector('.chip').dispatchEvent(new Event('click', { bubbles: true })); expect(detail).to.exist; });
|
|
33
|
+
it('30. nile-click detail value', async () => { const el = await fixture(html `<nile-filter-chip value="V"></nile-filter-chip>`); let detail; el.addEventListener('nile-click', ((e) => { detail = e.detail; })); el.shadowRoot.querySelector('.chip').click(); expect(detail.value).to.equal('V'); });
|
|
34
|
+
it('31. dynamic label', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); el.label = 'New'; await el.updateComplete; expect(el.shadowRoot.querySelector('[part="label"]').textContent).to.contain('New'); });
|
|
35
|
+
it('32. dynamic value', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); el.value = 'Val'; await el.updateComplete; expect(el.shadowRoot.querySelector('[part="value"]').textContent).to.contain('Val'); });
|
|
36
|
+
it('33. dynamic closable', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); el.closable = true; await el.updateComplete; expect(el.shadowRoot.querySelector('.close-icon')).to.exist; });
|
|
37
|
+
it('34. dynamic active', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); el.active = true; await el.updateComplete; expect(el.hasAttribute('active')).to.be.true; });
|
|
38
|
+
it('35. label-wrapper class', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('.label-wrapper')).to.exist; });
|
|
39
|
+
it('36. value-wrapper class', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('.value-wrapper')).to.exist; });
|
|
40
|
+
it('37. has styles', async () => { expect((await import('./nile-filter-chip')).NileFilterChip.styles).to.exist; });
|
|
41
|
+
it('38. is defined', async () => { expect(customElements.get('nile-filter-chip')).to.exist; });
|
|
42
|
+
it('39. shadow mode', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.mode).to.equal('open'); });
|
|
43
|
+
it('40. isConnected', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.isConnected).to.be.true; });
|
|
44
|
+
it('41. removal', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); el.remove(); expect(el.isConnected).to.be.false; });
|
|
45
|
+
it('42. outerHTML', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.outerHTML).to.contain('nile-filter-chip'); });
|
|
46
|
+
it('43. matches', async () => { const el = await fixture(html `<nile-filter-chip class="x"></nile-filter-chip>`); expect(el.matches('nile-filter-chip.x')).to.be.true; });
|
|
47
|
+
it('44. closest', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.closest('nile-filter-chip')).to.equal(el); });
|
|
48
|
+
it('45. cloneNode', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.cloneNode(true).tagName.toLowerCase()).to.equal('nile-filter-chip'); });
|
|
49
|
+
it('46. dispatchEvent', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); let f = false; el.addEventListener('c', () => (f = true)); el.dispatchEvent(new Event('c')); expect(f).to.be.true; });
|
|
50
|
+
it('47. updateComplete', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); const r = await el.updateComplete; expect(r).to.not.be.undefined; });
|
|
51
|
+
it('48. requestUpdate', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); el.requestUpdate(); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; });
|
|
52
|
+
it('49. render method', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.render).to.be.a('function'); });
|
|
53
|
+
it('50. shadowRoot host', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.host).to.equal(el); });
|
|
54
|
+
it('51. class attr', async () => { const el = await fixture(html `<nile-filter-chip class="f"></nile-filter-chip>`); expect(el.classList.contains('f')).to.be.true; });
|
|
55
|
+
it('52. id attr', async () => { const el = await fixture(html `<nile-filter-chip id="f1"></nile-filter-chip>`); expect(el.id).to.equal('f1'); });
|
|
56
|
+
it('53. style attr', async () => { const el = await fixture(html `<nile-filter-chip style="color:red"></nile-filter-chip>`); expect(el.style.color).to.equal('red'); });
|
|
57
|
+
it('54. data attr', async () => { const el = await fixture(html `<nile-filter-chip data-x="1"></nile-filter-chip>`); expect(el.getAttribute('data-x')).to.equal('1'); });
|
|
58
|
+
it('55. hidden', async () => { const el = await fixture(html `<nile-filter-chip hidden></nile-filter-chip>`); expect(el.hidden).to.be.true; });
|
|
59
|
+
it('56. dir', async () => { const el = await fixture(html `<nile-filter-chip dir="rtl"></nile-filter-chip>`); expect(el.dir).to.equal('rtl'); });
|
|
60
|
+
it('57. nodeType', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.nodeType).to.equal(1); });
|
|
61
|
+
it('58. multiple instances', async () => { const c = await fixture(html `<div><nile-filter-chip></nile-filter-chip><nile-filter-chip></nile-filter-chip></div>`); expect(c.querySelectorAll('nile-filter-chip').length).to.equal(2); });
|
|
62
|
+
it('59. parent-child', async () => { const c = await fixture(html `<div><nile-filter-chip></nile-filter-chip></div>`); expect(c.querySelector('nile-filter-chip').parentElement).to.equal(c); });
|
|
63
|
+
it('60. localName', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.localName).to.equal('nile-filter-chip'); });
|
|
64
|
+
it('61. namespaceURI', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.namespaceURI).to.equal('http://www.w3.org/1999/xhtml'); });
|
|
65
|
+
it('62. ownerDocument', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.ownerDocument).to.equal(document); });
|
|
66
|
+
it('63. classList add', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); el.classList.add('z'); expect(el.classList.contains('z')).to.be.true; });
|
|
67
|
+
it('64. dataset', async () => { const el = await fixture(html `<nile-filter-chip data-idx="0"></nile-filter-chip>`); expect(el.dataset.idx).to.equal('0'); });
|
|
68
|
+
it('65. getBoundingClientRect', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.getBoundingClientRect()).to.exist; });
|
|
69
|
+
it('66. label type', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(typeof el.label).to.equal('string'); });
|
|
70
|
+
it('67. value type', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(typeof el.value).to.equal('string'); });
|
|
71
|
+
it('68. closable type', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(typeof el.closable).to.equal('boolean'); });
|
|
72
|
+
it('69. editable type', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(typeof el.editable).to.equal('boolean'); });
|
|
73
|
+
it('70. active type', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(typeof el.active).to.equal('boolean'); });
|
|
74
|
+
it('71. viewMoreCount type', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(typeof el.viewMoreCount).to.equal('number'); });
|
|
75
|
+
it('72. close icon nile-icon', async () => { const el = await fixture(html `<nile-filter-chip closable></nile-filter-chip>`); expect(el.shadowRoot.querySelector('.close-icon nile-icon')).to.exist; });
|
|
76
|
+
it('73. badge-wrapper class', async () => { const el = await fixture(html `<nile-filter-chip .viewMoreCount=${2}></nile-filter-chip>`); expect(el.shadowRoot.querySelector('.badge-wrapper')).to.exist; });
|
|
77
|
+
it('74. badge part', async () => { const el = await fixture(html `<nile-filter-chip .viewMoreCount=${2}></nile-filter-chip>`); expect(el.shadowRoot.querySelector('[part="badge"]')).to.exist; });
|
|
78
|
+
it('75. badge text', async () => { const el = await fixture(html `<nile-filter-chip .viewMoreCount=${5}></nile-filter-chip>`); expect(el.shadowRoot.textContent).to.contain('+5'); });
|
|
79
|
+
it('76. aria-label', async () => { const el = await fixture(html `<nile-filter-chip aria-label="Filter"></nile-filter-chip>`); expect(el.getAttribute('aria-label')).to.equal('Filter'); });
|
|
80
|
+
it('77. role', async () => { const el = await fixture(html `<nile-filter-chip role="button"></nile-filter-chip>`); expect(el.getAttribute('role')).to.equal('button'); });
|
|
81
|
+
it('78. createElement', async () => { const el = document.createElement('nile-filter-chip'); document.body.appendChild(el); await el.updateComplete; expect(el.shadowRoot).to.not.be.null; document.body.removeChild(el); });
|
|
82
|
+
it('79. title attr', async () => { const el = await fixture(html `<nile-filter-chip title="F"></nile-filter-chip>`); expect(el.title).to.equal('F'); });
|
|
83
|
+
it('80. lang attr', async () => { const el = await fixture(html `<nile-filter-chip lang="en"></nile-filter-chip>`); expect(el.lang).to.equal('en'); });
|
|
84
|
+
it('81. tabindex', async () => { const el = await fixture(html `<nile-filter-chip tabindex="0"></nile-filter-chip>`); expect(el.getAttribute('tabindex')).to.equal('0'); });
|
|
85
|
+
it('82. no form', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('form')).to.be.null; });
|
|
86
|
+
it('83. no anchor', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('a')).to.be.null; });
|
|
87
|
+
it('84. no img', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.querySelector('img')).to.be.null; });
|
|
88
|
+
it('85. shadow childNodes', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.shadowRoot.childNodes.length).to.be.greaterThan(0); });
|
|
89
|
+
it('86. scrollIntoView', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.scrollIntoView).to.be.a('function'); });
|
|
90
|
+
it('87. focus method', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.focus).to.be.a('function'); });
|
|
91
|
+
it('88. blur method', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); expect(el.blur).to.be.a('function'); });
|
|
92
|
+
it('89. dispatchCustomEvent', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); let d; el.addEventListener('t', ((e) => { d = e.detail; })); el.dispatchEvent(new CustomEvent('t', { detail: 'x' })); expect(d).to.equal('x'); });
|
|
93
|
+
it('90. label colon', async () => { const el = await fixture(html `<nile-filter-chip label="Status"></nile-filter-chip>`); expect(el.shadowRoot.querySelector('[part="label"]').textContent).to.contain(':'); });
|
|
94
|
+
it('91. dynamic viewMoreCount', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); el.viewMoreCount = 5; await el.updateComplete; expect(el.shadowRoot.querySelector('nile-badge')).to.exist; });
|
|
95
|
+
it('92. removeIcon applies', async () => { const el = await fixture(html `<nile-filter-chip closable removeIcon="trash"></nile-filter-chip>`); const icon = el.shadowRoot.querySelector('.close-icon nile-icon'); expect(icon.getAttribute('name')).to.equal('trash'); });
|
|
96
|
+
it('93. close icon size', async () => { const el = await fixture(html `<nile-filter-chip closable></nile-filter-chip>`); const icon = el.shadowRoot.querySelector('.close-icon nile-icon'); expect(icon.getAttribute('size')).to.equal('12'); });
|
|
97
|
+
it('94. dynamic icon', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); el.icon = 'star'; await el.updateComplete; expect(el.shadowRoot.querySelector('.icon')).to.exist; });
|
|
98
|
+
it('95. slotted label', async () => { const el = await fixture(html `<nile-filter-chip><span slot="label">Custom</span></nile-filter-chip>`); expect(el.querySelector('[slot="label"]')).to.exist; });
|
|
99
|
+
it('96. slotted value', async () => { const el = await fixture(html `<nile-filter-chip><span slot="value">Custom</span></nile-filter-chip>`); expect(el.querySelector('[slot="value"]')).to.exist; });
|
|
100
|
+
it('97. slotted icon', async () => { const el = await fixture(html `<nile-filter-chip><nile-icon slot="icon" name="star"></nile-icon></nile-filter-chip>`); expect(el.querySelector('[slot="icon"]')).to.exist; });
|
|
101
|
+
it('98. rapid prop changes', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); el.label = 'A'; el.value = 'B'; el.closable = true; await el.updateComplete; expect(el.shadowRoot.querySelector('.close-icon')).to.exist; });
|
|
102
|
+
it('99. re-renders', async () => { const el = await fixture(html `<nile-filter-chip></nile-filter-chip>`); el.label = 'A'; await el.updateComplete; el.label = 'B'; await el.updateComplete; expect(el.shadowRoot.querySelector('[part="label"]').textContent).to.contain('B'); });
|
|
103
|
+
it('100. full integration', async () => { const el = await fixture(html `<nile-filter-chip label="Status" value="Active" closable .viewMoreCount=${3} active class="f" id="f1"></nile-filter-chip>`); expect(el.label).to.equal('Status'); expect(el.value).to.equal('Active'); expect(el.closable).to.be.true; expect(el.viewMoreCount).to.equal(3); expect(el.active).to.be.true; expect(el.id).to.equal('f1'); expect(el.shadowRoot.querySelector('.close-icon')).to.exist; expect(el.shadowRoot.querySelector('nile-badge')).to.exist; });
|
|
79
104
|
});
|
|
80
105
|
//# sourceMappingURL=nile-filter-chip.test.js.map
|