@flightlesslabs/dodo-ui 0.6.6 → 0.7.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 (118) hide show
  1. package/dist/index.d.ts +28 -7
  2. package/dist/index.js +12 -2
  3. package/dist/stories/Home.mdx +1 -1
  4. package/dist/stories/components/Form/Button/Button.svelte +2 -2
  5. package/dist/stories/components/Form/Button/Button.svelte.d.ts +8 -5
  6. package/dist/stories/components/Form/FormControl/FormControl.svelte +3 -0
  7. package/dist/stories/components/Form/FormControl/FormControl.svelte.d.ts +1 -1
  8. package/dist/stories/components/Form/Label/Label.svelte +5 -2
  9. package/dist/stories/components/Form/Label/Label.svelte.d.ts +1 -1
  10. package/dist/stories/components/Form/Message/Message.svelte +5 -2
  11. package/dist/stories/components/Form/Message/Message.svelte.d.ts +1 -1
  12. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +25 -32
  13. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +5 -5
  14. package/dist/stories/components/Form/Select/Customize/Customize.stories.svelte +120 -0
  15. package/dist/stories/components/Form/Select/Customize/Customize.stories.svelte.d.ts +18 -0
  16. package/dist/stories/components/Form/Select/Events/Events.stories.svelte +138 -0
  17. package/dist/stories/components/Form/Select/Options/OptionFormat.mdx +40 -0
  18. package/dist/stories/components/Form/Select/Roundness/Roundness.stories.svelte +28 -0
  19. package/dist/stories/components/Form/Select/Roundness/Roundness.stories.svelte.d.ts +18 -0
  20. package/dist/stories/components/Form/Select/Select.stories.svelte +114 -0
  21. package/dist/stories/components/Form/Select/Select.stories.svelte.d.ts +22 -0
  22. package/dist/stories/components/Form/Select/Select.svelte +285 -0
  23. package/dist/stories/components/Form/Select/Select.svelte.d.ts +87 -0
  24. package/dist/stories/components/Form/Select/Size/Size.stories.svelte +24 -0
  25. package/dist/stories/components/Form/Select/Size/Size.stories.svelte.d.ts +18 -0
  26. package/dist/stories/components/Form/Select/WithIcon/WithIcon.stories.svelte +39 -0
  27. package/dist/stories/components/Form/Select/WithIcon/WithIcon.stories.svelte.d.ts +18 -0
  28. package/dist/stories/components/Form/TextInput/TextInput.svelte +9 -28
  29. package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +8 -5
  30. package/dist/stories/components/Layout/Menu/Menu.stories.svelte +65 -0
  31. package/dist/stories/components/Layout/Menu/Menu.stories.svelte.d.ts +21 -0
  32. package/dist/stories/components/Layout/Menu/Menu.svelte +30 -0
  33. package/dist/stories/components/Layout/Menu/Menu.svelte.d.ts +23 -0
  34. package/dist/stories/components/Layout/Menu/MenuItem/MenuItem.stories.svelte +30 -0
  35. package/dist/stories/components/Layout/Menu/MenuItem/MenuItem.stories.svelte.d.ts +21 -0
  36. package/dist/stories/components/Layout/Menu/MenuItem/MenuItem.svelte +164 -0
  37. package/dist/stories/components/Layout/Menu/MenuItem/MenuItem.svelte.d.ts +49 -0
  38. package/dist/stories/components/Layout/Menu/MenuItem/Size/Size.stories.svelte +16 -0
  39. package/dist/stories/components/Layout/Menu/MenuItem/Type/Type.stories.svelte +21 -0
  40. package/dist/stories/components/{Form/SimpleSelect/WithIcon/WithIcon.stories.svelte.d.ts → Layout/Menu/MenuItem/Type/Type.stories.svelte.d.ts} +3 -3
  41. package/dist/stories/components/Layout/Menu/Size/Size.stories.svelte +37 -0
  42. package/dist/stories/components/{Form/SimpleSelect/Roundness/Roundness.stories.svelte.d.ts → Layout/Menu/Size/Size.stories.svelte.d.ts} +3 -3
  43. package/dist/stories/components/Layout/Paper/Color/Color.stories.svelte +1 -1
  44. package/dist/stories/components/Layout/Paper/Paper.stories.svelte +1 -1
  45. package/dist/stories/components/Layout/Paper/Paper.svelte.d.ts +5 -5
  46. package/dist/stories/components/Layout/Separator/Color/Color.stories.svelte +19 -0
  47. package/dist/stories/components/Layout/Separator/Color/Color.stories.svelte.d.ts +26 -0
  48. package/dist/stories/components/Layout/Separator/Separator.stories.svelte +26 -0
  49. package/dist/stories/components/Layout/Separator/Separator.stories.svelte.d.ts +21 -0
  50. package/dist/stories/components/Layout/Separator/Separator.svelte +66 -0
  51. package/dist/stories/components/Layout/Separator/Separator.svelte.d.ts +22 -0
  52. package/dist/stories/components/Layout/Separator/utils/scss/mixins.scss +24 -0
  53. package/dist/stories/developer tools/components/DynamicInput/DynamicInput.stories.svelte +49 -0
  54. package/dist/stories/{components/Form/SimpleSelect/SimpleSelect.stories.svelte.d.ts → developer tools/components/DynamicInput/DynamicInput.stories.svelte.d.ts } +5 -7
  55. package/dist/stories/developer tools/components/DynamicInput/DynamicInput.svelte +92 -0
  56. package/dist/stories/developer tools/components/DynamicInput/DynamicInput.svelte.d.ts +60 -0
  57. package/dist/stories/{components/Form/SimpleSelect/Size/Size.stories.svelte → developer tools/components/DynamicInput/Size/Size.stories.svelte } +5 -8
  58. package/dist/stories/developer tools/components/DynamicInput/Size/Size.stories.svelte.d.ts +26 -0
  59. package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte +6 -2
  60. package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte.d.ts +1 -1
  61. package/dist/stories/developer tools/components/Popper/Popper.stories.svelte +119 -0
  62. package/dist/stories/developer tools/components/Popper/Popper.stories.svelte.d.ts +21 -0
  63. package/dist/stories/developer tools/components/Popper/Popper.svelte +77 -0
  64. package/dist/stories/developer tools/components/Popper/Popper.svelte.d.ts +50 -0
  65. package/dist/stories/developer tools/components/Popper/PopperPopup/PopperPopup.stories.svelte +60 -0
  66. package/dist/stories/developer tools/components/Popper/PopperPopup/PopperPopup.stories.svelte.d.ts +21 -0
  67. package/dist/stories/developer tools/components/Popper/PopperPopup/PopperPopup.svelte +66 -0
  68. package/dist/stories/developer tools/components/Popper/PopperPopup/PopperPopup.svelte.d.ts +34 -0
  69. package/dist/stories/developer tools/components/Popper/PopperPopup/utils/getPopupPosition.d.ts +21 -0
  70. package/dist/stories/developer tools/components/Popper/PopperPopup/utils/getPopupPosition.js +62 -0
  71. package/dist/stories/developer tools/components/Popper/Positions/AutoPosition/AutoPosition.stories.svelte +89 -0
  72. package/dist/stories/developer tools/components/Popper/Positions/AutoPosition/AutoPosition.stories.svelte.d.ts +18 -0
  73. package/dist/stories/developer tools/components/Popper/Positions/Positions.stories.svelte +111 -0
  74. package/dist/stories/developer tools/components/Popper/Positions/Positions.stories.svelte.d.ts +18 -0
  75. package/dist/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte +3 -5
  76. package/dist/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte +0 -4
  77. package/dist/stories/developer tools/components/UtilityButton/UtilityButton.svelte +5 -2
  78. package/dist/stories/developer tools/components/UtilityButton/UtilityButton.svelte.d.ts +1 -1
  79. package/dist/stories/developer tools/directives/clickOutside/clickOutside.d.ts +3 -0
  80. package/dist/stories/developer tools/directives/clickOutside/clickOutside.js +14 -0
  81. package/dist/stories/developer tools/directives/clickOutside/index.mdx +25 -0
  82. package/dist/styles/_z-index.css +9 -0
  83. package/dist/styles/global.css +1 -0
  84. package/dist/types/position.d.ts +4 -0
  85. package/dist/types/position.js +2 -0
  86. package/package.json +1 -1
  87. package/src/lib/index.ts +50 -9
  88. package/src/lib/stories/components/Form/Button/Button.svelte +14 -10
  89. package/src/lib/stories/components/Form/FormControl/FormControl.svelte +7 -4
  90. package/src/lib/stories/components/Form/Label/Label.svelte +4 -2
  91. package/src/lib/stories/components/Form/Message/Message.svelte +4 -2
  92. package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +48 -49
  93. package/src/lib/stories/components/Form/Select/Select.svelte +501 -0
  94. package/src/lib/stories/components/Form/TextInput/TextInput.svelte +32 -59
  95. package/src/lib/stories/components/Layout/Menu/Menu.svelte +65 -0
  96. package/src/lib/stories/components/Layout/Menu/MenuItem/MenuItem.svelte +268 -0
  97. package/src/lib/stories/components/Layout/Paper/Paper.svelte +8 -9
  98. package/src/lib/stories/components/Layout/Separator/Separator.svelte +96 -0
  99. package/src/lib/stories/components/Layout/Separator/utils/scss/mixins.scss +24 -0
  100. package/src/lib/stories/developer tools/components/DynamicInput/DynamicInput.svelte +195 -0
  101. package/src/lib/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte +5 -2
  102. package/src/lib/stories/developer tools/components/Popper/Popper.svelte +159 -0
  103. package/src/lib/stories/developer tools/components/Popper/PopperPopup/PopperPopup.svelte +120 -0
  104. package/src/lib/stories/developer tools/components/Popper/PopperPopup/utils/getPopupPosition.ts +87 -0
  105. package/src/lib/stories/developer tools/components/UtilityButton/UtilityButton.svelte +4 -2
  106. package/src/lib/stories/developer tools/directives/clickOutside/clickOutside.ts +17 -0
  107. package/src/lib/styles/_z-index.css +9 -0
  108. package/src/lib/styles/global.css +1 -0
  109. package/src/lib/types/position.ts +5 -0
  110. package/dist/stories/components/Form/SimpleSelect/Events/Events.stories.svelte +0 -47
  111. package/dist/stories/components/Form/SimpleSelect/Roundness/Roundness.stories.svelte +0 -24
  112. package/dist/stories/components/Form/SimpleSelect/SimpleSelect.stories.svelte +0 -57
  113. package/dist/stories/components/Form/SimpleSelect/SimpleSelect.svelte +0 -69
  114. package/dist/stories/components/Form/SimpleSelect/SimpleSelect.svelte.d.ts +0 -51
  115. package/dist/stories/components/Form/SimpleSelect/WithIcon/WithIcon.stories.svelte +0 -36
  116. package/src/lib/stories/components/Form/SimpleSelect/SimpleSelect.svelte +0 -160
  117. /package/dist/stories/components/Form/{SimpleSelect → Select}/Events/Events.stories.svelte.d.ts +0 -0
  118. /package/dist/stories/components/{Form/SimpleSelect → Layout/Menu/MenuItem}/Size/Size.stories.svelte.d.ts +0 -0
