@liwe3/webcomponents 1.0.14 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/AITextEditor.d.ts +173 -0
  2. package/dist/AITextEditor.d.ts.map +1 -0
  3. package/dist/ChunkUploader.d.ts +103 -0
  4. package/dist/ChunkUploader.d.ts.map +1 -0
  5. package/dist/ChunkUploader.js +614 -0
  6. package/dist/ChunkUploader.js.map +1 -0
  7. package/dist/ContainerBox.d.ts +112 -0
  8. package/dist/ContainerBox.d.ts.map +1 -0
  9. package/dist/ContainerBox.js +359 -0
  10. package/dist/ContainerBox.js.map +1 -0
  11. package/dist/DateSelector.d.ts +103 -0
  12. package/dist/DateSelector.d.ts.map +1 -0
  13. package/dist/Drawer.d.ts +63 -0
  14. package/dist/Drawer.d.ts.map +1 -0
  15. package/dist/Drawer.js +340 -0
  16. package/dist/Drawer.js.map +1 -0
  17. package/dist/ImageView.d.ts +42 -0
  18. package/dist/ImageView.d.ts.map +1 -0
  19. package/dist/ImageView.js +209 -0
  20. package/dist/ImageView.js.map +1 -0
  21. package/dist/PopoverMenu.d.ts +103 -0
  22. package/dist/PopoverMenu.d.ts.map +1 -0
  23. package/dist/SmartSelect.d.ts +99 -0
  24. package/dist/SmartSelect.d.ts.map +1 -0
  25. package/dist/Toast.d.ts +127 -0
  26. package/dist/Toast.d.ts.map +1 -0
  27. package/dist/Toast.js +79 -49
  28. package/dist/Toast.js.map +1 -1
  29. package/dist/TreeView.d.ts +84 -0
  30. package/dist/TreeView.d.ts.map +1 -0
  31. package/dist/TreeView.js +478 -0
  32. package/dist/TreeView.js.map +1 -0
  33. package/dist/index.d.ts +16 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +26 -12
  36. package/dist/index.js.map +1 -1
  37. package/package.json +28 -3
  38. package/src/ChunkUploader.ts +921 -0
  39. package/src/ContainerBox.ts +570 -0
  40. package/src/Drawer.ts +435 -0
  41. package/src/ImageView.ts +265 -0
  42. package/src/Toast.ts +96 -32
  43. package/src/TreeView.ts +673 -0
  44. package/src/index.ts +45 -6
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
- return this.getAttribute( 'title' ) || this.config.title;
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
- this.setAttribute( 'title', value );
68
- this.config.title = value;
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
- this.title = config.title;
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
- * Default container ID for toast notifications
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 DEFAULT_CONTAINER_ID = 'liwe3-toast-container';
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
- let container = document.getElementById( DEFAULT_CONTAINER_ID );
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 = DEFAULT_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 style = document.createElement( 'style' );
708
- style.textContent = `
709
- #${DEFAULT_CONTAINER_ID} > * {
710
- margin-bottom: 12px;
711
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
712
- overflow: hidden;
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
- #${DEFAULT_CONTAINER_ID} > *:last-child {
716
- margin-bottom: 0;
717
- }
775
+ #${ containerId } > *:last-child {
776
+ margin-bottom: 0;
777
+ }
718
778
 
719
- @media (max-width: 768px) {
720
- #${DEFAULT_CONTAINER_ID} {
721
- left: 20px !important;
722
- right: 20px !important;
723
- max-width: none !important;
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
- document.head.appendChild( style );
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 container = getToastContainer();
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