@liwe3/webcomponents 1.0.14 → 1.1.10
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/dist/AIMarkdownEditor.d.ts +35 -0
- package/dist/AIMarkdownEditor.d.ts.map +1 -0
- package/dist/AIMarkdownEditor.js +412 -0
- package/dist/AIMarkdownEditor.js.map +1 -0
- package/dist/AITextEditor.d.ts +183 -0
- package/dist/AITextEditor.d.ts.map +1 -0
- package/dist/AITextEditor.js +63 -27
- package/dist/AITextEditor.js.map +1 -1
- package/dist/ButtonToolbar.d.ts +35 -0
- package/dist/ButtonToolbar.d.ts.map +1 -0
- package/dist/ButtonToolbar.js +220 -0
- package/dist/ButtonToolbar.js.map +1 -0
- package/dist/CheckList.d.ts +31 -0
- package/dist/CheckList.d.ts.map +1 -0
- package/dist/CheckList.js +336 -0
- package/dist/CheckList.js.map +1 -0
- package/dist/ChunkUploader.d.ts +125 -0
- package/dist/ChunkUploader.d.ts.map +1 -0
- package/dist/ChunkUploader.js +756 -0
- package/dist/ChunkUploader.js.map +1 -0
- package/dist/ComicBalloon.d.ts +82 -0
- package/dist/ComicBalloon.d.ts.map +1 -0
- package/dist/ComicBalloon.js +346 -0
- package/dist/ComicBalloon.js.map +1 -0
- package/dist/ContainerBox.d.ts +112 -0
- package/dist/ContainerBox.d.ts.map +1 -0
- package/dist/ContainerBox.js +359 -0
- package/dist/ContainerBox.js.map +1 -0
- package/dist/DateSelector.d.ts +103 -0
- package/dist/DateSelector.d.ts.map +1 -0
- package/dist/Dialog.d.ts +102 -0
- package/dist/Dialog.d.ts.map +1 -0
- package/dist/Dialog.js +299 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/Drawer.d.ts +63 -0
- package/dist/Drawer.d.ts.map +1 -0
- package/dist/Drawer.js +340 -0
- package/dist/Drawer.js.map +1 -0
- package/dist/ImageView.d.ts +42 -0
- package/dist/ImageView.d.ts.map +1 -0
- package/dist/ImageView.js +209 -0
- package/dist/ImageView.js.map +1 -0
- package/dist/MarkdownPreview.d.ts +25 -0
- package/dist/MarkdownPreview.d.ts.map +1 -0
- package/dist/MarkdownPreview.js +147 -0
- package/dist/MarkdownPreview.js.map +1 -0
- package/dist/PopoverMenu.d.ts +103 -0
- package/dist/PopoverMenu.d.ts.map +1 -0
- package/dist/ResizableCropper.d.ts +158 -0
- package/dist/ResizableCropper.d.ts.map +1 -0
- package/dist/ResizableCropper.js +562 -0
- package/dist/ResizableCropper.js.map +1 -0
- package/dist/SmartSelect.d.ts +100 -0
- package/dist/SmartSelect.d.ts.map +1 -0
- package/dist/SmartSelect.js +45 -2
- package/dist/SmartSelect.js.map +1 -1
- package/dist/Toast.d.ts +127 -0
- package/dist/Toast.d.ts.map +1 -0
- package/dist/Toast.js +79 -49
- package/dist/Toast.js.map +1 -1
- package/dist/TreeView.d.ts +84 -0
- package/dist/TreeView.d.ts.map +1 -0
- package/dist/TreeView.js +478 -0
- package/dist/TreeView.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -14
- package/dist/index.js.map +1 -1
- package/package.json +60 -5
- package/src/AIMarkdownEditor.ts +568 -0
- package/src/AITextEditor.ts +97 -2
- package/src/ButtonToolbar.ts +302 -0
- package/src/CheckList.ts +438 -0
- package/src/ChunkUploader.ts +1135 -0
- package/src/ComicBalloon.ts +709 -0
- package/src/ContainerBox.ts +570 -0
- package/src/Dialog.ts +510 -0
- package/src/Drawer.ts +435 -0
- package/src/ImageView.ts +265 -0
- package/src/MarkdownPreview.ts +213 -0
- package/src/ResizableCropper.ts +1099 -0
- package/src/SmartSelect.ts +48 -2
- package/src/Toast.ts +96 -32
- package/src/TreeView.ts +673 -0
- package/src/index.ts +129 -27
package/src/SmartSelect.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
export type SelectOption = {
|
|
7
7
|
value: string;
|
|
8
8
|
label: string;
|
|
9
|
+
image?: string;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export class SmartSelectElement extends HTMLElement {
|
|
@@ -699,6 +700,42 @@ export class SmartSelectElement extends HTMLElement {
|
|
|
699
700
|
color: var(--option-selected-color, #1976d2);
|
|
700
701
|
}
|
|
701
702
|
|
|
703
|
+
.option-content {
|
|
704
|
+
display: flex;
|
|
705
|
+
align-items: center;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
.option-image {
|
|
709
|
+
width: 24px;
|
|
710
|
+
height: 24px;
|
|
711
|
+
border-radius: 50%;
|
|
712
|
+
object-fit: cover;
|
|
713
|
+
margin-right: 8px;
|
|
714
|
+
flex-shrink: 0;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
.tag-image {
|
|
718
|
+
width: 16px;
|
|
719
|
+
height: 16px;
|
|
720
|
+
border-radius: 50%;
|
|
721
|
+
object-fit: cover;
|
|
722
|
+
margin-right: 4px;
|
|
723
|
+
flex-shrink: 0;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
.single-value {
|
|
727
|
+
display: flex;
|
|
728
|
+
align-items: center;
|
|
729
|
+
gap: 8px;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.single-value-image {
|
|
733
|
+
width: 20px;
|
|
734
|
+
height: 20px;
|
|
735
|
+
border-radius: 50%;
|
|
736
|
+
object-fit: cover;
|
|
737
|
+
}
|
|
738
|
+
|
|
702
739
|
.no-options {
|
|
703
740
|
padding: 8px 12px;
|
|
704
741
|
color: var(--no-options-color, #6c757d);
|
|
@@ -712,11 +749,17 @@ export class SmartSelectElement extends HTMLElement {
|
|
|
712
749
|
${ this.multiple && this.selectedOptions.length > 0
|
|
713
750
|
? this.selectedOptions.map( option => `
|
|
714
751
|
<span class="tag">
|
|
752
|
+
${ option.image ? `<img src="${ option.image }" class="tag-image" alt="">` : '' }
|
|
715
753
|
${ option.label }
|
|
716
754
|
<span class="remove-tag" data-value="${ option.value }">×</span>
|
|
717
755
|
</span>
|
|
718
756
|
`).join( '' )
|
|
719
|
-
:
|
|
757
|
+
: this.selectedOptions.length > 0
|
|
758
|
+
? `<div class="single-value">
|
|
759
|
+
${ this.selectedOptions[ 0 ].image ? `<img src="${ this.selectedOptions[ 0 ].image }" class="single-value-image" alt="">` : '' }
|
|
760
|
+
<span>${ this.selectedOptions[ 0 ].label }</span>
|
|
761
|
+
</div>`
|
|
762
|
+
: `<span>${ displayText }</span>`
|
|
720
763
|
}
|
|
721
764
|
</div>
|
|
722
765
|
<div class="arrow ${ this.isOpen ? 'open' : '' }"></div>
|
|
@@ -739,7 +782,10 @@ export class SmartSelectElement extends HTMLElement {
|
|
|
739
782
|
class="option ${ this.selectedOptions.find( selected => selected.value === option.value ) ? 'selected' : '' } ${ index === this.focusedIndex ? 'focused' : '' }"
|
|
740
783
|
data-value="${ option.value }"
|
|
741
784
|
>
|
|
742
|
-
|
|
785
|
+
<div class="option-content">
|
|
786
|
+
${ option.image ? `<img src="${ option.image }" class="option-image" alt="">` : '' }
|
|
787
|
+
<span>${ option.label }</span>
|
|
788
|
+
</div>
|
|
743
789
|
</div>
|
|
744
790
|
`).join( '' )
|
|
745
791
|
: '<div class="no-options">No options available</div>'
|
package/src/Toast.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
export type ToastType = 'info' | 'warning' | 'error' | 'success';
|
|
7
7
|
|
|
8
|
+
export type ToastPosition = 'TL' | 'T' | 'TR' | 'BL' | 'B' | 'BR';
|
|
9
|
+
|
|
8
10
|
export type ToastButton = {
|
|
9
11
|
label: string;
|
|
10
12
|
onClick: () => void;
|
|
@@ -18,6 +20,7 @@ export type ToastConfig = {
|
|
|
18
20
|
buttons?: ToastButton[];
|
|
19
21
|
closable?: boolean; // Show close X button
|
|
20
22
|
duration?: number; // Auto-dismiss after x milliseconds (0 = no auto-dismiss, default: 5000ms)
|
|
23
|
+
position?: ToastPosition; // Toast container position (default: 'TR')
|
|
21
24
|
onClose?: () => void;
|
|
22
25
|
};
|
|
23
26
|
|
|
@@ -60,12 +63,26 @@ export class ToastElement extends HTMLElement {
|
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
get title (): string {
|
|
63
|
-
|
|
66
|
+
const attrTitle = this.getAttribute( 'title' );
|
|
67
|
+
const configTitle = this.config.title;
|
|
68
|
+
|
|
69
|
+
// If no title is provided or empty, use capitalized type
|
|
70
|
+
if ( ( !attrTitle || attrTitle.trim() === '' ) && ( !configTitle || configTitle.trim() === '' ) ) {
|
|
71
|
+
const type = this.type;
|
|
72
|
+
return type.charAt( 0 ).toUpperCase() + type.slice( 1 );
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return attrTitle || configTitle;
|
|
64
76
|
}
|
|
65
77
|
|
|
66
78
|
set title ( value: string ) {
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
if ( value && value.trim() !== '' ) {
|
|
80
|
+
this.setAttribute( 'title', value );
|
|
81
|
+
this.config.title = value;
|
|
82
|
+
} else {
|
|
83
|
+
this.removeAttribute( 'title' );
|
|
84
|
+
this.config.title = '';
|
|
85
|
+
}
|
|
69
86
|
}
|
|
70
87
|
|
|
71
88
|
get text (): string {
|
|
@@ -160,7 +177,13 @@ export class ToastElement extends HTMLElement {
|
|
|
160
177
|
}
|
|
161
178
|
|
|
162
179
|
// Sync config to attributes
|
|
163
|
-
|
|
180
|
+
if ( config.title && config.title.trim() !== '' ) {
|
|
181
|
+
this.title = config.title;
|
|
182
|
+
} else {
|
|
183
|
+
// Clear title if not provided or empty
|
|
184
|
+
this.removeAttribute( 'title' );
|
|
185
|
+
this.config.title = '';
|
|
186
|
+
}
|
|
164
187
|
this.text = config.text;
|
|
165
188
|
if ( config.type ) this.type = config.type;
|
|
166
189
|
if ( config.icon !== undefined ) this.icon = config.icon;
|
|
@@ -681,50 +704,89 @@ const defineToast = ( tagName: string = 'liwe3-toast' ): void => {
|
|
|
681
704
|
defineToast();
|
|
682
705
|
|
|
683
706
|
/**
|
|
684
|
-
*
|
|
707
|
+
* Base container ID prefix for toast notifications
|
|
708
|
+
*/
|
|
709
|
+
const CONTAINER_ID_PREFIX = 'liwe3-toast-container';
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Gets the container positioning styles based on position
|
|
685
713
|
*/
|
|
686
|
-
const
|
|
714
|
+
const getContainerStyles = ( position: ToastPosition ): { top?: string; bottom?: string; left?: string; right?: string; alignItems: string } => {
|
|
715
|
+
switch ( position ) {
|
|
716
|
+
case 'TL':
|
|
717
|
+
return { top: '20px', left: '20px', alignItems: 'flex-start' };
|
|
718
|
+
case 'T':
|
|
719
|
+
return { top: '20px', left: '50%', alignItems: 'center' };
|
|
720
|
+
case 'TR':
|
|
721
|
+
return { top: '20px', right: '20px', alignItems: 'flex-end' };
|
|
722
|
+
case 'BL':
|
|
723
|
+
return { bottom: '20px', left: '20px', alignItems: 'flex-start' };
|
|
724
|
+
case 'B':
|
|
725
|
+
return { bottom: '20px', left: '50%', alignItems: 'center' };
|
|
726
|
+
case 'BR':
|
|
727
|
+
return { bottom: '20px', right: '20px', alignItems: 'flex-end' };
|
|
728
|
+
default:
|
|
729
|
+
return { top: '20px', right: '20px', alignItems: 'flex-end' };
|
|
730
|
+
}
|
|
731
|
+
};
|
|
687
732
|
|
|
688
733
|
/**
|
|
689
|
-
* Creates or gets the toast container element
|
|
734
|
+
* Creates or gets the toast container element for the specified position
|
|
690
735
|
*/
|
|
691
|
-
const getToastContainer = (): HTMLElement => {
|
|
692
|
-
|
|
736
|
+
const getToastContainer = ( position: ToastPosition = 'TR' ): HTMLElement => {
|
|
737
|
+
const containerId = `${ CONTAINER_ID_PREFIX }-${ position.toLowerCase() }`;
|
|
738
|
+
let container = document.getElementById( containerId );
|
|
693
739
|
|
|
694
740
|
if ( !container ) {
|
|
695
741
|
container = document.createElement( 'div' );
|
|
696
|
-
container.id =
|
|
742
|
+
container.id = containerId;
|
|
697
743
|
container.style.position = 'fixed';
|
|
698
|
-
container.style.top = '20px';
|
|
699
|
-
container.style.right = '20px';
|
|
700
744
|
container.style.zIndex = '99999';
|
|
701
745
|
container.style.display = 'flex';
|
|
702
746
|
container.style.flexDirection = 'column';
|
|
703
747
|
container.style.maxWidth = '400px';
|
|
704
748
|
container.style.pointerEvents = 'none';
|
|
705
749
|
|
|
750
|
+
// Apply position-specific styles
|
|
751
|
+
const styles = getContainerStyles( position );
|
|
752
|
+
if ( styles.top ) container.style.top = styles.top;
|
|
753
|
+
if ( styles.bottom ) container.style.bottom = styles.bottom;
|
|
754
|
+
if ( styles.left ) container.style.left = styles.left;
|
|
755
|
+
if ( styles.right ) container.style.right = styles.right;
|
|
756
|
+
container.style.alignItems = styles.alignItems;
|
|
757
|
+
|
|
758
|
+
// For centered positions, apply transform to center horizontally
|
|
759
|
+
if ( position === 'T' || position === 'B' ) {
|
|
760
|
+
container.style.transform = 'translateX(-50%)';
|
|
761
|
+
}
|
|
762
|
+
|
|
706
763
|
// Add media query styles for mobile and smooth transitions
|
|
707
|
-
const
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
764
|
+
const styleId = `${ containerId }-styles`;
|
|
765
|
+
if ( !document.getElementById( styleId ) ) {
|
|
766
|
+
const style = document.createElement( 'style' );
|
|
767
|
+
style.id = styleId;
|
|
768
|
+
style.textContent = `
|
|
769
|
+
#${ containerId } > * {
|
|
770
|
+
margin-bottom: 12px;
|
|
771
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
772
|
+
overflow: hidden;
|
|
773
|
+
}
|
|
714
774
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
775
|
+
#${ containerId } > *:last-child {
|
|
776
|
+
margin-bottom: 0;
|
|
777
|
+
}
|
|
718
778
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
779
|
+
@media (max-width: 768px) {
|
|
780
|
+
#${ containerId } {
|
|
781
|
+
left: 20px !important;
|
|
782
|
+
right: 20px !important;
|
|
783
|
+
max-width: none !important;
|
|
784
|
+
transform: none !important;
|
|
785
|
+
}
|
|
724
786
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
787
|
+
`;
|
|
788
|
+
document.head.appendChild( style );
|
|
789
|
+
}
|
|
728
790
|
|
|
729
791
|
document.body.appendChild( container );
|
|
730
792
|
}
|
|
@@ -747,12 +809,14 @@ const getToastContainer = (): HTMLElement => {
|
|
|
747
809
|
* title: 'Success!',
|
|
748
810
|
* text: 'Your changes have been saved.',
|
|
749
811
|
* type: 'success',
|
|
750
|
-
* duration: 5000
|
|
812
|
+
* duration: 5000,
|
|
813
|
+
* position: 'TR' // Optional: top-right (default)
|
|
751
814
|
* });
|
|
752
815
|
* ```
|
|
753
816
|
*/
|
|
754
817
|
const toastAdd = ( config: ToastConfig ): ToastElement => {
|
|
755
|
-
const
|
|
818
|
+
const position = config.position || 'TR';
|
|
819
|
+
const container = getToastContainer( position );
|
|
756
820
|
const toast = document.createElement( 'liwe3-toast' ) as ToastElement;
|
|
757
821
|
|
|
758
822
|
// Allow pointer events on individual toasts
|