@@ -0,0 +1,159 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+ import PopperPopup from './PopperPopup/PopperPopup.svelte';
4
+ import type { PaperProps } from '$lib/stories/components/Layout/Paper/Paper.svelte';
5
+ import { clickOutside } from '$lib/stories/developer tools/directives/clickOutside/clickOutside.js';
6
+ import type { PositionX, PositionY } from '$lib/types/position.js';
7
+
8
+ export interface PopperProps {
9
+ /** Popper contents goes here */
10
+ children?: Snippet;
11
+ /** Popper ref */
12
+ ref?: HTMLDivElement;
13
+ /** Id */
14
+ id?: string;
15
+ /** Title (for tooltip) */
16
+ title?: string;
17
+ /** Custom css class*/
18
+ class?: string;
19
+ /** Open popper */
20
+ open?: boolean;
21
+ /** Full width Popper? */
22
+ fullWidth?: boolean;
23
+ /** PopperPopup ref */
24
+ popupRef?: HTMLDivElement;
25
+ /** PopperPopup contents goes here */
26
+ popupChildren?: Snippet;
27
+ /** PaperProps: Paper component props for PopperPopup */
28
+ paperProps?: Partial<PaperProps>;
29
+ /** PopperPopup Max height. Use css compatible value */
30
+ popupMaxHeight?: string;
31
+ /** PopperPopup Width. Use css compatible value */
32
+ popupWidth?: string;
33
+ /** popup Custom css class*/
34
+ popupClass?: string;
35
+ /** Popup stick horizontally */
36
+ popupPositionX?: PositionX;
37
+ /** Popup stick vertically */
38
+ popupPositionY?: PositionY;
39
+ /** vertical offset/gap between Popup and content */
40
+ popupOffsetY?: number;
41
+ /** Horizontal offset/gap between Popup and content */
42
+ popupOffsetX?: number;
43
+ /** Lock positions, disable auto top, bottom position based */
44
+ lockPoistions?: boolean;
45
+ /** Popper Height For Vertical Position, default 300 */
46
+ popperHeightForVerticalPosition?: number;
47
+ /** Click Outside event */
48
+ onClickOutside?: () => void;
49
+ /** Custom Popup */
50
+ customPopup?: (popperLocation?: DOMRect) => Snippet;
51
+ }
52
+ </script>
53
+
54
+ <script lang="ts">
55
+ let {
56
+ children,
57
+ popupChildren,
58
+ id,
59
+ class: className = '',
60
+ ref = $bindable<HTMLDivElement>(),
61
+ open = false,
62
+ popupRef = $bindable<HTMLDivElement>(),
63
+ paperProps,
64
+ popupMaxHeight,
65
+ popupWidth,
66
+ popupClass,
67
+ popupPositionX,
68
+ popupPositionY,
69
+ popupOffsetX,
70
+ popupOffsetY,
71
+ onClickOutside = () => {},
72
+ customPopup,
73
+ popperHeightForVerticalPosition,
74
+ lockPoistions,
75
+ fullWidth = false,
76
+ }: PopperProps = $props();
77
+
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ let customPopupTyped = customPopup as any;
80
+
81
+ let popperContainerRef = $state<HTMLDivElement>();
82
+ let popperLocation = $state<DOMRect>();
83
+
84
+ function capturePopperLocation() {
85
+ if (!popperContainerRef) {
86
+ return;
87
+ }
88
+
89
+ popperLocation = popperContainerRef.getBoundingClientRect();
90
+ }
91
+
92
+ $effect(() => {
93
+ if (!popperContainerRef) {
94
+ return;
95
+ }
96
+
97
+ capturePopperLocation();
98
+
99
+ window.addEventListener('resize', capturePopperLocation);
100
+
101
+ return () => {
102
+ window.removeEventListener('resize', capturePopperLocation);
103
+ };
104
+ });
105
+ </script>
106
+
107
+ <div
108
+ class:fullWidth
109
+ class={['dodo-ui-Popper', className].join(' ')}
110
+ bind:this={ref}
111
+ {id}
112
+ use:clickOutside={onClickOutside}
113
+ >
114
+ <div class="PopperContainer" bind:this={popperContainerRef}>
115
+ {#if children}
116
+ {@render children()}
117
+ {/if}
118
+ </div>
119
+
120
+ {#if customPopupTyped}
121
+ {@render customPopupTyped(popperLocation)}
122
+ {:else if open && popperLocation}
123
+ <PopperPopup
124
+ {popperLocation}
125
+ {paperProps}
126
+ {popupMaxHeight}
127
+ {popupWidth}
128
+ {popupPositionX}
129
+ {popupPositionY}
130
+ {popupOffsetX}
131
+ {popupOffsetY}
132
+ {popperHeightForVerticalPosition}
133
+ {lockPoistions}
134
+ class={popupClass}
135
+ >
136
+ {#if popupChildren}
137
+ {@render popupChildren()}
138
+ {/if}
139
+ </PopperPopup>
140
+ {/if}
141
+ </div>
142
+
143
+ <style lang="scss">
144
+ .dodo-ui-Popper {
145
+ position: relative;
146
+ display: inline-flex;
147
+ flex-wrap: wrap;
148
+
149
+ &.fullWidth {
150
+ display: flex;
151
+ width: 100%;
152
+
153
+ .PopperContainer {
154
+ display: block;
155
+ width: 100%;
156
+ }
157
+ }
158
+ }
159
+ </style>
@@ -0,0 +1,120 @@
1
+ <script lang="ts" module>
2
+ import { Paper } from '$lib/index.js';
3
+ import type { PaperProps } from '$lib/stories/components/Layout/Paper/Paper.svelte';
4
+ import type { PositionX, PositionY } from '$lib/types/position.js';
5
+ import type { Snippet } from 'svelte';
6
+ import { getPopupPosition } from './utils/getPopupPosition.js';
7
+
8
+ export interface PopperPopupProps {
9
+ /** Popup contents goes here*/
10
+ children?: Snippet;
11
+ /** Popup ref */
12
+ ref?: HTMLDivElement;
13
+ /** PaperProps: Paper component props */
14
+ paperProps?: Partial<PaperProps>;
15
+ /** Max height. Use css compatible value */
16
+ popupMaxHeight?: string;
17
+ /** popup Width. Use css compatible value */
18
+ popupWidth?: string;
19
+ /** Custom css class */
20
+ class?: string;
21
+ /** Position of Popper content */
22
+ popperLocation?: DOMRect;
23
+ /** Popup stick horizontally */
24
+ popupPositionX?: PositionX;
25
+ /** Popup stick vertically */
26
+ popupPositionY?: PositionY;
27
+ /** vertical offset/gap between Popup and content */
28
+ popupOffsetY?: number;
29
+ /** Horizontal offset/gap between Popup and content */
30
+ popupOffsetX?: number;
31
+ /** Lock positions, disable auto top, bottom position based */
32
+ lockPoistions?: boolean;
33
+ /** Popper Height For Vertical Position, default 300 */
34
+ popperHeightForVerticalPosition?: number;
35
+ }
36
+ </script>
37
+
38
+ <script lang="ts">
39
+ let {
40
+ children,
41
+ paperProps = {},
42
+ class: className = '',
43
+ popupWidth: width,
44
+ popupMaxHeight: maxHeight,
45
+ popupPositionX: positionX = 'left',
46
+ popupPositionY: positionY = 'bottom',
47
+ popperLocation,
48
+ ref = $bindable<HTMLDivElement>(),
49
+ popupOffsetX: offsetX = 0,
50
+ popupOffsetY: offsetY = 12,
51
+ popperHeightForVerticalPosition = 100,
52
+ lockPoistions = false,
53
+ }: PopperPopupProps = $props();
54
+
55
+ const popperWidth = $derived(width || '100%');
56
+ const popupMaxHeight = $derived(maxHeight || '400px');
57
+
58
+ let left = $state<number | null>(null);
59
+ let right = $state<number | null>(null);
60
+ let top = $state<number | null>(null);
61
+ let bottom = $state<number | null>(null);
62
+
63
+ $effect(() => {
64
+ const values = getPopupPosition({
65
+ positionX,
66
+ positionY,
67
+ height: popperLocation?.height || 0,
68
+ width: popperLocation?.width || 0,
69
+ top: popperLocation?.top || 0,
70
+ bottom: popperLocation?.bottom || 0,
71
+ left: popperLocation?.left || 0,
72
+ right: popperLocation?.right || 0,
73
+ offsetX: offsetX,
74
+ offsetY: offsetY,
75
+ popperHeight: popperHeightForVerticalPosition,
76
+ lockPoistions,
77
+ });
78
+
79
+ left = values.left;
80
+ right = values.right;
81
+ top = values.top;
82
+ bottom = values.bottom;
83
+ });
84
+ </script>
85
+
86
+ <div
87
+ class={[
88
+ 'dodo-ui-PopperPopup',
89
+ `positionX--${positionX}`,
90
+ `positionY--${positionY}`,
91
+ className,
92
+ ].join(' ')}
93
+ bind:this={ref}
94
+ style={`width: ${popperWidth};
95
+ ${left !== null ? `left: ${left}px;` : ''}
96
+ ${right !== null ? `right: ${right}px;` : ''}
97
+ ${top !== null ? `top: ${top}px;` : ''}
98
+ ${bottom !== null ? `bottom: ${bottom}px;` : ''}
99
+ ${positionX === 'center' ? `margin: auto;` : ''}
100
+ `}
101
+ >
102
+ <Paper shadow={3} {...paperProps}>
103
+ <section style={`max-height: ${popupMaxHeight};`}>
104
+ {#if children}
105
+ {@render children()}
106
+ {/if}
107
+ </section>
108
+ </Paper>
109
+ </div>
110
+
111
+ <style lang="scss">
112
+ .dodo-ui-PopperPopup {
113
+ position: absolute;
114
+ z-index: var(--dodo-ui-z-index-4);
115
+
116
+ section {
117
+ overflow: auto;
118
+ }
119
+ }
120
+ </style>
@@ -0,0 +1,87 @@
1
+ import { browser } from '$app/environment';
2
+ import type { PositionX, PositionY } from '$lib/types/position.js';
3
+
4
+ export interface GetPopupPositionProps {
5
+ positionX: PositionX;
6
+ positionY: PositionY;
7
+ height: number;
8
+ width: number;
9
+ top: number;
10
+ bottom: number;
11
+ left: number;
12
+ right: number;
13
+ offsetX?: number;
14
+ offsetY?: number;
15
+ popperHeight: number;
16
+ lockPoistions: boolean;
17
+ }
18
+
19
+ export function getPopupPosition(props: GetPopupPositionProps) {
20
+ let left: null | number = null;
21
+ let right: null | number = null;
22
+ let top: null | number = null;
23
+ let bottom: null | number = null;
24
+
25
+ // exit if not browser
26
+ if (!browser) {
27
+ return {
28
+ left,
29
+ right,
30
+ top,
31
+ bottom,
32
+ };
33
+ }
34
+
35
+ const innerHeight = window.innerHeight;
36
+
37
+ const gapBottom = innerHeight - props.bottom;
38
+ const popperHeight = props.popperHeight;
39
+
40
+ const offsetX = props.offsetX ? props.offsetX : 0;
41
+ const offsetY = props.offsetY ? props.offsetY : 0;
42
+
43
+ const positionX = props.positionX;
44
+ let positionY = props.positionY;
45
+
46
+ if (!props.lockPoistions) {
47
+ if (positionY === 'top' && props.top < popperHeight + offsetY) {
48
+ positionY = 'bottom';
49
+ } else if (positionY === 'bottom' && gapBottom < popperHeight + offsetY) {
50
+ positionY = 'top';
51
+ }
52
+ }
53
+
54
+ switch (positionX) {
55
+ case 'left':
56
+ left = offsetX;
57
+ right = null;
58
+ break;
59
+ case 'center':
60
+ left = 0;
61
+ right = 0;
62
+ break;
63
+ case 'right':
64
+ left = null;
65
+ right = offsetX;
66
+ break;
67
+ }
68
+
69
+ switch (positionY) {
70
+ case 'top':
71
+ case 'middle':
72
+ top = null;
73
+ bottom = props.height + offsetY;
74
+ break;
75
+ case 'bottom':
76
+ top = props.height + offsetY;
77
+ bottom = null;
78
+ break;
79
+ }
80
+
81
+ return {
82
+ left,
83
+ right,
84
+ top,
85
+ bottom,
86
+ };
87
+ }
@@ -1,9 +1,9 @@
1
- <script lang="ts">
1
+ <script lang="ts" module>
2
2
  import type { ComponentSize } from '$lib/types/size.js';
3
3
  import type { Snippet } from 'svelte';
4
4
  import type { MouseEventHandler } from 'svelte/elements';
5
5
 
6
- interface UtilityButtonProps {
6
+ export interface UtilityButtonProps {
7
7
  /** Button contents goes here*/
8
8
  children?: Snippet;
9
9
  /** Button ref */
@@ -23,7 +23,9 @@
23
23
  /** The onclick event handler */
24
24
  onclick?: MouseEventHandler<HTMLButtonElement>;
25
25
  }
26
+ </script>
26
27
 
28
+ <script lang="ts">
27
29
  let {
28
30
  children,
29
31
  size = 'normal',
@@ -0,0 +1,17 @@
1
+ export function clickOutside(node: Element, callback: () => void) {
2
+ const handleClick = (event: MouseEvent) => {
3
+ const target = event.target as Node;
4
+
5
+ if (node && !node.contains(target) && !event.defaultPrevented) {
6
+ callback();
7
+ }
8
+ };
9
+
10
+ document.addEventListener('click', handleClick, true);
11
+
12
+ return {
13
+ destroy() {
14
+ document.removeEventListener('click', handleClick, true);
15
+ },
16
+ };
17
+ }
@@ -0,0 +1,9 @@
1
+ :root {
2
+ /* zIndex */
3
+ --dodo-ui-z-index-0: 0;
4
+ --dodo-ui-z-index-1: 1;
5
+ --dodo-ui-z-index-2: 100;
6
+ --dodo-ui-z-index-3: 1000;
7
+ --dodo-ui-z-index-4: 5000;
8
+ --dodo-ui-z-index-5: 5001;
9
+ }
@@ -2,6 +2,7 @@
2
2
  @import '_colors-base.css';
3
3
  @import '_colors.css';
4
4
  @import '_space.css';
5
+ @import '_z-index.css';
5
6
  @import '_breakpoint.css';
6
7
  @import '_shadow.css';
7
8
  @import '_components.css';
@@ -0,0 +1,5 @@
1
+ export type PositionY = 'top' | 'middle' | 'bottom';
2
+ export type PositionX = 'left' | 'center' | 'right';
3
+
4
+ export const positionYArray: PositionY[] = ['top', 'bottom'];
5
+ export const positionXArray: PositionX[] = ['left', 'center', 'right'];
@@ -1,47 +0,0 @@
1
- <script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
2
- import {} from '../SimpleSelect.svelte';
3
- import SimpleSelect from '../SimpleSelect.svelte';
4
- import { storySimpleSelectArgTypes, storySimpleSelectOptions, } from '../SimpleSelect.stories.svelte';
5
- // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
6
- const { Story } = defineMeta({
7
- component: SimpleSelect,
8
- tags: ['autodocs'],
9
- argTypes: storySimpleSelectArgTypes,
10
- args: { options: storySimpleSelectOptions },
11
- });
12
- </script>
13
-
14
- <Story
15
- name="Change"
16
- args={{
17
- onchange: (e: Event) => {
18
- const target = e.target as HTMLSelectElement;
19
-
20
- console.log('onChange Event', target.value);
21
- },
22
- }}
23
- />
24
-
25
- <!-- `e: SimpleSelectFocusEvent` -->
26
- <Story
27
- name="Focus"
28
- args={{
29
- onfocus: (e: SimpleSelectFocusEvent) => {
30
- const target = e.target as HTMLSelectElement;
31
-
32
- console.log('onfocus Event', target);
33
- },
34
- }}
35
- />
36
-
37
- <!-- `e: SimpleSelectFocusEvent` -->
38
- <Story
39
- name="Blur"
40
- args={{
41
- onblur: (e: SimpleSelectFocusEvent) => {
42
- const target = e.target as HTMLSelectElement;
43
-
44
- console.log('onblur Event', target);
45
- },
46
- }}
47
- />
@@ -1,24 +0,0 @@
1
- <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import SimpleSelect from '../SimpleSelect.svelte';
4
- import {
5
- storySimpleSelectArgTypes,
6
- storySimpleSelectOptions,
7
- } from '../SimpleSelect.stories.svelte';
8
-
9
- // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
10
- const { Story } = defineMeta({
11
- component: SimpleSelect,
12
- tags: ['autodocs'],
13
- argTypes: storySimpleSelectArgTypes,
14
- args: { options: storySimpleSelectOptions },
15
- });
16
- </script>
17
-
18
- <Story name="Roundness 1" />
19
-
20
- <Story name="Roundness 2" args={{ roundness: 2 }} />
21
-
22
- <Story name="Roundness 3" args={{ roundness: 3 }} />
23
-
24
- <Story name="Roundness 0" args={{ roundness: 0 }} />
@@ -1,57 +0,0 @@
1
- <script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
2
- import {} from './SimpleSelect.svelte';
3
- import SimpleSelect from './SimpleSelect.svelte';
4
- import { componentRoundnessArray } from '../../../../types/roundness.js';
5
- import { componentSizeArray } from '../../../../types/size.js';
6
- export const storySimpleSelectArgTypes = {
7
- roundness: {
8
- control: { type: 'select' },
9
- options: componentRoundnessArray,
10
- },
11
- size: {
12
- control: { type: 'select' },
13
- options: componentSizeArray,
14
- },
15
- };
16
- export const storySimpleSelectOptions = [
17
- {
18
- value: 'volvo',
19
- label: 'Volvo',
20
- },
21
- {
22
- value: 'saab',
23
- label: 'Saab',
24
- },
25
- {
26
- value: 'mercedes',
27
- label: 'Mercedes',
28
- },
29
- {
30
- value: 'audi',
31
- label: 'Audi',
32
- },
33
- {
34
- value: 'opel',
35
- label: 'Opel',
36
- disabled: true,
37
- },
38
- ];
39
- // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
40
- const { Story } = defineMeta({
41
- component: SimpleSelect,
42
- tags: ['autodocs'],
43
- argTypes: storySimpleSelectArgTypes,
44
- args: { options: storySimpleSelectOptions },
45
- });
46
- </script>
47
-
48
- <!-- SimpleSelect with default style -->
49
- <Story name="Default" />
50
-
51
- <Story name="Placeholder" args={{ value: '', placeholder: 'Type something...' }} />
52
-
53
- <Story name="No Outline" args={{ outline: false }} />
54
-
55
- <Story name="Error" args={{ error: true }} />
56
-
57
- <Story name="Disabled" args={{ disabled: true }} />
@@ -1,69 +0,0 @@
1
- <script lang="ts" module>export {};
2
- </script>
3
-
4
- <script lang="ts">import InputEnclosure from '../../../developer tools/components/InputEnclosure/InputEnclosure.svelte';
5
- let { size = 'normal', roundness = 1, outline = true, name, id, class: className = '', disabled = false, onchange, onblur, onfocus, before, after, error = false, value, placeholder, ref = $bindable(), options, } = $props();
6
- let focused = $state(false);
7
- function onfocusMod(e) {
8
- focused = true;
9
- if (onfocus) {
10
- onfocus(e);
11
- }
12
- }
13
- function onblurMod(e) {
14
- focused = false;
15
- if (onblur) {
16
- onblur(e);
17
- }
18
- }
19
- </script>
20
-
21
- <div
22
- class:outline
23
- class:disabled
24
- class:error
25
- class:focused
26
- class={['dodo-ui-SimpleSelect', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
27
- >
28
- <InputEnclosure {outline} {disabled} {error} {focused} {size} {roundness} {before} {after}>
29
- <select
30
- {name}
31
- {id}
32
- {disabled}
33
- {onchange}
34
- onfocus={onfocusMod}
35
- onblur={onblurMod}
36
- {placeholder}
37
- bind:this={ref}
38
- >
39
- {#each options as option (option.value)}
40
- <option value={option.value} disabled={option.disabled} selected={value === option.value}>
41
- {option.label}
42
- </option>
43
- {/each}
44
- </select>
45
- </InputEnclosure>
46
- </div>
47
-
48
- <style>.dodo-ui-SimpleSelect select {
49
- flex: 1;
50
- border: 0;
51
- outline: 0;
52
- height: 100%;
53
- background-color: transparent;
54
- font-family: inherit;
55
- color: inherit;
56
- letter-spacing: 0.3px;
57
- }
58
- .dodo-ui-SimpleSelect.size--normal select {
59
- font-size: 1rem;
60
- padding: 0 calc(var(--dodo-ui-space-small) * 2);
61
- }
62
- .dodo-ui-SimpleSelect.size--small select {
63
- padding: 0 var(--dodo-ui-space);
64
- font-size: 0.9rem;
65
- }
66
- .dodo-ui-SimpleSelect.size--large select {
67
- font-size: 1.1rem;
68
- padding: 0 calc(var(--dodo-ui-space) * 2);
69
- }</style>
@@ -1,51 +0,0 @@
1
- export type SimpleSelectFocusEvent = FocusEvent & {
2
- currentTarget: EventTarget & HTMLSelectElement;
3
- };
4
- export type SimpleSelectOption = {
5
- value: string;
6
- label: string;
7
- disabled?: boolean;
8
- };
9
- import type { ComponentRoundness } from '../../../../types/roundness.js';
10
- import type { ComponentSize } from '../../../../types/size.js';
11
- import type { Snippet } from 'svelte';
12
- import type { ChangeEventHandler, FocusEventHandler } from 'svelte/elements';
13
- interface SimpleSelectProps {
14
- /** Select ref */
15
- ref?: HTMLSelectElement;
16
- /** How large should the button be? */
17
- size?: ComponentSize;
18
- /** How round should the border radius be? */
19
- roundness?: ComponentRoundness;
20
- /** How round should the border radius be? */
21
- options: SimpleSelectOption[];
22
- /** Add a border around the button. Default True */
23
- outline?: boolean;
24
- /** Select value */
25
- value?: string;
26
- /** How round should the border radius be? */
27
- placeholder?: string;
28
- /** disabled state */
29
- disabled?: boolean;
30
- /** is there any associated Error ? */
31
- error?: boolean;
32
- /** Name */
33
- name?: string;
34
- /** Id */
35
- id?: string;
36
- /** Icon before button content */
37
- before?: Snippet;
38
- /** Icon after button content */
39
- after?: Snippet;
40
- /** Custom css class*/
41
- class?: string;
42
- /** onchange event handler */
43
- onchange?: ChangeEventHandler<HTMLSelectElement>;
44
- /** onblur event handler */
45
- onblur?: FocusEventHandler<HTMLSelectElement>;
46
- /** onfocus event handler */
47
- onfocus?: FocusEventHandler<HTMLSelectElement>;
48
- }
49
- declare const SimpleSelect: import("svelte").Component<SimpleSelectProps, {}, "ref">;
50
- type SimpleSelect = ReturnType<typeof SimpleSelect>;
51
- export default SimpleSelect;