@designbasekorea/ui-wc 0.2.0 → 0.2.2
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 +322 -29
- package/dist/esm/components/animation-background/canvas-controller.js +1 -0
- package/dist/esm/components/animation-background/layers.js +1 -0
- package/dist/esm/components/animation-background/lumina-presets.js +1 -0
- package/dist/esm/components/animation-background/lumina-shaders.js +1 -0
- package/dist/esm/components/animation-background/lumina-utils.js +1 -0
- package/dist/esm/components/animation-background/particle-defaults.js +1 -0
- package/dist/esm/components/animation-background/renderers.js +1 -0
- package/dist/esm/components/animation-background/shader-controller.js +1 -0
- package/dist/esm/components/color-picker-utils.js +1 -0
- package/dist/esm/components/date-picker-utils.js +1 -0
- package/dist/esm/components/db-accordion.d.ts +40 -0
- package/dist/esm/components/db-accordion.js +1 -0
- package/dist/esm/components/db-ad-banner.d.ts +41 -0
- package/dist/esm/components/db-ad-banner.js +1 -0
- package/dist/esm/components/db-alert.d.ts +24 -0
- package/dist/esm/components/db-alert.js +1 -0
- package/dist/esm/components/db-animation-background.d.ts +20 -0
- package/dist/esm/components/db-animation-background.js +1 -0
- package/dist/esm/components/db-animation-text.d.ts +32 -0
- package/dist/esm/components/db-animation-text.js +1 -0
- package/dist/esm/components/db-app-badge.d.ts +20 -0
- package/dist/esm/components/db-app-badge.js +1 -0
- package/dist/esm/components/db-audio-player.d.ts +82 -0
- package/dist/esm/components/db-audio-player.js +1 -0
- package/dist/esm/components/db-avatar.d.ts +18 -0
- package/dist/esm/components/db-avatar.js +1 -0
- package/dist/esm/components/db-backdrop.d.ts +24 -0
- package/dist/esm/components/db-backdrop.js +1 -0
- package/dist/esm/components/db-badge.d.ts +27 -0
- package/dist/esm/components/db-badge.js +1 -0
- package/dist/esm/components/db-banner.d.ts +28 -0
- package/dist/esm/components/db-banner.js +1 -0
- package/dist/esm/components/db-bottom-navigation.d.ts +29 -0
- package/dist/esm/components/db-bottom-navigation.js +1 -0
- package/dist/esm/components/db-bottom-sheet.d.ts +49 -0
- package/dist/esm/components/db-bottom-sheet.js +1 -0
- package/dist/esm/components/db-breadcrumbs.d.ts +24 -0
- package/dist/esm/components/db-breadcrumbs.js +1 -0
- package/dist/esm/components/db-button.d.ts +57 -0
- package/dist/esm/components/db-button.js +1 -0
- package/dist/esm/components/db-calendar.d.ts +78 -0
- package/dist/esm/components/db-calendar.js +1 -0
- package/dist/esm/components/db-card.d.ts +42 -0
- package/dist/esm/components/db-card.js +1 -0
- package/dist/esm/components/db-carousel.d.ts +35 -0
- package/dist/esm/components/db-carousel.js +1 -0
- package/dist/esm/components/db-checkbox.d.ts +35 -0
- package/dist/esm/components/db-checkbox.js +1 -0
- package/dist/esm/components/db-chip.d.ts +14 -0
- package/dist/esm/components/db-chip.js +1 -0
- package/dist/esm/components/db-code-block.d.ts +28 -0
- package/dist/esm/components/db-code-block.js +1 -0
- package/dist/esm/components/db-color-picker.d.ts +83 -0
- package/dist/esm/components/db-color-picker.js +1 -0
- package/dist/esm/components/db-confirm.d.ts +23 -0
- package/dist/esm/components/db-confirm.js +1 -0
- package/dist/esm/components/db-container.d.ts +13 -0
- package/dist/esm/components/db-container.js +1 -0
- package/dist/esm/components/db-context-menu.d.ts +46 -0
- package/dist/esm/components/db-context-menu.js +1 -0
- package/dist/esm/components/db-countdown.d.ts +23 -0
- package/dist/esm/components/db-countdown.js +1 -0
- package/dist/esm/components/db-cursor-follower.d.ts +32 -0
- package/dist/esm/components/db-cursor-follower.js +1 -0
- package/dist/esm/components/db-date-picker.d.ts +84 -0
- package/dist/esm/components/db-date-picker.js +1 -0
- package/dist/esm/components/db-divider.d.ts +13 -0
- package/dist/esm/components/db-divider.js +1 -0
- package/dist/esm/components/db-drawer.d.ts +32 -0
- package/dist/esm/components/db-drawer.js +1 -0
- package/dist/esm/components/db-dropdown.d.ts +70 -0
- package/dist/esm/components/db-dropdown.js +1 -0
- package/dist/esm/components/db-dropzone.d.ts +29 -0
- package/dist/esm/components/db-dropzone.js +1 -0
- package/dist/esm/components/db-empty-state.d.ts +14 -0
- package/dist/esm/components/db-empty-state.js +1 -0
- package/dist/esm/components/db-file-uploader.d.ts +27 -0
- package/dist/esm/components/db-file-uploader.js +1 -0
- package/dist/esm/components/db-floating-action-button.d.ts +24 -0
- package/dist/esm/components/db-floating-action-button.js +1 -0
- package/dist/esm/components/db-form.d.ts +94 -0
- package/dist/esm/components/db-form.js +1 -0
- package/dist/esm/components/db-gradient.d.ts +26 -0
- package/dist/esm/components/db-gradient.js +1 -0
- package/dist/esm/components/db-grid.d.ts +20 -0
- package/dist/esm/components/db-grid.js +1 -0
- package/dist/esm/components/db-icons.js +1 -0
- package/dist/esm/components/db-image-list.d.ts +35 -0
- package/dist/esm/components/db-image-list.js +1 -0
- package/dist/esm/components/db-image-placeholder.d.ts +16 -0
- package/dist/esm/components/db-image-placeholder.js +1 -0
- package/dist/esm/components/db-image.d.ts +34 -0
- package/dist/esm/components/db-image.js +1 -0
- package/dist/esm/components/db-indicator.d.ts +46 -0
- package/dist/esm/components/db-indicator.js +1 -0
- package/dist/esm/components/db-input.d.ts +51 -0
- package/dist/esm/components/db-input.js +1 -0
- package/dist/esm/components/db-label.d.ts +13 -0
- package/dist/esm/components/db-label.js +1 -0
- package/dist/esm/components/db-lightbox.d.ts +52 -0
- package/dist/esm/components/db-lightbox.js +1 -0
- package/dist/esm/components/db-list.d.ts +46 -0
- package/dist/esm/components/db-list.js +1 -0
- package/dist/esm/components/db-logo-svg.js +1 -0
- package/dist/esm/components/db-logo.d.ts +15 -0
- package/dist/esm/components/db-logo.js +1 -0
- package/dist/esm/components/db-lottie.d.ts +20 -0
- package/dist/esm/components/db-lottie.js +1 -0
- package/dist/esm/components/db-markdown-editor.d.ts +53 -0
- package/dist/esm/components/db-markdown-editor.js +1 -0
- package/dist/esm/components/db-marquee.d.ts +34 -0
- package/dist/esm/components/db-marquee.js +1 -0
- package/dist/esm/components/db-masonry.d.ts +24 -0
- package/dist/esm/components/db-masonry.js +1 -0
- package/dist/esm/components/db-menu-item.d.ts +30 -0
- package/dist/esm/components/db-menu-item.js +1 -0
- package/dist/esm/components/db-modal.d.ts +63 -0
- package/dist/esm/components/db-modal.js +1 -0
- package/dist/esm/components/db-navbar.d.ts +57 -0
- package/dist/esm/components/db-navbar.js +1 -0
- package/dist/esm/components/db-onboarding-modal.d.ts +57 -0
- package/dist/esm/components/db-onboarding-modal.js +1 -0
- package/dist/esm/components/db-page-header.d.ts +33 -0
- package/dist/esm/components/db-page-header.js +1 -0
- package/dist/esm/components/db-pagination.d.ts +25 -0
- package/dist/esm/components/db-pagination.js +1 -0
- package/dist/esm/components/db-popover.d.ts +62 -0
- package/dist/esm/components/db-popover.js +1 -0
- package/dist/esm/components/db-progress-step.d.ts +28 -0
- package/dist/esm/components/db-progress-step.js +1 -0
- package/dist/esm/components/db-progress.d.ts +15 -0
- package/dist/esm/components/db-progress.js +1 -0
- package/dist/esm/components/db-progressbar.d.ts +13 -0
- package/dist/esm/components/db-progressbar.js +1 -0
- package/dist/esm/components/db-radio.d.ts +34 -0
- package/dist/esm/components/db-radio.js +1 -0
- package/dist/esm/components/db-random-gradient.d.ts +24 -0
- package/dist/esm/components/db-random-gradient.js +1 -0
- package/dist/esm/components/db-range-slider.d.ts +64 -0
- package/dist/esm/components/db-range-slider.js +1 -0
- package/dist/esm/components/db-rating.d.ts +31 -0
- package/dist/esm/components/db-rating.js +1 -0
- package/dist/esm/components/db-reorder.d.ts +38 -0
- package/dist/esm/components/db-reorder.js +1 -0
- package/dist/esm/components/db-resizable-panels.d.ts +42 -0
- package/dist/esm/components/db-resizable-panels.js +1 -0
- package/dist/esm/components/db-scroll-area.d.ts +23 -0
- package/dist/esm/components/db-scroll-area.js +1 -0
- package/dist/esm/components/db-search-bar.d.ts +53 -0
- package/dist/esm/components/db-search-bar.js +1 -0
- package/dist/esm/components/db-section-app-download.d.ts +32 -0
- package/dist/esm/components/db-section-app-download.js +1 -0
- package/dist/esm/components/db-section-contact.d.ts +22 -0
- package/dist/esm/components/db-section-contact.js +1 -0
- package/dist/esm/components/db-section-feature.d.ts +34 -0
- package/dist/esm/components/db-section-feature.js +1 -0
- package/dist/esm/components/db-section-hero.d.ts +34 -0
- package/dist/esm/components/db-section-hero.js +1 -0
- package/dist/esm/components/db-section.d.ts +44 -0
- package/dist/esm/components/db-section.js +1 -0
- package/dist/esm/components/db-segment-control.d.ts +41 -0
- package/dist/esm/components/db-segment-control.js +1 -0
- package/dist/esm/components/db-select.d.ts +66 -0
- package/dist/esm/components/db-select.js +1 -0
- package/dist/esm/components/db-share-icons.js +1 -0
- package/dist/esm/components/db-share.d.ts +48 -0
- package/dist/esm/components/db-share.js +1 -0
- package/dist/esm/components/db-sidebar.d.ts +59 -0
- package/dist/esm/components/db-sidebar.js +1 -0
- package/dist/esm/components/db-skeleton.d.ts +13 -0
- package/dist/esm/components/db-skeleton.js +1 -0
- package/dist/esm/components/db-spinner.d.ts +27 -0
- package/dist/esm/components/db-spinner.js +1 -0
- package/dist/esm/components/db-split-view.d.ts +33 -0
- package/dist/esm/components/db-split-view.js +1 -0
- package/dist/esm/components/db-stack.d.ts +13 -0
- package/dist/esm/components/db-stack.js +1 -0
- package/dist/esm/components/db-stat.d.ts +26 -0
- package/dist/esm/components/db-stat.js +1 -0
- package/dist/esm/components/db-stepper.d.ts +49 -0
- package/dist/esm/components/db-stepper.js +1 -0
- package/dist/esm/components/db-table.d.ts +39 -0
- package/dist/esm/components/db-table.js +1 -0
- package/dist/esm/components/db-tabs.d.ts +48 -0
- package/dist/esm/components/db-tabs.js +1 -0
- package/dist/esm/components/db-testimonial.d.ts +27 -0
- package/dist/esm/components/db-testimonial.js +1 -0
- package/dist/esm/components/db-textarea.d.ts +33 -0
- package/dist/esm/components/db-textarea.js +1 -0
- package/dist/esm/components/db-time-picker.d.ts +62 -0
- package/dist/esm/components/db-time-picker.js +1 -0
- package/dist/esm/components/db-timeline.d.ts +29 -0
- package/dist/esm/components/db-timeline.js +1 -0
- package/dist/esm/components/db-toast.d.ts +23 -0
- package/dist/esm/components/db-toast.js +1 -0
- package/dist/esm/components/db-toggle.d.ts +35 -0
- package/dist/esm/components/db-toggle.js +1 -0
- package/dist/esm/components/db-toolbar.d.ts +25 -0
- package/dist/esm/components/db-toolbar.js +1 -0
- package/dist/esm/components/db-tooltip.d.ts +55 -0
- package/dist/esm/components/db-tooltip.js +1 -0
- package/dist/esm/components/db-top-banner.d.ts +17 -0
- package/dist/esm/components/db-top-banner.js +1 -0
- package/dist/esm/components/db-tutorial.d.ts +54 -0
- package/dist/esm/components/db-tutorial.js +1 -0
- package/dist/esm/components/db-video-player.d.ts +67 -0
- package/dist/esm/components/db-video-player.js +1 -0
- package/dist/esm/components/db-youtube-player.d.ts +22 -0
- package/dist/esm/components/db-youtube-player.js +1 -0
- package/dist/esm/components/highlight-code.js +1 -0
- package/dist/esm/components/input-validation.js +1 -0
- package/dist/esm/components/number-scrub.js +1 -0
- package/dist/esm/components/random-gradient-palettes.js +1 -0
- package/dist/esm/helpers/confirm.d.ts +30 -0
- package/dist/esm/helpers/confirm.js +1 -0
- package/dist/esm/helpers/toast.d.ts +56 -0
- package/dist/esm/helpers/toast.js +1 -0
- package/dist/esm/index.d.ts +100 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/node_modules/prismjs/components/prism-bash.js +1 -0
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +1 -0
- package/dist/esm/node_modules/prismjs/components/prism-css.js +1 -0
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +1 -0
- package/dist/esm/node_modules/prismjs/components/prism-json.js +1 -0
- package/dist/esm/node_modules/prismjs/components/prism-jsx.js +1 -0
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +1 -0
- package/dist/esm/node_modules/prismjs/components/prism-scss.js +1 -0
- package/dist/esm/node_modules/prismjs/components/prism-tsx.js +1 -0
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +180 -3
- package/dist/index.esm.js +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.d.ts +203 -50
- package/dist/react/index.esm.js +1 -1
- package/package.json +10 -2
- /package/dist/chunks/{lottie-f6500ba3.js → lottie-e741cdda.js} +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
type DbReorderItem = {
|
|
2
|
+
id: string;
|
|
3
|
+
content: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
selected?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare class DbReorder extends HTMLElement {
|
|
8
|
+
private draggedIndex;
|
|
9
|
+
private dropIndex;
|
|
10
|
+
static get observedAttributes(): string[];
|
|
11
|
+
get items(): DbReorderItem[];
|
|
12
|
+
set items(value: DbReorderItem[] | string);
|
|
13
|
+
connectedCallback(): void;
|
|
14
|
+
disconnectedCallback(): void;
|
|
15
|
+
attributeChangedCallback(): void;
|
|
16
|
+
private getBool;
|
|
17
|
+
private getOption;
|
|
18
|
+
private emitReorder;
|
|
19
|
+
private getItemElements;
|
|
20
|
+
private updateDragClasses;
|
|
21
|
+
private getAdjustedDropIndex;
|
|
22
|
+
private isValidDropIndex;
|
|
23
|
+
private getDropIndexFromPointer;
|
|
24
|
+
private getDropIndexFromContainerPointer;
|
|
25
|
+
private commitDrop;
|
|
26
|
+
private handleContainerDragOver;
|
|
27
|
+
private handleContainerDrop;
|
|
28
|
+
private setDropIndex;
|
|
29
|
+
private resetDragState;
|
|
30
|
+
private render;
|
|
31
|
+
}
|
|
32
|
+
declare global {
|
|
33
|
+
interface HTMLElementTagNameMap {
|
|
34
|
+
'db-reorder': DbReorder;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { DbReorder };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createDbIcon as e}from"./db-icons.js";const t=["default","bordered","filled","minimal"],r=["s","m","l"],s=["vertical","horizontal"];class DbReorder extends HTMLElement{constructor(){super(...arguments),this.draggedIndex=-1,this.dropIndex=-1,this.handleContainerDragOver=e=>{if(this.draggedIndex<0)return;const t=e.target;if(t instanceof Element&&t.closest(".designbase-wc-reorder__item"))return;e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move");const r=this.getDropIndexFromContainerPointer(e);this.setDropIndex(this.isValidDropIndex(r)?r:-1)},this.handleContainerDrop=e=>{if(this.draggedIndex<0)return;const t=e.target;if(t instanceof Element&&t.closest(".designbase-wc-reorder__item"))return;e.preventDefault();const r=this.dropIndex>=0?this.dropIndex:this.getDropIndexFromContainerPointer(e);this.commitDrop(r)}}static get observedAttributes(){return["items","variant","size","orientation","selectable","multi-select","show-drag-handle","show-drag-icon","full-width","disabled"]}get items(){try{const e=JSON.parse(this.getAttribute("items")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}set items(e){this.setAttribute("items","string"==typeof e?e:JSON.stringify(e))}connectedCallback(){this.addEventListener("dragover",this.handleContainerDragOver),this.addEventListener("drop",this.handleContainerDrop),this.render()}disconnectedCallback(){this.removeEventListener("dragover",this.handleContainerDragOver),this.removeEventListener("drop",this.handleContainerDrop)}attributeChangedCallback(){this.render()}getBool(e,t=!1){if(!this.hasAttribute(e))return t;const r=this.getAttribute(e);return""===r||"true"===r}getOption(e,t,r){const s=this.getAttribute(e);return s&&t.includes(s)?s:r}emitReorder(e){this.items=e,this.dispatchEvent(new CustomEvent("db-reorder",{detail:{items:e},bubbles:!0,composed:!0}))}getItemElements(){return Array.from(this.children).filter(e=>e instanceof HTMLElement&&e.classList.contains("designbase-wc-reorder__item"))}updateDragClasses(){const e=this.getOption("orientation",s,"vertical"),t=this.draggedIndex>=0,r=this.items.length,i=t&&this.isValidDropIndex(this.dropIndex);this.classList.toggle("designbase-wc-reorder--dragging",t),this.getItemElements().forEach((s,d)=>{const n=t&&this.draggedIndex===d,o=i&&this.dropIndex===d,a=i&&this.dropIndex===r&&d===r-1,g=o||a;s.classList.toggle("designbase-wc-reorder__item--dragged",n),s.classList.toggle("designbase-wc-reorder__item--drag-over",g),s.classList.toggle("designbase-wc-reorder__item--drag-down",o&&"vertical"===e),s.classList.toggle("designbase-wc-reorder__item--drag-up",a&&"vertical"===e),s.classList.toggle("designbase-wc-reorder__item--drag-right",o&&"horizontal"===e),s.classList.toggle("designbase-wc-reorder__item--drag-left",a&&"horizontal"===e)})}getAdjustedDropIndex(e=this.dropIndex){return this.draggedIndex<0||e<0?-1:e>this.draggedIndex?e-1:e}isValidDropIndex(e=this.dropIndex){const t=this.getAdjustedDropIndex(e);return t>=0&&t!==this.draggedIndex}getDropIndexFromPointer(e,t,r,s){const i=t.getBoundingClientRect();return("horizontal"===s?e.clientX-i.left:e.clientY-i.top)<("horizontal"===s?i.width/2:i.height/2)?r:r+1}getDropIndexFromContainerPointer(e){const t=this.getOption("orientation",s,"vertical"),r=this.getItemElements();if(0===r.length)return-1;const i="horizontal"===t?e.clientX:e.clientY;for(let e=0;e<r.length;e+=1){const s=r[e].getBoundingClientRect();if(i<("horizontal"===t?s.left:s.top)+("horizontal"===t?s.width:s.height)/2)return e}return r.length}commitDrop(e){const t=this.getAdjustedDropIndex(e);if(this.draggedIndex<0||t<0||t===this.draggedIndex)return void this.resetDragState();const r=[...this.items],[s]=r.splice(this.draggedIndex,1);r.splice(t,0,s),this.draggedIndex=-1,this.dropIndex=-1,this.emitReorder(r)}setDropIndex(e){this.dropIndex!==e&&(this.dropIndex=e,this.updateDragClasses())}resetDragState(){this.draggedIndex=-1,this.dropIndex=-1,this.updateDragClasses()}render(){const i=this.getOption("variant",t,"default"),d=this.getOption("size",r,"m"),n=this.getOption("orientation",s,"vertical"),o=this.getBool("disabled"),a=this.getBool("selectable"),g=this.getBool("multi-select"),l=this.getBool("show-drag-handle",!0),c=this.getBool("show-drag-icon",!0);this.className=["designbase-wc-reorder",`designbase-wc-reorder--${i}`,`designbase-wc-reorder--${d}`,`designbase-wc-reorder--${n}`,this.getBool("full-width")&&"designbase-wc-reorder--full-width",o&&"designbase-wc-reorder--disabled",a&&"designbase-wc-reorder--selectable"].filter(Boolean).join(" ");const h=document.createDocumentFragment();this.items.forEach((t,r)=>{const s=document.createElement("div"),i=o||!!t.disabled,m=this.draggedIndex===r,p=this.draggedIndex>=0&&this.isValidDropIndex(this.dropIndex),b=p&&this.dropIndex===r,u=p&&this.dropIndex===this.items.length&&r===this.items.length-1,x=b||u;if(s.className=["designbase-wc-reorder__item",t.selected&&"designbase-wc-reorder__item--selected",m&&"designbase-wc-reorder__item--dragged",i&&"designbase-wc-reorder__item--disabled",x&&"designbase-wc-reorder__item--drag-over",b&&"vertical"===n&&"designbase-wc-reorder__item--drag-down",u&&"vertical"===n&&"designbase-wc-reorder__item--drag-up",b&&"horizontal"===n&&"designbase-wc-reorder__item--drag-right",u&&"horizontal"===n&&"designbase-wc-reorder__item--drag-left"].filter(Boolean).join(" "),s.draggable=!i,s.addEventListener("dragstart",e=>{i||(this.draggedIndex=r,this.dropIndex=-1,e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",t.id)),this.updateDragClasses())}),s.addEventListener("dragover",e=>{if(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),this.draggedIndex<0)return void this.setDropIndex(-1);const t=this.getDropIndexFromPointer(e,s,r,n);this.setDropIndex(this.isValidDropIndex(t)?t:-1)}),s.addEventListener("dragleave",e=>{const t=s.getBoundingClientRect(),r=e.clientX-t.left,i=e.clientY-t.top;(r<0||r>t.width||i<0||i>t.height)&&this.setDropIndex(-1)}),s.addEventListener("drop",e=>{e.preventDefault();const t=this.dropIndex>=0?this.dropIndex:this.getDropIndexFromPointer(e,s,r,n);this.commitDrop(t)}),s.addEventListener("dragend",()=>{this.resetDragState()}),l&&!i){const t=document.createElement("div");if(t.className="designbase-wc-reorder__drag-handle",t.setAttribute("aria-hidden","true"),c){const r="horizontal"===n?"grip-horizontal":"grip-vertical",s="s"===d?14:"l"===d?18:16;t.append(e(r,s))}else t.textContent="≡";s.append(t)}if(a){const e=document.createElement("div");e.className="designbase-wc-reorder__checkbox";const r=document.createElement("input");r.type=g?"checkbox":"radio",r.checked=!!t.selected,r.disabled=i,r.className="designbase-wc-reorder__checkbox-input",r.addEventListener("change",()=>{const e=this.items.map(e=>e.id!==t.id?g?e:{...e,selected:!1}:{...e,selected:!g||!e.selected});this.items=e,this.dispatchEvent(new CustomEvent("db-select",{detail:{items:e.filter(e=>e.selected)},bubbles:!0,composed:!0})),this.render()}),e.append(r),s.append(e)}const I=document.createElement("div");I.className="designbase-wc-reorder__content",I.textContent=t.content,s.append(I),h.append(s)}),this.replaceChildren(h)}}customElements.get("db-reorder")||customElements.define("db-reorder",DbReorder);export{DbReorder};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare class DbResizablePanels extends HTMLElement {
|
|
2
|
+
private container?;
|
|
3
|
+
private contentEl?;
|
|
4
|
+
private guidesEl?;
|
|
5
|
+
private sizeIndicatorEl?;
|
|
6
|
+
private constraintsEl?;
|
|
7
|
+
private handleEl?;
|
|
8
|
+
private isResizing;
|
|
9
|
+
private startSize;
|
|
10
|
+
private startPos;
|
|
11
|
+
private currentSize;
|
|
12
|
+
static get observedAttributes(): string[];
|
|
13
|
+
connectedCallback(): void;
|
|
14
|
+
attributeChangedCallback(): void;
|
|
15
|
+
private getBool;
|
|
16
|
+
private getNumber;
|
|
17
|
+
private getDirection;
|
|
18
|
+
private getHandlePosition;
|
|
19
|
+
private initializeSize;
|
|
20
|
+
private getMinSize;
|
|
21
|
+
private getMaxSize;
|
|
22
|
+
private ensureStructure;
|
|
23
|
+
private onMouseDown;
|
|
24
|
+
private onTouchStart;
|
|
25
|
+
private startResize;
|
|
26
|
+
private onMouseMove;
|
|
27
|
+
private onTouchMove;
|
|
28
|
+
private applyResize;
|
|
29
|
+
private onMouseUp;
|
|
30
|
+
private onTouchEnd;
|
|
31
|
+
private endResize;
|
|
32
|
+
private renderHandleStyle;
|
|
33
|
+
private render;
|
|
34
|
+
private makeConstraint;
|
|
35
|
+
}
|
|
36
|
+
declare global {
|
|
37
|
+
interface HTMLElementTagNameMap {
|
|
38
|
+
'db-resizable-panels': DbResizablePanels;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { DbResizablePanels };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=["both","horizontal","vertical"],t=["bottom-right","bottom-left","top-right","top-left","right","bottom"];class DbResizablePanels extends HTMLElement{constructor(){super(...arguments),this.isResizing=!1,this.startSize={width:0,height:0},this.startPos={x:0,y:0},this.currentSize={width:0,height:0},this.onMouseDown=e=>{e.preventDefault(),this.startResize(e.clientX,e.clientY),document.addEventListener("mousemove",this.onMouseMove),document.addEventListener("mouseup",this.onMouseUp)},this.onTouchStart=e=>{e.preventDefault();const t=e.touches[0];this.startResize(t.clientX,t.clientY),document.addEventListener("touchmove",this.onTouchMove,{passive:!1}),document.addEventListener("touchend",this.onTouchEnd)},this.onMouseMove=e=>{this.applyResize(e.clientX,e.clientY)},this.onTouchMove=e=>{e.preventDefault();const t=e.touches[0];this.applyResize(t.clientX,t.clientY)},this.onMouseUp=()=>{this.endResize(),document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp)},this.onTouchEnd=()=>{this.endResize(),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd)}}static get observedAttributes(){return["initial-width","initial-height","min-width","min-height","max-width","max-height","direction","handle-position","handle-size","handle-color","handle-hover-color","snap-to-grid","show-guides","show-size-indicator","show-constraints","show-border","shadow","background-color","border-radius"]}connectedCallback(){this.ensureStructure(),this.initializeSize(),this.render()}attributeChangedCallback(){this.render()}getBool(e,t=!1){if(!this.hasAttribute(e))return t;const i=this.getAttribute(e);return""===i||"true"===i}getNumber(e,t){const i=Number(this.getAttribute(e)??t);return Number.isFinite(i)?i:t}getDirection(){const t=this.getAttribute("direction");return t&&e.includes(t)?t:"both"}getHandlePosition(){const e=this.getAttribute("handle-position");return e&&t.includes(e)?e:"bottom-right"}initializeSize(){const e=this.parentElement?.getBoundingClientRect();if(!e)return;const t=this.getAttribute("initial-width")||"100%",i=this.getAttribute("initial-height")||"100%";this.currentSize={width:"string"==typeof t&&t.endsWith("%")?e.width*Number(t.replace("%",""))/100:Number(t)||e.width,height:"string"==typeof i&&i.endsWith("%")?e.height*Number(i.replace("%",""))/100:Number(i)||e.height}}getMinSize(){return{width:this.getNumber("min-width",200),height:this.getNumber("min-height",150)}}getMaxSize(){const e=this.parentElement?.getBoundingClientRect();if(!e)return{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY};const t=this.getAttribute("max-width")||"100vw",i=this.getAttribute("max-height")||"100vh",toSize=(e,t,i)=>{if("100vw"===e||"100vh"===e)return t;if("100%"===e)return i;const s=Number(e);return Number.isFinite(s)?s:Number.POSITIVE_INFINITY};return{width:toSize(t,window.innerWidth,e.width),height:toSize(i,window.innerHeight,e.height)}}ensureStructure(){if(this.container)return;this.container=document.createElement("div"),this.container.className="designbase-wc-resizable-panels",this.guidesEl=document.createElement("div"),this.guidesEl.className="designbase-wc-resizable-panels__guides";const e=document.createElement("div");e.className="designbase-wc-resizable-panels__guide designbase-wc-resizable-panels__guide--horizontal";const t=document.createElement("div");t.className="designbase-wc-resizable-panels__guide designbase-wc-resizable-panels__guide--vertical",this.guidesEl.append(e,t),this.sizeIndicatorEl=document.createElement("div"),this.sizeIndicatorEl.className="designbase-wc-resizable-panels__size-indicator",this.constraintsEl=document.createElement("div"),this.constraintsEl.className="designbase-wc-resizable-panels__constraints",this.contentEl=document.createElement("div"),this.contentEl.className="designbase-wc-resizable-panels__content",this.handleEl=document.createElement("div"),this.handleEl.className="designbase-wc-resizable-panels__handle",this.handleEl.addEventListener("mousedown",this.onMouseDown),this.handleEl.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.container.append(this.guidesEl,this.sizeIndicatorEl,this.constraintsEl,this.contentEl,this.handleEl),this.replaceChildren(this.container)}startResize(e,t){this.isResizing=!0,this.startSize={...this.currentSize},this.startPos={x:e,y:t},this.dispatchEvent(new CustomEvent("db-resize-start",{detail:this.currentSize,bubbles:!0,composed:!0})),this.render()}applyResize(e,t){if(!this.isResizing)return;const i=e-this.startPos.x,s=t-this.startPos.y,n=this.getDirection();let h=this.startSize.width,r=this.startSize.height;"both"!==n&&"horizontal"!==n||(h+=i),"both"!==n&&"vertical"!==n||(r+=s);const o=this.getNumber("snap-to-grid",0);o>0&&(h=Math.round(h/o)*o,r=Math.round(r/o)*o);const a=this.getMinSize(),l=this.getMaxSize();h=Math.max(a.width,Math.min(l.width,h)),r=Math.max(a.height,Math.min(l.height,r)),this.currentSize={width:h,height:r},this.dispatchEvent(new CustomEvent("db-resize",{detail:this.currentSize,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("db-size-change",{detail:this.currentSize,bubbles:!0,composed:!0})),this.render()}endResize(){this.isResizing&&(this.isResizing=!1,this.dispatchEvent(new CustomEvent("db-resize-end",{detail:this.currentSize,bubbles:!0,composed:!0})),this.render())}renderHandleStyle(){if(!this.handleEl)return;const e=this.getDirection(),t=this.getHandlePosition(),i=this.getAttribute("handle-color"),s=this.getAttribute("handle-hover-color");i?this.handleEl.style.setProperty("--db-resize-handle-color",i):this.handleEl.style.removeProperty("--db-resize-handle-color"),s?this.handleEl.style.setProperty("--db-resize-handle-hover-color",s):this.handleEl.style.removeProperty("--db-resize-handle-hover-color"),this.handleEl.style.top="",this.handleEl.style.right="",this.handleEl.style.bottom="",this.handleEl.style.left="",this.handleEl.style.transform="",this.handleEl.style.width="",this.handleEl.style.height="",this.handleEl.style.backgroundColor="",this.handleEl.onmouseenter=null,this.handleEl.onmouseleave=null;let n=`corner-${t}`;"vertical"===e?n="edge-bottom":"horizontal"===e&&(n="edge-right"),this.handleEl.className=`designbase-wc-resizable-panels__handle designbase-wc-resizable-panels__handle--${n}`,this.handleEl.setAttribute("role","separator"),this.handleEl.setAttribute("aria-label","크기 조절"),this.handleEl.replaceChildren()}render(){if(this.ensureStructure(),!(this.container&&this.contentEl&&this.guidesEl&&this.sizeIndicatorEl&&this.constraintsEl))return;const e=["designbase-wc-resizable-panels",this.isResizing&&"designbase-wc-resizable-panels--resizing",this.getBool("show-border",!0)&&"designbase-wc-resizable-panels--border",this.getBool("shadow",!0)&&"designbase-wc-resizable-panels--shadow"].filter(Boolean).join(" ");this.container.className=e,this.container.style.width=`${this.currentSize.width}px`,this.container.style.height=`${this.currentSize.height}px`;const t=this.getAttribute("background-color");this.container.style.backgroundColor=t||"";const i=this.getAttribute("border-radius")||"8px";if(this.container.style.borderRadius=/^\d+$/.test(i)?`${i}px`:i,0===this.contentEl.children.length){const e=Array.from(this.childNodes).filter(e=>e!==this.container);this.contentEl.append(...e)}if(this.guidesEl.style.display=this.getBool("show-guides",!0)&&this.isResizing?"":"none",this.sizeIndicatorEl.style.display=this.getBool("show-size-indicator",!0)&&this.isResizing?"":"none",this.sizeIndicatorEl.textContent=`${Math.round(this.currentSize.width)} × ${Math.round(this.currentSize.height)}`,this.constraintsEl.style.display=this.getBool("show-constraints",!0)&&this.isResizing?"":"none",this.constraintsEl.replaceChildren(),"none"!==this.constraintsEl.style.display){const e=this.getMinSize(),t=this.getMaxSize();this.currentSize.width<=e.width&&this.constraintsEl.append(this.makeConstraint("최소 너비 도달","min")),this.currentSize.height<=e.height&&this.constraintsEl.append(this.makeConstraint("최소 높이 도달","min")),this.currentSize.width>=t.width&&this.constraintsEl.append(this.makeConstraint("최대 너비 도달","max")),this.currentSize.height>=t.height&&this.constraintsEl.append(this.makeConstraint("최대 높이 도달","max"))}this.renderHandleStyle()}makeConstraint(e,t){const i=document.createElement("div");return i.className=`designbase-wc-resizable-panels__constraint designbase-wc-resizable-panels__constraint--${t}`,i.textContent=e,i}}customElements.get("db-resizable-panels")||customElements.define("db-resizable-panels",DbResizablePanels);export{DbResizablePanels};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare class DbScrollArea extends HTMLElement {
|
|
2
|
+
static get observedAttributes(): string[];
|
|
3
|
+
private contentEl?;
|
|
4
|
+
private resizeObserver?;
|
|
5
|
+
private observer?;
|
|
6
|
+
connectedCallback(): void;
|
|
7
|
+
disconnectedCallback(): void;
|
|
8
|
+
attributeChangedCallback(): void;
|
|
9
|
+
private ensureStructure;
|
|
10
|
+
private collectContentNodes;
|
|
11
|
+
private syncChildren;
|
|
12
|
+
private toCssSize;
|
|
13
|
+
private syncScrollState;
|
|
14
|
+
private syncViewportSize;
|
|
15
|
+
private sync;
|
|
16
|
+
}
|
|
17
|
+
declare global {
|
|
18
|
+
interface HTMLElementTagNameMap {
|
|
19
|
+
'db-scroll-area': DbScrollArea;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { DbScrollArea };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=["vertical","horizontal","both"],e=["auto","thin","none"];class DbScrollArea extends HTMLElement{static get observedAttributes(){return["direction","scrollbar-style","max-height","max-width","min-height","min-width","full-width","full-height","always-show-scrollbar","scrollbar-color","scrollbar-track-color"]}connectedCallback(){this.ensureStructure(),this.sync(),this.resizeObserver=new ResizeObserver(()=>{this.syncViewportSize(),this.syncScrollState()}),this.resizeObserver.observe(this),this.contentEl&&this.resizeObserver.observe(this.contentEl),this.observer=new MutationObserver(()=>this.syncChildren()),this.observer.observe(this,{childList:!0,subtree:!0})}disconnectedCallback(){this.resizeObserver?.disconnect(),this.observer?.disconnect()}attributeChangedCallback(){this.isConnected&&this.sync()}ensureStructure(){this.contentEl||(this.contentEl=document.createElement("div"),this.contentEl.className="designbase-wc-scroll-area__content",this.contentEl.setAttribute("data-wc-internal","")),this.contentEl.isConnected||this.append(this.contentEl)}collectContentNodes(){return Array.from(this.children).filter(t=>t!==this.contentEl&&!t.hasAttribute("data-wc-internal"))}syncChildren(){const t=this.collectContentNodes();t.length&&this.contentEl?.append(...t),this.syncScrollState()}toCssSize(t){if(!t)return;if(t.includes("px")||t.includes("%")||t.includes("vh")||t.includes("rem"))return t;const e=Number(t);return Number.isFinite(e)?`${e}px`:t}syncScrollState(){const t=this.contentEl;if(!t)return;const e=t.scrollHeight>t.clientHeight,s=t.scrollWidth>t.clientWidth;this.classList.toggle("designbase-wc-scroll-area--has-vertical",e),this.classList.toggle("designbase-wc-scroll-area--has-horizontal",s)}syncViewportSize(){if(!this.contentEl)return;const t=this.toCssSize(this.getAttribute("max-height"))||this.style.maxHeight||void 0,e=this.toCssSize(this.getAttribute("max-width"))||this.style.maxWidth||void 0,s=this.toCssSize(this.getAttribute("min-height"))||this.style.minHeight||void 0,i=this.toCssSize(this.getAttribute("min-width"))||this.style.minWidth||void 0;this.contentEl.style.maxHeight=t||"",this.contentEl.style.maxWidth=e||"",this.contentEl.style.minHeight=s||"",this.contentEl.style.minWidth=i||""}sync(){this.ensureStructure();const s=this.getAttribute("direction")||"vertical",i=this.getAttribute("scrollbar-style")||"auto",r=t.includes(s)?s:"vertical",l=e.includes(i)?i:"auto";this.className=["designbase-wc-scroll-area",`designbase-wc-scroll-area--direction-${r}`,`designbase-wc-scroll-area--scrollbar-${l}`,this.hasAttribute("full-width")&&"designbase-wc-scroll-area--full-width",this.hasAttribute("full-height")&&"designbase-wc-scroll-area--full-height",this.hasAttribute("always-show-scrollbar")&&"designbase-wc-scroll-area--always-show"].filter(Boolean).join(" ");const c=this.getAttribute("scrollbar-color"),n=this.getAttribute("scrollbar-track-color");c?this.style.setProperty("--scrollbar-color",c):this.style.removeProperty("--scrollbar-color"),n?this.style.setProperty("--scrollbar-track-color",n):this.style.removeProperty("--scrollbar-track-color"),this.syncViewportSize(),this.syncChildren()}}customElements.get("db-scroll-area")||customElements.define("db-scroll-area",DbScrollArea);export{DbScrollArea};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
declare class DbSearchBar extends HTMLElement {
|
|
2
|
+
static get observedAttributes(): string[];
|
|
3
|
+
private input?;
|
|
4
|
+
private clearButton?;
|
|
5
|
+
private shortcutBadge?;
|
|
6
|
+
private dropdown?;
|
|
7
|
+
private recentSearches;
|
|
8
|
+
private isFocused;
|
|
9
|
+
private currentSuggestion;
|
|
10
|
+
private suggestionInterval?;
|
|
11
|
+
private blurTimer?;
|
|
12
|
+
private globalKeyHandler?;
|
|
13
|
+
private repositionHandler?;
|
|
14
|
+
private scrollParents;
|
|
15
|
+
private getResolvedSize;
|
|
16
|
+
private getIconPx;
|
|
17
|
+
private syncIcons;
|
|
18
|
+
private hasInputValue;
|
|
19
|
+
get value(): string;
|
|
20
|
+
set value(nextValue: string);
|
|
21
|
+
connectedCallback(): void;
|
|
22
|
+
disconnectedCallback(): void;
|
|
23
|
+
attributeChangedCallback(name: string): void;
|
|
24
|
+
focus(): void;
|
|
25
|
+
private parseJsonArray;
|
|
26
|
+
private getRecentSearchesKey;
|
|
27
|
+
private loadRecentSearches;
|
|
28
|
+
private saveRecentSearches;
|
|
29
|
+
private clearSuggestionInterval;
|
|
30
|
+
private syncSuggestionRolling;
|
|
31
|
+
private syncPlaceholder;
|
|
32
|
+
private syncValueState;
|
|
33
|
+
private syncAttributes;
|
|
34
|
+
private bindGlobalShortcut;
|
|
35
|
+
private unbindGlobalShortcut;
|
|
36
|
+
private positionDropdown;
|
|
37
|
+
private bindRepositionListeners;
|
|
38
|
+
private unbindRepositionListeners;
|
|
39
|
+
private attachDropdownPortal;
|
|
40
|
+
private detachDropdownPortal;
|
|
41
|
+
private shouldShowDropdown;
|
|
42
|
+
private formatSearchResult;
|
|
43
|
+
private handleSearch;
|
|
44
|
+
private updateDropdown;
|
|
45
|
+
private render;
|
|
46
|
+
}
|
|
47
|
+
declare global {
|
|
48
|
+
interface HTMLElementTagNameMap {
|
|
49
|
+
'db-search-bar': DbSearchBar;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { DbSearchBar };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getDbComponentIconSize as e,createDbIcon as t}from"./db-icons.js";const s=["s","m","l"],a=["vertical","horizontal"];class DbSearchBar extends HTMLElement{constructor(){super(...arguments),this.recentSearches=[],this.isFocused=!1,this.currentSuggestion=0,this.scrollParents=[]}static get observedAttributes(){return["value","default-value","placeholder","size","disabled","readonly","full-width","show-shortcut","shortcut-label","enable-recent-searches","recent-searches-key","recent-searches-layout","suggested-searches","suggestion-rolling-interval","categories","selected-category","search-results","empty-state-message"]}getResolvedSize(){const e=this.getAttribute("size")||"m";return s.includes(e)?e:"m"}getIconPx(){return e(this.getResolvedSize())}syncIcons(){const e=this.getIconPx();this.querySelector(".designbase-wc-search-bar__search-icon")?.replaceChildren(t("search",e)),this.clearButton?.replaceChildren(t("close",e))}hasInputValue(){return Boolean((this.input?.value??this.getAttribute("value")??"").trim())}get value(){return this.input?.value??this.getAttribute("value")??""}set value(e){this.setAttribute("value",e),this.input&&(this.input.value=e)}connectedCallback(){this.loadRecentSearches(),this.render(),this.bindGlobalShortcut()}disconnectedCallback(){this.clearSuggestionInterval(),this.unbindGlobalShortcut(),this.detachDropdownPortal(),this.blurTimer&&clearTimeout(this.blurTimer)}attributeChangedCallback(e){if(this.isConnected)return"value"===e&&this.input?(this.input.value=this.getAttribute("value")||"",this.syncValueState(),this.syncPlaceholder(),this.updateDropdown(),void this.syncSuggestionRolling()):"disabled"===e||"readonly"===e||"placeholder"===e||"show-shortcut"===e||"shortcut-label"===e||"selected-category"===e||"search-results"===e||"empty-state-message"===e||"suggested-searches"===e?(this.syncAttributes(),this.syncPlaceholder(),this.updateDropdown(),void this.syncSuggestionRolling()):"enable-recent-searches"===e||"recent-searches-key"===e?(this.loadRecentSearches(),void this.updateDropdown()):void("categories"!==e&&"recent-searches-layout"!==e?this.render():this.updateDropdown())}focus(){this.input?.focus()}parseJsonArray(e){try{const t=JSON.parse(this.getAttribute(e)||"[]");return Array.isArray(t)?t:[]}catch{return[]}}getRecentSearchesKey(){return this.getAttribute("recent-searches-key")||"searchbar-recent-searches"}loadRecentSearches(){if(this.hasAttribute("enable-recent-searches"))try{const e=localStorage.getItem(this.getRecentSearchesKey());this.recentSearches=e?JSON.parse(e):[],Array.isArray(this.recentSearches)||(this.recentSearches=[])}catch{this.recentSearches=[]}else this.recentSearches=[]}saveRecentSearches(){try{localStorage.setItem(this.getRecentSearchesKey(),JSON.stringify(this.recentSearches))}catch{}}clearSuggestionInterval(){this.suggestionInterval&&(clearInterval(this.suggestionInterval),this.suggestionInterval=void 0)}syncSuggestionRolling(){this.clearSuggestionInterval();const e=this.parseJsonArray("suggested-searches"),t=this.hasInputValue(),s=Number(this.getAttribute("suggestion-rolling-interval")||5e3);e.length>0&&!t&&(this.suggestionInterval=setInterval(()=>{this.currentSuggestion=(this.currentSuggestion+1)%e.length,this.syncPlaceholder(),this.updateDropdown()},s))}syncPlaceholder(){if(!this.input)return;const e=this.parseJsonArray("suggested-searches"),t=this.hasInputValue(),s=this.getAttribute("placeholder")||"검색...";e.length>0&&!t?this.input.placeholder=e[this.currentSuggestion]||s:this.input.placeholder=s}syncValueState(){const e=this.hasInputValue();this.classList.toggle("designbase-wc-search-bar--has-value",e),this.clearButton&&(this.clearButton.hidden=!e||this.hasAttribute("disabled")||this.hasAttribute("readonly")),this.shortcutBadge&&(this.shortcutBadge.hidden=!this.hasAttribute("show-shortcut")||e||this.hasAttribute("disabled")||this.hasAttribute("readonly")),this.syncIcons()}syncAttributes(){const e=this.getAttribute("size")||"m",t=this.hasAttribute("disabled"),a=this.hasAttribute("readonly"),n=this.hasAttribute("show-shortcut");this.className=["designbase-wc-search-bar",`designbase-wc-search-bar--${s.includes(e)?e:"m"}`,t&&"designbase-wc-search-bar--disabled",a&&"designbase-wc-search-bar--readonly",this.hasAttribute("full-width")&&"designbase-wc-search-bar--full-width",Boolean(this.hasInputValue())&&"designbase-wc-search-bar--has-value"].filter(Boolean).join(" "),this.input&&(this.input.disabled=t,this.input.readOnly=a),this.shortcutBadge&&(this.shortcutBadge.hidden=!n||this.hasInputValue()||t||a,this.shortcutBadge.textContent=this.getAttribute("shortcut-label")||"⌘K"),this.syncValueState()}bindGlobalShortcut(){this.unbindGlobalShortcut(),!this.hasAttribute("show-shortcut")||this.hasAttribute("disabled")||this.hasAttribute("readonly")||(this.globalKeyHandler=e=>{const t=e.metaKey||e.ctrlKey;let s="k";const a=(this.getAttribute("shortcut-label")||"⌘K").slice(-1).toLowerCase();a&&(s=a),t&&e.key.toLowerCase()===s&&(e.preventDefault(),this.focus())},window.addEventListener("keydown",this.globalKeyHandler))}unbindGlobalShortcut(){this.globalKeyHandler&&(window.removeEventListener("keydown",this.globalKeyHandler),this.globalKeyHandler=void 0)}positionDropdown(){if(!this.dropdown||this.dropdown.hidden)return;const e=this.getBoundingClientRect(),t=this.input?.getBoundingClientRect(),s=t??e;this.dropdown.style.top=`${s.bottom+4}px`,this.dropdown.style.left=`${e.left}px`,this.dropdown.style.width=`${e.width}px`,this.dropdown.style.right="auto"}bindRepositionListeners(){if(this.repositionHandler)return;this.repositionHandler=()=>{requestAnimationFrame(()=>this.positionDropdown())},window.addEventListener("scroll",this.repositionHandler,!0),window.addEventListener("resize",this.repositionHandler),this.scrollParents=[];let e=this.parentElement;for(;e&&e!==document.body;){const t=getComputedStyle(e),s=/(auto|scroll|overlay)/.test(t.overflowY),a=/(auto|scroll|overlay)/.test(t.overflow);(s||a)&&e.scrollHeight>e.clientHeight&&(e.addEventListener("scroll",this.repositionHandler,{passive:!0}),this.scrollParents.push(e)),e=e.parentElement}}unbindRepositionListeners(){this.repositionHandler&&(window.removeEventListener("scroll",this.repositionHandler,!0),window.removeEventListener("resize",this.repositionHandler),this.scrollParents.forEach(e=>e.removeEventListener("scroll",this.repositionHandler)),this.scrollParents=[],this.repositionHandler=void 0)}attachDropdownPortal(){this.dropdown&&!this.dropdown.hidden&&(this.dropdown.classList.add("designbase-wc-search-bar__dropdown--portal"),this.dropdown.parentElement!==document.body&&document.body.append(this.dropdown),requestAnimationFrame(()=>this.positionDropdown()),this.repositionHandler||this.bindRepositionListeners())}detachDropdownPortal(){this.unbindRepositionListeners(),this.dropdown&&(this.dropdown.classList.remove("designbase-wc-search-bar__dropdown--portal"),this.dropdown.style.top="",this.dropdown.style.left="",this.dropdown.style.width="",this.dropdown.style.right="",this.dropdown.parentElement===document.body&&this.isConnected&&this.append(this.dropdown))}shouldShowDropdown(){const e=this.hasInputValue(),t=this.parseJsonArray("categories"),s=this.parseJsonArray("suggested-searches"),a=this.getAttribute("search-results"),n=this.getAttribute("empty-state-message");return this.isFocused&&(t.length>0||this.hasAttribute("enable-recent-searches")&&this.recentSearches.length>0&&!e||s.length>0&&!e||null!==a&&e||Boolean(n)&&!e&&(!this.hasAttribute("enable-recent-searches")||0===this.recentSearches.length)&&0===s.length)}formatSearchResult(e){if("string"==typeof e||"number"==typeof e)return String(e);if(e&&"object"==typeof e){const t=e;if("string"==typeof t.title)return t.title;if("string"==typeof t.label)return t.label}return String(e)}handleSearch(e){const t=(e??this.value).trim();t&&(this.dispatchEvent(new CustomEvent("db-search",{detail:{value:t},bubbles:!0,composed:!0})),this.hasAttribute("enable-recent-searches")&&(this.recentSearches=[t,...this.recentSearches.filter(e=>e!==t)].slice(0,10),this.saveRecentSearches(),this.updateDropdown()))}updateDropdown(){if(!this.dropdown)return;const s=this.shouldShowDropdown();if(this.dropdown.hidden=!s,this.classList.toggle("designbase-wc-search-bar--dropdown-open",s),!s)return this.dropdown.replaceChildren(),void this.detachDropdownPortal();this.dropdown.replaceChildren();const n=this.hasInputValue(),r=this.parseJsonArray("categories"),i=this.parseJsonArray("suggested-searches"),o=this.getAttribute("selected-category")||"",c=this.parseJsonArray("search-results"),h=this.getAttribute("empty-state-message"),d=a.includes(this.getAttribute("recent-searches-layout")||"vertical")&&this.getAttribute("recent-searches-layout")||"vertical";if(r.length>0){const e=document.createElement("div");e.className="designbase-wc-search-bar__categories",r.forEach(t=>{const s=document.createElement("db-chip");s.setAttribute("label",t),s.setAttribute("size","s"),s.setAttribute("variant",t===o?"primary":"default"),s.setAttribute("clickable",""),s.addEventListener("mousedown",e=>{e.preventDefault(),this.setAttribute("selected-category",t),this.dispatchEvent(new CustomEvent("db-category-change",{detail:{category:t},bubbles:!0,composed:!0})),this.updateDropdown()}),e.append(s)}),this.dropdown.append(e)}if(n&&this.hasAttribute("search-results")){const e=document.createElement("div");if(e.className="designbase-wc-search-bar__results",c.length>0){const t=document.createElement("ul");t.className="designbase-wc-search-bar__results-list",c.forEach((e,s)=>{const a=document.createElement("li");a.className="designbase-wc-search-bar__result-item",a.textContent=this.formatSearchResult(e),a.addEventListener("mousedown",t=>{t.preventDefault(),this.isFocused=!1,this.updateDropdown(),this.dispatchEvent(new CustomEvent("db-search-result-click",{detail:{result:e,index:s},bubbles:!0,composed:!0}))}),t.append(a)}),e.append(t)}else{const t=document.createElement("div");t.className="designbase-wc-search-bar__results-empty",t.textContent="검색 결과가 없습니다.",e.append(t)}return this.dropdown.append(e),void this.attachDropdownPortal()}if(this.hasAttribute("enable-recent-searches")&&!n&&this.recentSearches.length>0){const s=document.createElement("div");s.className=`designbase-wc-search-bar__recent-searches designbase-wc-search-bar__recent-searches--${d}`;const a=document.createElement("div");a.className="designbase-wc-search-bar__recent-header";const n=document.createElement("span");n.className="designbase-wc-search-bar__recent-title",n.textContent="최근 검색어";const r=document.createElement("button");r.type="button",r.className="designbase-wc-search-bar__clear-all-button",r.setAttribute("aria-label","모든 최근 검색어 삭제"),r.textContent="전체 삭제",r.addEventListener("mousedown",e=>{e.preventDefault(),this.recentSearches=[];try{localStorage.removeItem(this.getRecentSearchesKey())}catch{}this.updateDropdown()}),a.append(n,r);const i=document.createElement("div");i.className="designbase-wc-search-bar__recent-list",this.recentSearches.forEach(s=>{const a=document.createElement("div");a.className="designbase-wc-search-bar__recent-item";const n=document.createElement("button");n.type="button",n.className="designbase-wc-search-bar__recent-search-button",n.textContent=s,n.addEventListener("mousedown",e=>{if(e.preventDefault(),!this.input)return;this.input.value=s,this.setAttribute("value",s),this.syncValueState(),this.syncPlaceholder(),this.handleSearch(s);const t={value:s};this.dispatchEvent(new CustomEvent("db-input",{detail:t,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("db-change",{detail:t,bubbles:!0,composed:!0})),this.isFocused=!1,this.updateDropdown()});const r=document.createElement("button");r.type="button",r.className="designbase-wc-search-bar__recent-remove-button",r.setAttribute("aria-label",`${s} 삭제`),r.append(t("close",e("s"))),r.addEventListener("mousedown",e=>{e.preventDefault(),this.recentSearches=this.recentSearches.filter(e=>e!==s),this.saveRecentSearches(),this.updateDropdown()}),a.append(n,r),i.append(a)}),s.append(a,i),this.dropdown.append(s)}if(i.length>0&&!n){const e=document.createElement("div");e.className="designbase-wc-search-bar__suggestions";const t=document.createElement("div");t.className="designbase-wc-search-bar__suggestions-header";const s=document.createElement("span");s.className="designbase-wc-search-bar__suggestions-title",s.textContent="추천 검색어",t.append(s);const a=document.createElement("div");a.className="designbase-wc-search-bar__suggestions-list",i.forEach((e,t)=>{const s=document.createElement("button");s.type="button",s.className=["designbase-wc-search-bar__suggestion-item",t===this.currentSuggestion&&"designbase-wc-search-bar__suggestion-item--active"].filter(Boolean).join(" "),s.textContent=e,s.addEventListener("mousedown",t=>{if(t.preventDefault(),!this.input)return;this.clearSuggestionInterval(),this.input.value=e,this.setAttribute("value",e),this.syncValueState(),this.syncPlaceholder(),this.handleSearch(e);const s={value:e};this.dispatchEvent(new CustomEvent("db-input",{detail:s,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("db-change",{detail:s,bubbles:!0,composed:!0})),this.isFocused=!1,this.updateDropdown()}),a.append(s)}),e.append(t,a),this.dropdown.append(e)}if(h&&!n&&(!this.hasAttribute("enable-recent-searches")||0===this.recentSearches.length)&&0===i.length){const e=document.createElement("div");e.className="designbase-wc-search-bar__empty-state",e.textContent=h,this.dropdown.append(e)}this.attachDropdownPortal()}render(){const e=this.getAttribute("size")||"m",a=this.hasAttribute("disabled"),n=this.hasAttribute("readonly"),r=this.hasAttribute("full-width"),i=this.hasAttribute("show-shortcut"),o=this.getAttribute("value")??this.getAttribute("default-value")??"",c=Boolean(o.trim()),h=this.getIconPx();this.className=["designbase-wc-search-bar",`designbase-wc-search-bar--${s.includes(e)?e:"m"}`,a&&"designbase-wc-search-bar--disabled",n&&"designbase-wc-search-bar--readonly",r&&"designbase-wc-search-bar--full-width",c&&"designbase-wc-search-bar--has-value",this.shouldShowDropdown()&&"designbase-wc-search-bar--dropdown-open"].filter(Boolean).join(" "),this.setAttribute("role","search"),this.clearSuggestionInterval(),this.detachDropdownPortal(),this.replaceChildren();const d=document.createElement("div");d.className="designbase-wc-search-bar__container";const l=document.createElement("div");l.className="designbase-wc-search-bar__search-icon",l.setAttribute("aria-hidden","true"),l.append(t("search",h));const u=document.createElement("input");if(u.type="text",u.className="designbase-wc-search-bar__input",u.value=o,u.disabled=a,u.readOnly=n,u.setAttribute("aria-label","검색어 입력"),this.input=u,i){const t=document.createElement("db-badge");t.className="designbase-wc-search-bar__shortcut-badge",t.setAttribute("size","l"===e?"m":"s"),t.setAttribute("variant","secondary"),t.setAttribute("badge-style","text"),t.setAttribute("aria-hidden","true"),t.textContent=this.getAttribute("shortcut-label")||"⌘K",t.hidden=c||a||n,this.shortcutBadge=t,d.append(l,u,t)}else d.append(l,u);const b=document.createElement("button");b.type="button",b.className="designbase-wc-search-bar__clear-button",b.setAttribute("aria-label","검색어 지우기"),b.hidden=!c||a||n,b.append(t("close",h)),this.clearButton=b,d.append(b);const p=document.createElement("div");p.className="designbase-wc-search-bar__dropdown",p.hidden=!0,p.addEventListener("mousedown",e=>{e.preventDefault()}),this.dropdown=p,u.addEventListener("input",()=>{this.setAttribute("value",u.value),this.syncValueState(),this.syncPlaceholder(),this.updateDropdown(),this.syncSuggestionRolling();const e={value:u.value};this.dispatchEvent(new CustomEvent("db-input",{detail:e,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("db-change",{detail:e,bubbles:!0,composed:!0}))}),u.addEventListener("keydown",e=>{"Enter"===e.key&&this.handleSearch()}),u.addEventListener("focus",()=>{this.isFocused=!0,this.updateDropdown(),this.dispatchEvent(new CustomEvent("db-focus",{bubbles:!0,composed:!0}))}),u.addEventListener("blur",()=>{this.isFocused=!1,this.blurTimer&&clearTimeout(this.blurTimer),this.updateDropdown(),this.dispatchEvent(new CustomEvent("db-blur",{bubbles:!0,composed:!0}))}),b.addEventListener("click",()=>{u.value="",this.setAttribute("value",""),this.syncValueState(),this.syncPlaceholder(),this.updateDropdown(),this.syncSuggestionRolling(),u.focus(),this.dispatchEvent(new CustomEvent("db-clear",{bubbles:!0,composed:!0}));const e={value:""};this.dispatchEvent(new CustomEvent("db-input",{detail:e,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("db-change",{detail:e,bubbles:!0,composed:!0}))}),this.append(d,p),this.syncIcons(),this.syncPlaceholder(),this.syncSuggestionRolling(),this.bindGlobalShortcut(),this.updateDropdown()}}customElements.get("db-search-bar")||customElements.define("db-search-bar",DbSearchBar);export{DbSearchBar};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
interface DownloadStore {
|
|
2
|
+
store: 'app-store' | 'google-play';
|
|
3
|
+
href?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
storeName?: string;
|
|
6
|
+
size?: string;
|
|
7
|
+
theme?: string;
|
|
8
|
+
}
|
|
9
|
+
declare class DbSectionAppDownload extends HTMLElement {
|
|
10
|
+
static get observedAttributes(): string[];
|
|
11
|
+
private built;
|
|
12
|
+
private sectionEl?;
|
|
13
|
+
private wrapEl?;
|
|
14
|
+
private innerEl?;
|
|
15
|
+
private titleEl?;
|
|
16
|
+
private descriptionEl?;
|
|
17
|
+
private badgesEl?;
|
|
18
|
+
connectedCallback(): void;
|
|
19
|
+
attributeChangedCallback(): void;
|
|
20
|
+
get stores(): DownloadStore[];
|
|
21
|
+
set stores(value: DownloadStore[] | string);
|
|
22
|
+
private parseStores;
|
|
23
|
+
private build;
|
|
24
|
+
private updateUI;
|
|
25
|
+
}
|
|
26
|
+
declare global {
|
|
27
|
+
interface HTMLElementTagNameMap {
|
|
28
|
+
'db-section-app-download': DbSectionAppDownload;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { DbSectionAppDownload };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t="designbase-wc-section-app-download";class DbSectionAppDownload extends HTMLElement{constructor(){super(...arguments),this.built=!1}static get observedAttributes(){return["title","description","stores","align","size","full-width","full-height","overflow-visible"]}connectedCallback(){this.style.display="block",this.built||(this.built=!0,this.build()),this.updateUI()}attributeChangedCallback(){this.built&&this.updateUI()}get stores(){return this.parseStores()}set stores(t){this.setAttribute("stores","string"==typeof t?t:JSON.stringify(t))}parseStores(){try{const t=JSON.parse(this.getAttribute("stores")||"[]");if(Array.isArray(t)&&t.length>0)return t}catch{}return[{store:"app-store",href:"#"},{store:"google-play",href:"#"}]}build(){this.sectionEl=document.createElement("db-section"),this.sectionEl.setAttribute("no-padding",""),this.sectionEl.setAttribute("data-wc-internal",""),this.wrapEl=document.createElement("div"),this.wrapEl.className=t,this.innerEl=document.createElement("div"),this.innerEl.className=`${t}__inner`,this.titleEl=document.createElement("h2"),this.titleEl.className=`${t}__title`,this.descriptionEl=document.createElement("p"),this.descriptionEl.className=`${t}__description`,this.badgesEl=document.createElement("div"),this.badgesEl.className=`${t}__badges`,this.innerEl.append(this.titleEl,this.descriptionEl,this.badgesEl),this.wrapEl.append(this.innerEl),this.sectionEl.append(this.wrapEl),this.append(this.sectionEl)}updateUI(){const e=this.getAttribute("title")||"지금 바로 시작하세요",i=this.getAttribute("description")||"앱을 다운로드하고 바로 이용해 보세요.",s=this.getAttribute("align")||"center",l=this.getAttribute("size")||"l",r=this.parseStores(),n=[t,`${t}--${s}`].join(" ");this.className=t,this.wrapEl&&(this.wrapEl.className=n),this.sectionEl&&(this.sectionEl.setAttribute("size",l),this.hasAttribute("full-width")?this.sectionEl.setAttribute("full-width",""):this.sectionEl.removeAttribute("full-width"),this.hasAttribute("full-height")?this.sectionEl.setAttribute("full-height",""):this.sectionEl.removeAttribute("full-height"),this.hasAttribute("overflow-visible")?this.sectionEl.setAttribute("overflow-visible",""):this.sectionEl.removeAttribute("overflow-visible")),this.titleEl&&(this.titleEl.textContent=e),this.descriptionEl&&(this.descriptionEl.textContent=i,this.descriptionEl.hidden=!i),this.badgesEl&&(this.badgesEl.replaceChildren(),r.forEach(t=>{const e=document.createElement("db-app-badge");e.setAttribute("store",t.store),e.setAttribute("size",t.size||"m"),e.setAttribute("theme",t.theme||"dark"),t.href&&e.setAttribute("href",t.href),t.label&&e.setAttribute("label",t.label),t.storeName&&e.setAttribute("store-name",t.storeName),this.badgesEl.append(e)}))}}customElements.get("db-section-app-download")||customElements.define("db-section-app-download",DbSectionAppDownload);export{DbSectionAppDownload};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare class DbSectionContact extends HTMLElement {
|
|
2
|
+
static get observedAttributes(): string[];
|
|
3
|
+
private built;
|
|
4
|
+
private sectionEl?;
|
|
5
|
+
private wrapEl?;
|
|
6
|
+
private contactWrapEl?;
|
|
7
|
+
private titleEl?;
|
|
8
|
+
private descriptionEl?;
|
|
9
|
+
private actionEl?;
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
attributeChangedCallback(): void;
|
|
12
|
+
private parseAction;
|
|
13
|
+
private build;
|
|
14
|
+
private updateUI;
|
|
15
|
+
}
|
|
16
|
+
declare global {
|
|
17
|
+
interface HTMLElementTagNameMap {
|
|
18
|
+
'db-section-contact': DbSectionContact;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { DbSectionContact };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t="designbase-wc-section-contact",i="contact@designbase.co.kr";class DbSectionContact extends HTMLElement{constructor(){super(...arguments),this.built=!1}static get observedAttributes(){return["title","description","action","align","accent","content-padding","size","full-width","full-height","overflow-visible"]}connectedCallback(){this.style.display="block",this.built||(this.built=!0,this.build()),this.updateUI()}attributeChangedCallback(){this.built&&this.updateUI()}parseAction(){try{const t=this.getAttribute("action");if(t)return JSON.parse(t)}catch{}return{label:i,href:`mailto:${i}`}}build(){this.sectionEl=document.createElement("db-section"),this.sectionEl.setAttribute("no-padding",""),this.sectionEl.setAttribute("data-wc-internal",""),this.wrapEl=document.createElement("div"),this.wrapEl.className=t,this.contactWrapEl=document.createElement("div"),this.contactWrapEl.className=`${t}__inner`,this.titleEl=document.createElement("h2"),this.titleEl.className=`${t}__title`,this.descriptionEl=document.createElement("p"),this.descriptionEl.className=`${t}__description`,this.actionEl=document.createElement("db-button"),this.actionEl.className=`${t}__action`,this.actionEl.setAttribute("variant","primary"),this.actionEl.setAttribute("size","m"),this.actionEl.setAttribute("radius","pill"),this.actionEl.setAttribute("start-icon","mail"),this.actionEl.addEventListener("click",t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("db-action",{detail:{action:this.parseAction()},bubbles:!0,composed:!0}))}),this.contactWrapEl.append(this.titleEl,this.descriptionEl,this.actionEl),this.wrapEl.append(this.contactWrapEl),this.sectionEl.append(this.wrapEl),this.append(this.sectionEl)}updateUI(){const i=this.getAttribute("title")||"문의하기",e=this.getAttribute("description")||"궁금한 점이 있으시면 언제든지 연락주세요.",s=this.getAttribute("align")||"center",n=this.getAttribute("content-padding")||"l",l=this.getAttribute("size")||"l",c=!this.hasAttribute("accent")||"false"!==this.getAttribute("accent"),a=this.parseAction(),o=[t,`${t}--${s}`,`${t}--padding-${n}`,c&&`${t}--accent`].filter(Boolean).join(" ");this.className=t,this.wrapEl&&(this.wrapEl.className=o),this.contactWrapEl&&(this.contactWrapEl.className=`${t}__inner`),this.sectionEl&&(this.sectionEl.setAttribute("size",l),this.hasAttribute("full-width")?this.sectionEl.setAttribute("full-width",""):this.sectionEl.removeAttribute("full-width"),this.hasAttribute("full-height")?this.sectionEl.setAttribute("full-height",""):this.sectionEl.removeAttribute("full-height"),this.hasAttribute("overflow-visible")?this.sectionEl.setAttribute("overflow-visible",""):this.sectionEl.removeAttribute("overflow-visible")),this.titleEl&&(this.titleEl.textContent=i),this.descriptionEl&&(this.descriptionEl.textContent=e,this.descriptionEl.hidden=!e),this.actionEl&&(this.actionEl.textContent=a.label,a.href?this.actionEl.setAttribute("href",a.href):this.actionEl.removeAttribute("href"))}}customElements.get("db-section-contact")||customElements.define("db-section-contact",DbSectionContact);export{DbSectionContact};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface FeatureAction {
|
|
2
|
+
label: string;
|
|
3
|
+
variant?: string;
|
|
4
|
+
size?: string;
|
|
5
|
+
href?: string;
|
|
6
|
+
}
|
|
7
|
+
declare class DbSectionFeature extends HTMLElement {
|
|
8
|
+
static get observedAttributes(): string[];
|
|
9
|
+
private built;
|
|
10
|
+
private sectionEl?;
|
|
11
|
+
private featureWrapEl?;
|
|
12
|
+
private badgeEl?;
|
|
13
|
+
private headlineEl?;
|
|
14
|
+
private subtitleEl?;
|
|
15
|
+
private descriptionEl?;
|
|
16
|
+
private actionsEl?;
|
|
17
|
+
private mediaEl?;
|
|
18
|
+
private imageEl?;
|
|
19
|
+
connectedCallback(): void;
|
|
20
|
+
attributeChangedCallback(): void;
|
|
21
|
+
private parseBadge;
|
|
22
|
+
get actions(): FeatureAction[];
|
|
23
|
+
set actions(value: FeatureAction[] | string);
|
|
24
|
+
private parseActions;
|
|
25
|
+
private build;
|
|
26
|
+
private updateUI;
|
|
27
|
+
}
|
|
28
|
+
declare global {
|
|
29
|
+
interface HTMLElementTagNameMap {
|
|
30
|
+
'db-section-feature': DbSectionFeature;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { DbSectionFeature };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t="designbase-wc-section-feature";class DbSectionFeature extends HTMLElement{constructor(){super(...arguments),this.built=!1}static get observedAttributes(){return["headline","subtitle","description","badge","image","image-alt","media-position","actions","tinted","content-padding","size","full-width","full-height","overflow-visible"]}connectedCallback(){this.style.display="block",this.built||(this.built=!0,this.build()),this.updateUI()}attributeChangedCallback(){this.built&&this.updateUI()}parseBadge(){try{const t=this.getAttribute("badge");return t?JSON.parse(t):null}catch{return null}}get actions(){return this.parseActions()}set actions(t){this.setAttribute("actions","string"==typeof t?t:JSON.stringify(t))}parseActions(){try{const t=JSON.parse(this.getAttribute("actions")||"[]");return Array.isArray(t)?t:[]}catch{return[]}}build(){this.sectionEl=document.createElement("db-section"),this.sectionEl.setAttribute("no-padding",""),this.sectionEl.setAttribute("data-wc-internal",""),this.featureWrapEl=document.createElement("div"),this.featureWrapEl.className=t;const e=document.createElement("div");e.className=`${t}__inner`;const i=document.createElement("div");i.className=`${t}__content`,this.badgeEl=document.createElement("db-badge"),this.badgeEl.className=`${t}__badge`,this.badgeEl.hidden=!0,this.headlineEl=document.createElement("h2"),this.headlineEl.className=`${t}__headline`,this.subtitleEl=document.createElement("p"),this.subtitleEl.className=`${t}__subtitle`,this.descriptionEl=document.createElement("p"),this.descriptionEl.className=`${t}__description`,this.actionsEl=document.createElement("div"),this.actionsEl.className=`${t}__actions`,i.append(this.badgeEl,this.headlineEl,this.subtitleEl,this.descriptionEl,this.actionsEl),this.mediaEl=document.createElement("div"),this.mediaEl.className=`${t}__media`,this.imageEl=document.createElement("img"),this.imageEl.className=`${t}__image`,this.mediaEl.append(this.imageEl),e.append(i,this.mediaEl),this.featureWrapEl.append(e),this.sectionEl.append(this.featureWrapEl),this.append(this.sectionEl)}updateUI(){const e=this.getAttribute("headline")||"",i=this.getAttribute("subtitle")||"",s=this.getAttribute("description")||"",a=this.getAttribute("image")||"",l=this.getAttribute("image-alt")||e||"feature",n=this.getAttribute("media-position")||"right",h=this.getAttribute("content-padding")||"l",r=this.getAttribute("size")||"l",d=this.hasAttribute("tinted"),c=this.parseBadge(),o=this.parseActions(),u=[t,`${t}--media-${n}`,`${t}--padding-${h}`,d&&`${t}--tinted`].filter(Boolean).join(" ");this.className=t,this.featureWrapEl&&(this.featureWrapEl.className=u),this.sectionEl&&(this.sectionEl.setAttribute("size",r),this.hasAttribute("full-width")?this.sectionEl.setAttribute("full-width",""):this.sectionEl.removeAttribute("full-width"),this.hasAttribute("full-height")?this.sectionEl.setAttribute("full-height",""):this.sectionEl.removeAttribute("full-height"),this.hasAttribute("overflow-visible")?this.sectionEl.setAttribute("overflow-visible",""):this.sectionEl.removeAttribute("overflow-visible")),this.badgeEl&&(c?.text?(this.badgeEl.hidden=!1,this.badgeEl.setAttribute("variant",c.variant||"primary"),this.badgeEl.setAttribute("badge-style",c.style||"text"),this.badgeEl.setAttribute("size",c.size||"m"),this.badgeEl.textContent=c.text):this.badgeEl.hidden=!0),this.headlineEl&&(this.headlineEl.textContent=e),this.subtitleEl&&(this.subtitleEl.textContent=i,this.subtitleEl.hidden=!i),this.descriptionEl&&(this.descriptionEl.textContent=s,this.descriptionEl.hidden=!s),this.mediaEl&&this.imageEl&&(a?(this.mediaEl.hidden=!1,this.imageEl.src=a,this.imageEl.alt=l):this.mediaEl.hidden=!0),this.actionsEl&&(this.actionsEl.replaceChildren(),o.length>0?(o.forEach(t=>{const e=document.createElement("db-button");e.setAttribute("variant",t.variant||"primary"),e.setAttribute("size",t.size||"m"),t.href&&e.setAttribute("href",t.href),e.textContent=t.label,e.addEventListener("click",e=>{e.stopPropagation(),this.dispatchEvent(new CustomEvent("db-action",{detail:{action:t},bubbles:!0,composed:!0}))}),this.actionsEl.append(e)}),this.actionsEl.hidden=!1):this.actionsEl.hidden=!0)}}customElements.get("db-section-feature")||customElements.define("db-section-feature",DbSectionFeature);export{DbSectionFeature};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface HeroButton {
|
|
2
|
+
text: string;
|
|
3
|
+
href?: string;
|
|
4
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'outline' | 'ghost';
|
|
5
|
+
size?: 's' | 'm' | 'l';
|
|
6
|
+
external?: boolean;
|
|
7
|
+
startIcon?: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
}
|
|
10
|
+
declare class DbSectionHero extends HTMLElement {
|
|
11
|
+
static get observedAttributes(): string[];
|
|
12
|
+
private built;
|
|
13
|
+
private backgroundVideoEl?;
|
|
14
|
+
private backgroundImageEl?;
|
|
15
|
+
private overlayEl?;
|
|
16
|
+
private titleEl?;
|
|
17
|
+
private subtitleEl?;
|
|
18
|
+
private descriptionEl?;
|
|
19
|
+
private buttonsEl?;
|
|
20
|
+
connectedCallback(): void;
|
|
21
|
+
attributeChangedCallback(): void;
|
|
22
|
+
get buttons(): HeroButton[];
|
|
23
|
+
set buttons(value: HeroButton[] | string);
|
|
24
|
+
private parseButtons;
|
|
25
|
+
private build;
|
|
26
|
+
private updateUI;
|
|
27
|
+
}
|
|
28
|
+
declare global {
|
|
29
|
+
interface HTMLElementTagNameMap {
|
|
30
|
+
'db-section-hero': DbSectionHero;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { DbSectionHero };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t="designbase-wc-section-hero";class DbSectionHero extends HTMLElement{constructor(){super(...arguments),this.built=!1}static get observedAttributes(){return["title","subtitle","description","background-image","background-video","overlay-color","overlay-opacity","buttons","variant","theme","alignment","animated","full-height","min-height","max-height","content-max-width"]}connectedCallback(){this.style.display="block",this.built||(this.built=!0,this.build()),this.updateUI()}attributeChangedCallback(){this.built&&this.updateUI()}get buttons(){return this.parseButtons()}set buttons(t){this.setAttribute("buttons","string"==typeof t?t:JSON.stringify(t))}parseButtons(){try{const t=JSON.parse(this.getAttribute("buttons")||"[]");return Array.isArray(t)?t:[]}catch{return[]}}build(){this.backgroundVideoEl=document.createElement("video"),this.backgroundVideoEl.className=`${t}__background-video`,this.backgroundVideoEl.autoplay=!0,this.backgroundVideoEl.muted=!0,this.backgroundVideoEl.loop=!0,this.backgroundVideoEl.playsInline=!0,this.backgroundVideoEl.hidden=!0,this.backgroundImageEl=document.createElement("div"),this.backgroundImageEl.className=`${t}__background-image`,this.backgroundImageEl.hidden=!0,this.overlayEl=document.createElement("div"),this.overlayEl.className=`${t}__overlay`,this.overlayEl.hidden=!0;const e=document.createElement("div");e.className=`${t}__container`;const i=document.createElement("div");i.className=`${t}__content`,this.titleEl=document.createElement("h1"),this.titleEl.className=`${t}__title`,this.subtitleEl=document.createElement("p"),this.subtitleEl.className=`${t}__subtitle`,this.descriptionEl=document.createElement("p"),this.descriptionEl.className=`${t}__description`,this.buttonsEl=document.createElement("div"),this.buttonsEl.className=`${t}__buttons`,i.append(this.titleEl,this.subtitleEl,this.descriptionEl,this.buttonsEl),e.append(i),this.append(this.backgroundVideoEl,this.backgroundImageEl,this.overlayEl,e)}updateUI(){const e=this.getAttribute("title")||"",i=this.getAttribute("subtitle")||"",s=this.getAttribute("description")||"",n=this.getAttribute("background-image")||"",a=this.getAttribute("background-video")||"",o=this.getAttribute("overlay-color")||"",r=Number(this.getAttribute("overlay-opacity")||.5),l=this.getAttribute("variant")||"default",d=this.getAttribute("theme")||"light",c=this.getAttribute("alignment")||"left",h=this.hasAttribute("animated"),u=this.hasAttribute("full-height"),b=this.getAttribute("min-height"),g=this.getAttribute("max-height"),m=this.getAttribute("content-max-width"),E=this.parseButtons(),p=Boolean(n||a),y="dark"===d||"gradient"===d||p&&("overlay"===l||"image"===d);this.className=[t,`${t}--variant-${l}`,`${t}--theme-${d}`,`${t}--alignment-${c}`,h&&`${t}--animated`,u&&`${t}--full-height`,y&&`${t}--on-media`].filter(Boolean).join(" "),this.style.minHeight=b||"",this.style.maxHeight=g||"",this.titleEl&&(this.titleEl.textContent=e),this.subtitleEl&&(this.subtitleEl.textContent=i,this.subtitleEl.hidden=!i),this.descriptionEl&&(this.descriptionEl.textContent=s,this.descriptionEl.hidden=!s);const k=this.querySelector(`.${t}__content`);if(k&&(m?k.style.maxWidth=/^\d+$/.test(m)?`${m}px`:m:k.style.removeProperty("max-width")),this.backgroundVideoEl)if(a){this.backgroundVideoEl.hidden=!1,this.backgroundVideoEl.replaceChildren();const t=document.createElement("source");t.src=a,t.type="video/mp4",this.backgroundVideoEl.append(t)}else this.backgroundVideoEl.hidden=!0;this.backgroundImageEl&&(n?(this.backgroundImageEl.hidden=!1,this.backgroundImageEl.style.backgroundImage=`url(${n})`,this.backgroundImageEl.style.backgroundSize="cover",this.backgroundImageEl.style.backgroundPosition="center",this.backgroundImageEl.style.backgroundRepeat="no-repeat"):this.backgroundImageEl.hidden=!0),this.overlayEl&&(p?(this.overlayEl.hidden=!1,o?(this.overlayEl.style.background=o,this.overlayEl.style.opacity=String(r)):(this.overlayEl.style.background=`linear-gradient(180deg, rgba(0, 0, 0, ${.35*r}) 0%, rgba(0, 0, 0, ${r}) 100%)`,this.overlayEl.style.opacity="1")):this.overlayEl.hidden=!0),this.buttonsEl&&(this.buttonsEl.replaceChildren(),E.length>0?(E.forEach(e=>{const i=document.createElement("db-button");if(i.setAttribute("variant",function mapButtonVariant(t){return"outline"===t?"tertiary":"ghost"===t?"ghost":"secondary"===t?"secondary":"tertiary"===t?"tertiary":"primary"}(e.variant)),i.setAttribute("size",e.size||"m"),e.href&&i.setAttribute("href",e.href),e.external&&(i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer")),e.startIcon)i.setAttribute("start-icon",e.startIcon),i.textContent=e.text;else if(e.icon){const s=document.createElement("span");s.className=`${t}__button-content`;const n=document.createElement("span");n.className=`${t}__button-icon`,n.setAttribute("aria-hidden","true"),n.textContent=e.icon;const a=document.createElement("span");a.textContent=e.text,s.append(n,a),i.append(s)}else i.textContent=e.text;i.addEventListener("click",t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("db-button-click",{detail:{button:e},bubbles:!0,composed:!0}))}),this.buttonsEl.append(i)}),this.buttonsEl.hidden=!1):this.buttonsEl.hidden=!0)}}customElements.get("db-section-hero")||customElements.define("db-section-hero",DbSectionHero);export{DbSectionHero};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
declare class DbSection extends HTMLElement {
|
|
2
|
+
static get observedAttributes(): string[];
|
|
3
|
+
private headerEl?;
|
|
4
|
+
private bodyEl?;
|
|
5
|
+
private bodyInnerEl?;
|
|
6
|
+
private contentEl?;
|
|
7
|
+
private footerEl?;
|
|
8
|
+
private actionsHostEl?;
|
|
9
|
+
private tabsEl?;
|
|
10
|
+
private contentId;
|
|
11
|
+
private internalExpanded;
|
|
12
|
+
private internalTabId;
|
|
13
|
+
private observer?;
|
|
14
|
+
connectedCallback(): void;
|
|
15
|
+
disconnectedCallback(): void;
|
|
16
|
+
attributeChangedCallback(name: string): void;
|
|
17
|
+
private syncDefaultTab;
|
|
18
|
+
private parseTabs;
|
|
19
|
+
private getActiveTabId;
|
|
20
|
+
private hasHeaderTabs;
|
|
21
|
+
private isCollapsible;
|
|
22
|
+
private isExpanded;
|
|
23
|
+
private isUserNode;
|
|
24
|
+
private collectSlotted;
|
|
25
|
+
private collectContentNodes;
|
|
26
|
+
private ensureStructure;
|
|
27
|
+
private mountBody;
|
|
28
|
+
private getChevronSize;
|
|
29
|
+
private createTitleArea;
|
|
30
|
+
private createChevron;
|
|
31
|
+
private handleToggle;
|
|
32
|
+
private handleTabChange;
|
|
33
|
+
private renderHeader;
|
|
34
|
+
private syncHostClasses;
|
|
35
|
+
private syncCollapsibleState;
|
|
36
|
+
private sync;
|
|
37
|
+
}
|
|
38
|
+
declare global {
|
|
39
|
+
interface HTMLElementTagNameMap {
|
|
40
|
+
'db-section': DbSection;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { DbSection };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createDbIcon as e}from"./db-icons.js";const t=["s","m","l","xl"];class DbSection extends HTMLElement{constructor(){super(...arguments),this.contentId=`db-section-${Math.random().toString(36).slice(2,9)}`,this.internalExpanded=!0,this.internalTabId="",this.handleToggle=()=>{if(!this.isCollapsible())return;const e=!this.isExpanded();this.hasAttribute("expanded")||(this.internalExpanded=e),this.dispatchEvent(new CustomEvent("db-expanded-change",{bubbles:!0,composed:!0,detail:{expanded:e}})),this.hasAttribute("expanded")||(this.syncHostClasses(),this.syncCollapsibleState())},this.handleTabChange=e=>{const t=e.detail,s=t?.id??this.parseTabs()[t?.index??0]?.id??String(t?.index??0);this.internalTabId=s,this.tabsEl?.setAttribute("selected-id",s),this.dispatchEvent(new CustomEvent("db-tab-change",{bubbles:!0,composed:!0,detail:{tabId:s}}))}}static get observedAttributes(){return["title","subtitle","description","size","collapsible","default-expanded","expanded","no-padding","full-width","full-height","overflow-visible","tabs","selected-tab-id","default-selected-tab-id"]}connectedCallback(){this.internalExpanded="false"!==this.getAttribute("default-expanded"),this.syncDefaultTab(),this.ensureStructure(),this.sync(),this.observer=new MutationObserver(()=>this.sync()),this.observer.observe(this,{childList:!0})}disconnectedCallback(){this.observer?.disconnect()}attributeChangedCallback(e){if(this.isConnected){if("default-expanded"!==e||this.hasAttribute("expanded")||(this.internalExpanded="false"!==this.getAttribute("default-expanded")),"default-selected-tab-id"!==e&&"tabs"!==e||this.syncDefaultTab(),"selected-tab-id"===e){const e=this.getAttribute("selected-tab-id");e&&(this.internalTabId=e)}this.sync()}}syncDefaultTab(){if(this.internalTabId)return;const e=this.parseTabs(),t=this.getAttribute("default-selected-tab-id")||"";this.internalTabId=t||e[0]?.id||""}parseTabs(){try{const e=JSON.parse(this.getAttribute("tabs")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}getActiveTabId(){const e=this.getAttribute("selected-tab-id");return e&&this.internalTabId&&e!==this.internalTabId?this.internalTabId:e||this.internalTabId||this.tabsEl?.getAttribute("selected-id")||""}hasHeaderTabs(){return this.parseTabs().length>0&&!this.isCollapsible()}isCollapsible(){return this.hasAttribute("collapsible")}isExpanded(){return!this.isCollapsible()||(this.hasAttribute("expanded")?"false"!==this.getAttribute("expanded"):this.internalExpanded)}isUserNode(e){return!e.hasAttribute("data-wc-internal")}collectSlotted(e){const t=Array.from(this.querySelectorAll(`:scope > [slot="${e}"]`)).filter(this.isUserNode);if(t.length)return t;if("actions"===e&&this.actionsHostEl)return Array.from(this.actionsHostEl.children);if("footer"===e&&this.footerEl)return Array.from(this.footerEl.children);if("header"===e){const e=this.headerEl?.querySelector(".designbase-wc-section__header-main");return e?Array.from(e.children):[]}if("description"===e){const e=this.headerEl?.querySelector(".designbase-wc-section__description"),t=e?.firstElementChild;return t?[t]:[]}return[]}collectContentNodes(){const e=Array.from(this.children).filter(e=>{if(!this.isUserNode(e))return!1;const t=e.getAttribute("slot");return!t||"default"===t});return e.length?e:this.contentEl?Array.from(this.contentEl.children):[]}ensureStructure(){this.headerEl||(this.headerEl=document.createElement("div"),this.headerEl.className="designbase-wc-section__header",this.headerEl.setAttribute("data-wc-internal","")),this.bodyEl||(this.bodyEl=document.createElement("div"),this.bodyEl.className="designbase-wc-section__body",this.bodyEl.id=this.contentId,this.bodyEl.setAttribute("data-wc-internal",""),this.bodyInnerEl=document.createElement("div"),this.bodyInnerEl.className="designbase-wc-section__body-inner",this.bodyInnerEl.setAttribute("data-wc-internal",""),this.bodyEl.append(this.bodyInnerEl)),this.contentEl||(this.contentEl=document.createElement("div"),this.contentEl.className="designbase-wc-section__content",this.contentEl.setAttribute("data-wc-internal","")),this.footerEl||(this.footerEl=document.createElement("div"),this.footerEl.className="designbase-wc-section__footer",this.footerEl.setAttribute("data-wc-internal","")),this.headerEl.isConnected||this.append(this.headerEl)}mountBody(){const e=this.collectContentNodes(),t=this.collectSlotted("footer");if(this.contentEl.replaceChildren(...e),this.footerEl.replaceChildren(...t),this.footerEl.hidden=0===t.length,this.isCollapsible())return this.bodyInnerEl.replaceChildren(this.contentEl,this.footerEl),void(this.bodyEl.isConnected||this.append(this.bodyEl));this.bodyEl?.remove(),this.contentEl.isConnected||this.append(this.contentEl),t.length?this.footerEl.isConnected||this.append(this.footerEl):this.footerEl.remove()}getChevronSize(){const e=this.getAttribute("size")||"m";return"s"===e?16:"l"===e||"xl"===e?24:20}createTitleArea(){const e=this.getAttribute("title"),t=this.getAttribute("subtitle"),s=this.getAttribute("description"),i=this.collectSlotted("description")[0];if(!(e||t||s||i))return null;const n=document.createElement("div");if(n.className="designbase-wc-section__title-area",e){const t=document.createElement("h2");t.className="designbase-wc-section__title",t.textContent=e,n.append(t)}if(t){const e=document.createElement("h3");e.className="designbase-wc-section__subtitle",e.textContent=t,n.append(e)}if(i){const e=document.createElement("p");e.className="designbase-wc-section__description",e.append(i),n.append(e)}else if(s){const e=document.createElement("p");e.className="designbase-wc-section__description",e.textContent=s,n.append(e)}return n}createChevron(){const t=document.createElement("span");return t.className="designbase-wc-section__chevron",t.setAttribute("aria-hidden","true"),t.append(e("chevron-down",this.getChevronSize())),t}renderHeader(){if(!this.headerEl)return;const e=this.collectSlotted("header")[0],t=this.collectSlotted("actions"),s=this.createTitleArea(),i=this.hasHeaderTabs(),n=Boolean(e||s||t.length);if(this.headerEl.replaceChildren(),this.headerEl.hidden=!n&&!i,this.headerEl.classList.toggle("designbase-wc-section__header--with-tabs",i),!n&&!i)return;if(this.isCollapsible()){if(e){const t=document.createElement("button");t.type="button",t.className="designbase-wc-section__header-trigger",t.setAttribute("aria-expanded",String(this.isExpanded())),t.setAttribute("aria-controls",this.contentId),t.addEventListener("click",this.handleToggle);const s=document.createElement("div");s.className="designbase-wc-section__header-main",s.append(e),t.append(s,this.createChevron()),this.headerEl.append(t)}else{const e=document.createElement("button");e.type="button",e.className="designbase-wc-section__header-trigger",e.setAttribute("aria-expanded",String(this.isExpanded())),e.setAttribute("aria-controls",this.contentId),e.addEventListener("click",this.handleToggle),s&&e.append(s),e.append(this.createChevron()),this.headerEl.append(e),t.length&&(this.actionsHostEl=document.createElement("div"),this.actionsHostEl.className="designbase-wc-section__actions",this.actionsHostEl.addEventListener("click",e=>e.stopPropagation()),t.forEach(e=>this.actionsHostEl.append(e)),this.headerEl.append(this.actionsHostEl))}return}const appendHeaderMain=i=>{e?i.append(e):(s&&i.append(s),t.length&&(this.actionsHostEl=document.createElement("div"),this.actionsHostEl.className="designbase-wc-section__actions",t.forEach(e=>this.actionsHostEl.append(e)),i.append(this.actionsHostEl)))};if(i){const e=document.createElement("div");e.className="designbase-wc-section__header-row",appendHeaderMain(e),this.headerEl.append(e);const t=document.createElement("div");return t.className="designbase-wc-section__header-tabs",this.tabsEl||(this.tabsEl=document.createElement("db-tabs"),this.tabsEl.setAttribute("size","m"),this.tabsEl.addEventListener("db-change",this.handleTabChange)),this.tabsEl.setAttribute("items",JSON.stringify(this.parseTabs())),this.tabsEl.setAttribute("selected-id",this.getActiveTabId()),t.append(this.tabsEl),void this.headerEl.append(t)}appendHeaderMain(this.headerEl)}syncHostClasses(){const e=this.getAttribute("size")||"m",s=t.includes(e)?e:"m",i=this.isExpanded();this.className=["designbase-wc-section",`designbase-wc-section--size-${s}`,this.hasAttribute("no-padding")&&"designbase-wc-section--no-padding",this.hasHeaderTabs()&&"designbase-wc-section--has-header-tabs",this.hasAttribute("full-width")&&"designbase-wc-section--full-width",this.hasAttribute("full-height")&&"designbase-wc-section--full-height",this.hasAttribute("overflow-visible")&&"designbase-wc-section--overflow-visible",this.isCollapsible()&&"designbase-wc-section--collapsible",this.isCollapsible()&&i&&"designbase-wc-section--expanded",this.isCollapsible()&&!i&&"designbase-wc-section--collapsed"].filter(Boolean).join(" ")}syncCollapsibleState(){if(!this.isCollapsible()||!this.bodyEl)return;const e=this.isExpanded();this.bodyEl.setAttribute("aria-hidden",String(!e));const t=this.headerEl?.querySelector(".designbase-wc-section__header-trigger");t?.setAttribute("aria-expanded",String(e))}sync(){this.ensureStructure(),this.syncHostClasses(),this.renderHeader(),this.mountBody(),this.syncCollapsibleState()}}customElements.get("db-section")||customElements.define("db-section",DbSection);export{DbSection};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SegmentControl Web Component
|
|
3
|
+
* packages/ui SegmentControl.tsx와 DOM·동작·스타일 1:1 동기화
|
|
4
|
+
*/
|
|
5
|
+
interface DbSegmentOptionData {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
icon?: string;
|
|
10
|
+
}
|
|
11
|
+
declare class DbSegmentControl extends HTMLElement {
|
|
12
|
+
static get observedAttributes(): string[];
|
|
13
|
+
private built;
|
|
14
|
+
private indicatorEl;
|
|
15
|
+
private segmentButtons;
|
|
16
|
+
private focusedIndex;
|
|
17
|
+
private boundKeyDown;
|
|
18
|
+
private boundResize;
|
|
19
|
+
private resizeObserver;
|
|
20
|
+
connectedCallback(): void;
|
|
21
|
+
disconnectedCallback(): void;
|
|
22
|
+
attributeChangedCallback(name: string): void;
|
|
23
|
+
get options(): DbSegmentOptionData[];
|
|
24
|
+
set options(value: DbSegmentOptionData[] | string);
|
|
25
|
+
get value(): string;
|
|
26
|
+
set value(value: string);
|
|
27
|
+
private parseOptions;
|
|
28
|
+
private render;
|
|
29
|
+
private updateSelection;
|
|
30
|
+
private updateIndicator;
|
|
31
|
+
private select;
|
|
32
|
+
private handleKeyDown;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
'db-segment-control': DbSegmentControl;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { DbSegmentControl };
|
|
41
|
+
export type { DbSegmentOptionData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="designbase-wc-segment-control",t={bar:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="12" width="4" height="8"/><rect x="10" y="8" width="4" height="12"/><rect x="17" y="4" width="4" height="16"/></svg>',line:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="4 16 9 10 14 13 20 6"/></svg>',pie:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2v10l8.66 5"/><circle cx="12" cy="12" r="10"/></svg>',donut:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="8"/><circle cx="12" cy="12" r="3"/></svg>',radar:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 20 8 17 20 7 20 4 8"/></svg>'};class DbSegmentControl extends HTMLElement{constructor(){super(...arguments),this.built=!1,this.indicatorEl=null,this.segmentButtons=[],this.focusedIndex=-1,this.boundKeyDown=e=>this.handleKeyDown(e),this.boundResize=()=>this.updateIndicator(),this.resizeObserver=null}static get observedAttributes(){return["options","value","default-value","size","variant","appearance","full-width","disabled"]}connectedCallback(){this.built||(this.built=!0),this.render(),this.addEventListener("keydown",this.boundKeyDown),window.addEventListener("resize",this.boundResize),this.resizeObserver=new ResizeObserver(()=>this.updateIndicator()),this.resizeObserver.observe(this)}disconnectedCallback(){this.removeEventListener("keydown",this.boundKeyDown),window.removeEventListener("resize",this.boundResize),this.resizeObserver?.disconnect(),this.resizeObserver=null}attributeChangedCallback(e){this.built&&("value"!==e?this.render():this.updateSelection())}get options(){return this.parseOptions(this.getAttribute("options"))}set options(e){this.setAttribute("options","string"==typeof e?e:JSON.stringify(e))}get value(){return this.getAttribute("value")||this.getAttribute("default-value")||this.options[0]?.value||""}set value(e){this.setAttribute("value",e)}parseOptions(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}render(){const i=this.getAttribute("size")||"m",s=this.getAttribute("variant")||"default",n=this.getAttribute("appearance")||"pill",r=this.hasAttribute("disabled"),o=this.options,a=this.value;this.className=[e,`${e}--${i}`,`${e}--${s}`,"rounded"===n&&`${e}--appearance-rounded`,this.hasAttribute("full-width")&&`${e}--full-width`,r&&`${e}--disabled`].filter(Boolean).join(" "),this.setAttribute("role","tablist"),this.setAttribute("aria-label","세그먼트 컨트롤"),this.replaceChildren(),this.segmentButtons=[],o.forEach((i,n)=>{const o=i.value===a,l=Boolean(r||i.disabled),d=document.createElement("button");if(d.type="button",d.className=[`${e}__segment`,o&&`${e}__segment--selected`,l&&`${e}__segment--disabled`].filter(Boolean).join(" "),d.setAttribute("role","tab"),d.setAttribute("aria-selected",String(o)),d.setAttribute("aria-disabled",String(l)),d.setAttribute("tabindex",o?"0":"-1"),d.disabled=l,i.icon&&t[i.icon]){const s=document.createElement("span");s.className=`${e}__segment-icon`,s.innerHTML=t[i.icon],d.appendChild(s)}const h=document.createElement("span");h.className=`${e}__segment-label`,h.textContent=i.label,"icon-only"===s&&h.setAttribute("aria-label",i.label),d.appendChild(h),d.addEventListener("click",()=>this.select(i.value)),d.addEventListener("focus",()=>{this.focusedIndex=n,d.classList.add(`${e}__segment--focused`)}),d.addEventListener("blur",()=>{this.focusedIndex=-1,d.classList.remove(`${e}__segment--focused`)}),this.appendChild(d),this.segmentButtons.push(d)}),this.indicatorEl=document.createElement("div"),this.indicatorEl.className=`${e}__indicator`,this.appendChild(this.indicatorEl),this.updateSelection()}updateSelection(){const t=this.options,i=this.value,s=t.findIndex(e=>e.value===i);this.segmentButtons.forEach((s,n)=>{const r=t[n],o=r?.value===i;s.classList.toggle(`${e}__segment--selected`,o),s.setAttribute("aria-selected",String(o)),s.setAttribute("tabindex",o?"0":"-1")}),this.indicatorEl&&t.length>0&&s>=0&&requestAnimationFrame(()=>this.updateIndicator())}updateIndicator(){const e=this.options.findIndex(e=>e.value===this.value),t=this.segmentButtons[e];this.indicatorEl&&t&&(this.indicatorEl.style.width=`${t.offsetWidth}px`,this.indicatorEl.style.transform=`translateX(${t.offsetLeft}px)`)}select(e){if(this.hasAttribute("disabled"))return;const t=this.options.find(t=>t.value===e);t&&!t.disabled&&(this.setAttribute("value",e),this.dispatchEvent(new CustomEvent("db-change",{detail:{value:e},bubbles:!0,composed:!0})))}handleKeyDown(e){if(this.hasAttribute("disabled"))return;const t=this.options,i=t.findIndex(e=>e.value===this.value);if(-1===i)return;let s=i;switch(e.key){case"ArrowLeft":e.preventDefault(),s=i>0?i-1:t.length-1;break;case"ArrowRight":e.preventDefault(),s=i<t.length-1?i+1:0;break;case"Home":e.preventDefault(),s=0;break;case"End":e.preventDefault(),s=t.length-1;break;case"Enter":case" ":return e.preventDefault(),void this.select(t[s]?.value??this.value);default:return}for(;s!==i;){const i=t[s];if(i&&!i.disabled){this.segmentButtons[s]?.focus();break}s="ArrowLeft"===e.key||"Home"===e.key?s>0?s-1:t.length-1:s<t.length-1?s+1:0}}}customElements.get("db-segment-control")||customElements.define("db-segment-control",DbSegmentControl);export{DbSegmentControl};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import './db-checkbox.js';
|
|
2
|
+
|
|
3
|
+
declare class DbSelect extends HTMLElement {
|
|
4
|
+
static readonly formAssociated = true;
|
|
5
|
+
static get observedAttributes(): string[];
|
|
6
|
+
private readonly internals;
|
|
7
|
+
private labelEl?;
|
|
8
|
+
private trigger?;
|
|
9
|
+
private valueEl?;
|
|
10
|
+
private indicatorsEl?;
|
|
11
|
+
private clearButton?;
|
|
12
|
+
private chevronEl?;
|
|
13
|
+
private dropdown?;
|
|
14
|
+
private searchWrap?;
|
|
15
|
+
private searchInput?;
|
|
16
|
+
private optionsEl?;
|
|
17
|
+
private helperEl?;
|
|
18
|
+
private errorEl?;
|
|
19
|
+
private built;
|
|
20
|
+
private searchTerm;
|
|
21
|
+
private focusedIndex;
|
|
22
|
+
get name(): string;
|
|
23
|
+
set name(value: string);
|
|
24
|
+
get open(): boolean;
|
|
25
|
+
set open(value: boolean);
|
|
26
|
+
get value(): string;
|
|
27
|
+
set value(value: string);
|
|
28
|
+
connectedCallback(): void;
|
|
29
|
+
disconnectedCallback(): void;
|
|
30
|
+
formResetCallback(): void;
|
|
31
|
+
formDisabledCallback(disabled: boolean): void;
|
|
32
|
+
attributeChangedCallback(name: string): void;
|
|
33
|
+
get multiple(): boolean;
|
|
34
|
+
set multiple(value: boolean);
|
|
35
|
+
get searchable(): boolean;
|
|
36
|
+
set searchable(value: boolean);
|
|
37
|
+
private get showClearButton();
|
|
38
|
+
private parseOptions;
|
|
39
|
+
private parseSelectedValues;
|
|
40
|
+
private setSelectedValues;
|
|
41
|
+
private getIconSize;
|
|
42
|
+
private syncIndicatorIcons;
|
|
43
|
+
private build;
|
|
44
|
+
private handleTriggerClick;
|
|
45
|
+
private handleTriggerFocus;
|
|
46
|
+
private handleTriggerBlur;
|
|
47
|
+
private handleClear;
|
|
48
|
+
private handleSearchInput;
|
|
49
|
+
private handleDocumentMouseDown;
|
|
50
|
+
private handleDocumentKeyDown;
|
|
51
|
+
private getFilteredOptions;
|
|
52
|
+
private selectOption;
|
|
53
|
+
private dispatchChange;
|
|
54
|
+
private syncState;
|
|
55
|
+
private syncOpenState;
|
|
56
|
+
private syncTrigger;
|
|
57
|
+
private syncOptions;
|
|
58
|
+
private escape;
|
|
59
|
+
}
|
|
60
|
+
declare global {
|
|
61
|
+
interface HTMLElementTagNameMap {
|
|
62
|
+
'db-select': DbSelect;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { DbSelect };
|