lapikit 0.0.0-insiders.fd1a829 → 0.0.0-insiders.fd9617d
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/LICENSE +21 -0
- package/README.md +117 -1
- package/bin/configuration.js +303 -0
- package/bin/helper.js +59 -0
- package/bin/index.js +33 -0
- package/bin/presets.js +26 -0
- package/bin/prompts.js +67 -0
- package/dist/actions/accordion.svelte.d.ts +9 -0
- package/dist/actions/accordion.svelte.js +24 -0
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +2 -0
- package/dist/actions/use-theme.d.ts +1 -0
- package/dist/actions/use-theme.js +18 -0
- package/dist/assets/icons/arrow-down.svelte +12 -0
- package/dist/assets/icons/arrow-down.svelte.d.ts +18 -0
- package/dist/assets/icons/arrow-up.svelte +12 -0
- package/dist/assets/icons/arrow-up.svelte.d.ts +18 -0
- package/dist/assets/icons/close-fill.svelte +12 -0
- package/dist/assets/icons/close-fill.svelte.d.ts +18 -0
- package/dist/assets/icons/loading-fill.svelte +31 -0
- package/dist/assets/icons/loading-fill.svelte.d.ts +18 -0
- package/dist/components/accordion/accordion.css +36 -0
- package/dist/components/accordion/accordion.svelte +39 -0
- package/dist/components/accordion/accordion.svelte.d.ts +4 -0
- package/dist/components/accordion/modules/accordion-item.css +68 -0
- package/dist/components/accordion/modules/accordion-item.svelte +94 -0
- package/dist/components/accordion/modules/accordion-item.svelte.d.ts +4 -0
- package/dist/components/accordion/types.d.ts +33 -0
- package/dist/components/accordion/types.js +1 -0
- package/dist/components/alert/alert.css +130 -0
- package/dist/components/alert/alert.svelte +89 -0
- package/dist/components/alert/alert.svelte.d.ts +4 -0
- package/dist/components/alert/types.d.ts +28 -0
- package/dist/components/alert/types.js +1 -0
- package/dist/components/app/app.css +26 -0
- package/dist/components/app/app.svelte +79 -0
- package/dist/components/app/app.svelte.d.ts +4 -0
- package/dist/components/app/types.d.ts +10 -0
- package/dist/components/app/types.js +1 -0
- package/dist/components/appbar/appbar.css +38 -0
- package/dist/components/appbar/appbar.svelte +40 -0
- package/dist/components/appbar/appbar.svelte.d.ts +4 -0
- package/dist/components/appbar/types.d.ts +15 -0
- package/dist/components/appbar/types.js +1 -0
- package/dist/components/aspect-ratio/aspect-ratio.css +19 -0
- package/dist/components/aspect-ratio/aspect-ratio.svelte +25 -0
- package/dist/components/aspect-ratio/aspect-ratio.svelte.d.ts +4 -0
- package/dist/components/aspect-ratio/types.d.ts +5 -0
- package/dist/components/aspect-ratio/types.js +1 -0
- package/dist/components/avatar/avatar.css +102 -0
- package/dist/components/avatar/avatar.svelte +46 -0
- package/dist/components/avatar/avatar.svelte.d.ts +4 -0
- package/dist/components/avatar/types.d.ts +22 -0
- package/dist/components/avatar/types.js +1 -0
- package/dist/components/button/button.css +240 -0
- package/dist/components/button/button.svelte +102 -0
- package/dist/components/button/button.svelte.d.ts +4 -0
- package/dist/components/button/types.d.ts +29 -0
- package/dist/components/button/types.js +1 -0
- package/dist/components/card/card.css +105 -0
- package/dist/components/card/card.svelte +67 -0
- package/dist/components/card/card.svelte.d.ts +4 -0
- package/dist/components/card/types.d.ts +20 -0
- package/dist/components/card/types.js +1 -0
- package/dist/components/chip/chip.css +224 -0
- package/dist/components/chip/chip.svelte +131 -0
- package/dist/components/chip/chip.svelte.d.ts +4 -0
- package/dist/components/chip/types.d.ts +32 -0
- package/dist/components/chip/types.js +1 -0
- package/dist/components/dialog/dialog.css +129 -0
- package/dist/components/dialog/dialog.svelte +67 -0
- package/dist/components/dialog/dialog.svelte.d.ts +4 -0
- package/dist/components/dialog/types.d.ts +24 -0
- package/dist/components/dialog/types.js +1 -0
- package/dist/components/dropdown/dropdown.css +13 -0
- package/dist/components/dropdown/dropdown.svelte +115 -0
- package/dist/components/dropdown/dropdown.svelte.d.ts +4 -0
- package/dist/components/dropdown/types.d.ts +26 -0
- package/dist/components/dropdown/types.js +1 -0
- package/dist/components/icon/icon.css +78 -0
- package/dist/components/icon/icon.svelte +49 -0
- package/dist/components/icon/icon.svelte.d.ts +4 -0
- package/dist/components/icon/types.d.ts +16 -0
- package/dist/components/icon/types.js +1 -0
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +23 -0
- package/dist/components/list/list.css +149 -0
- package/dist/components/list/list.svelte +44 -0
- package/dist/components/list/list.svelte.d.ts +4 -0
- package/dist/components/list/modules/list-item.css +67 -0
- package/dist/components/list/modules/list-item.svelte +76 -0
- package/dist/components/list/modules/list-item.svelte.d.ts +4 -0
- package/dist/components/list/types.d.ts +33 -0
- package/dist/components/list/types.js +1 -0
- package/dist/components/modal/modal.css +137 -0
- package/dist/components/modal/modal.svelte +112 -0
- package/dist/components/modal/modal.svelte.d.ts +4 -0
- package/dist/components/modal/types.d.ts +26 -0
- package/dist/components/modal/types.js +1 -0
- package/dist/components/popover/popover.css +13 -0
- package/dist/components/popover/popover.svelte +73 -0
- package/dist/components/popover/popover.svelte.d.ts +4 -0
- package/dist/components/popover/types.d.ts +20 -0
- package/dist/components/popover/types.js +1 -0
- package/dist/components/separator/separator.css +42 -0
- package/dist/components/separator/separator.svelte +37 -0
- package/dist/components/separator/separator.svelte.d.ts +4 -0
- package/dist/components/separator/types.d.ts +15 -0
- package/dist/components/separator/types.js +1 -0
- package/dist/components/spacer/spacer.css +3 -0
- package/dist/components/spacer/spacer.svelte +7 -0
- package/dist/components/spacer/spacer.svelte.d.ts +4 -0
- package/dist/components/spacer/types.d.ts +4 -0
- package/dist/components/spacer/types.js +1 -0
- package/dist/components/textfield/textfield.css +298 -0
- package/dist/components/textfield/textfield.svelte +193 -0
- package/dist/components/textfield/textfield.svelte.d.ts +4 -0
- package/dist/components/textfield/types.d.ts +37 -0
- package/dist/components/textfield/types.js +1 -0
- package/dist/components/toolbar/toolbar.css +106 -0
- package/dist/components/toolbar/toolbar.svelte +47 -0
- package/dist/components/toolbar/toolbar.svelte.d.ts +4 -0
- package/dist/components/toolbar/types.d.ts +27 -0
- package/dist/components/toolbar/types.js +1 -0
- package/dist/components/tooltip/tooltip.css +116 -0
- package/dist/components/tooltip/tooltip.svelte +113 -0
- package/dist/components/tooltip/tooltip.svelte.d.ts +4 -0
- package/dist/components/tooltip/types.d.ts +23 -0
- package/dist/components/tooltip/types.js +1 -0
- package/dist/entry-bundler.d.ts +12 -0
- package/dist/entry-bundler.js +107 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +23 -3
- package/dist/internal/config/presets.d.ts +149 -0
- package/dist/internal/config/presets.js +169 -0
- package/dist/internal/config/variables.d.ts +3 -0
- package/dist/internal/config/variables.js +3 -0
- package/dist/internal/core/actions/assets.svelte.d.ts +8 -0
- package/dist/internal/core/actions/assets.svelte.js +54 -0
- package/dist/internal/core/actions/dropdown.svelte.d.ts +7 -0
- package/dist/internal/core/actions/dropdown.svelte.js +148 -0
- package/dist/internal/core/actions/popover.svelte.d.ts +7 -0
- package/dist/internal/core/actions/popover.svelte.js +134 -0
- package/dist/internal/core/actions/tooltip.svelte.d.ts +7 -0
- package/dist/internal/core/actions/tooltip.svelte.js +131 -0
- package/dist/internal/core/animations/ripple.d.ts +12 -0
- package/dist/internal/core/animations/ripple.js +93 -0
- package/dist/{server/modules → internal/core/bin}/ansi.d.ts +0 -1
- package/dist/{server/modules → internal/core/bin}/ansi.js +0 -11
- package/dist/internal/core/bin/terminal.d.ts +1 -0
- package/dist/internal/core/bin/terminal.js +12 -0
- package/dist/internal/core/css.d.ts +1 -0
- package/dist/internal/core/css.js +16 -0
- package/dist/internal/core/formatter/component.d.ts +5 -0
- package/dist/internal/core/formatter/component.js +60 -0
- package/dist/internal/core/formatter/device.d.ts +5 -0
- package/dist/internal/core/formatter/device.js +66 -0
- package/dist/internal/core/formatter/index.d.ts +7 -0
- package/dist/internal/core/formatter/index.js +35 -0
- package/dist/internal/core/formatter/style.d.ts +4 -0
- package/dist/internal/core/formatter/style.js +15 -0
- package/dist/internal/core/formatter/theme.d.ts +5 -0
- package/dist/internal/core/formatter/theme.js +44 -0
- package/dist/internal/core/formatter/typography.d.ts +5 -0
- package/dist/internal/core/formatter/typography.js +12 -0
- package/dist/internal/core/standard-colors.d.ts +75 -0
- package/dist/internal/core/standard-colors.js +75 -0
- package/dist/{server/modules/x11.d.ts → internal/core/x11-colors.d.ts} +1 -1
- package/dist/internal/helpers/colors.d.ts +1 -0
- package/dist/{server/modules → internal/helpers}/colors.js +2 -2
- package/dist/internal/helpers/convert.d.ts +1 -0
- package/dist/internal/helpers/convert.js +17 -0
- package/dist/internal/helpers/deep-merge.d.ts +44 -0
- package/dist/internal/helpers/deep-merge.js +80 -0
- package/dist/internal/helpers/outside.d.ts +9 -0
- package/dist/internal/helpers/outside.js +34 -0
- package/dist/internal/helpers/parser.d.ts +10 -0
- package/dist/internal/helpers/parser.js +93 -0
- package/dist/internal/helpers/scroll.d.ts +1 -0
- package/dist/internal/helpers/scroll.js +5 -0
- package/dist/internal/plugins/vite.d.ts +8 -0
- package/dist/internal/plugins/vite.js +33 -0
- package/dist/internal/types/components.d.ts +14 -0
- package/dist/internal/types/components.js +1 -0
- package/dist/internal/types/configuration.d.ts +63 -0
- package/dist/internal/types/configuration.js +1 -0
- package/dist/internal/types/index.d.ts +2 -0
- package/dist/internal/types/index.js +2 -0
- package/dist/labs/components/btn/btn.svelte +13 -0
- package/dist/labs/components/btn/btn.svelte.d.ts +5 -0
- package/dist/labs/components/index.d.ts +1 -0
- package/dist/labs/components/index.js +2 -0
- package/dist/stores/breakpoints.d.ts +6 -0
- package/dist/stores/breakpoints.js +14 -0
- package/dist/stores/components.d.ts +8 -0
- package/dist/stores/components.js +26 -0
- package/dist/stores/devices.d.ts +6 -0
- package/dist/stores/devices.js +9 -0
- package/dist/stores/index.d.ts +5 -0
- package/dist/stores/index.js +5 -0
- package/dist/stores/themes.d.ts +2 -0
- package/dist/stores/themes.js +4 -0
- package/dist/stores/viewport.d.ts +7 -0
- package/dist/stores/viewport.js +7 -0
- package/dist/styles/animation.css +33 -0
- package/dist/styles/keyframes.css +30 -0
- package/dist/styles/{normalize.css → reset.css} +15 -5
- package/dist/styles.css.d.ts +4 -0
- package/dist/themes.css +0 -0
- package/dist/themes.css.d.ts +4 -0
- package/package.json +135 -74
- package/dist/app.d.ts +0 -13
- package/dist/app.html +0 -12
- package/dist/server/modules/colors.d.ts +0 -1
- package/dist/server/modules/css.d.ts +0 -1
- package/dist/server/modules/css.js +0 -144
- package/dist/server/modules/devices.d.ts +0 -1
- package/dist/server/modules/devices.js +0 -43
- package/dist/server/modules/importer.d.ts +0 -1
- package/dist/server/modules/importer.js +0 -13
- package/dist/server/modules/themes.d.ts +0 -4
- package/dist/server/modules/themes.js +0 -94
- package/dist/server/vite.d.ts +0 -11
- package/dist/server/vite.js +0 -17
- package/dist/styles/variables.css +0 -7
- /package/dist/{server/modules → internal/core}/minify.d.ts +0 -0
- /package/dist/{server/modules → internal/core}/minify.js +0 -0
- /package/dist/{server/modules/x11.js → internal/core/x11-colors.js} +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { variables } from './variables.js';
|
|
2
|
+
import standardColors from '../core/standard-colors.js';
|
|
3
|
+
export const preset = {
|
|
4
|
+
breakpoints: {
|
|
5
|
+
devices: {
|
|
6
|
+
desktop: 1024, //64rem (lg)
|
|
7
|
+
tablet: 768, //48rem (md)
|
|
8
|
+
mobile: 640 //40rem (sm)
|
|
9
|
+
},
|
|
10
|
+
thresholds: {
|
|
11
|
+
base: 0, // 0px
|
|
12
|
+
xs: 448, //28rem
|
|
13
|
+
sm: 640, //40rem
|
|
14
|
+
md: 768, //48rem
|
|
15
|
+
lg: 1024, //64rem
|
|
16
|
+
xl: 1280, //80rem
|
|
17
|
+
'2xl': 1536, //96rem
|
|
18
|
+
'3xl': 1792 //112rem
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
theme: {
|
|
22
|
+
defaultTheme: 'light',
|
|
23
|
+
colorScheme: true,
|
|
24
|
+
themes: {
|
|
25
|
+
light: {
|
|
26
|
+
dark: false,
|
|
27
|
+
colors: {
|
|
28
|
+
label: {
|
|
29
|
+
primary: '#000000',
|
|
30
|
+
secondary: standardColors.gray.light,
|
|
31
|
+
tertiary: standardColors.gray2.light,
|
|
32
|
+
quaternary: standardColors.gray3.light
|
|
33
|
+
},
|
|
34
|
+
accent: {
|
|
35
|
+
primary: standardColors.blue.light,
|
|
36
|
+
success: standardColors.green.light,
|
|
37
|
+
warning: standardColors.orange.light,
|
|
38
|
+
destructive: standardColors.red.light,
|
|
39
|
+
info: standardColors.cyan.light
|
|
40
|
+
},
|
|
41
|
+
separator: {
|
|
42
|
+
default: standardColors.gray3.light,
|
|
43
|
+
opaque: standardColors.gray4.light
|
|
44
|
+
},
|
|
45
|
+
state: {
|
|
46
|
+
placeholder: standardColors.gray3.light,
|
|
47
|
+
disabled: standardColors.gray2.light,
|
|
48
|
+
link: standardColors.blue.light,
|
|
49
|
+
highlight: standardColors.gray5.light,
|
|
50
|
+
shadow: '#00000033'
|
|
51
|
+
},
|
|
52
|
+
background: {
|
|
53
|
+
primary: '#FFFFFF',
|
|
54
|
+
secondary: standardColors.gray6.light,
|
|
55
|
+
tertiary: standardColors.gray5.light,
|
|
56
|
+
grouped: {
|
|
57
|
+
primary: standardColors.gray6.light,
|
|
58
|
+
secondary: '#FFFFFF',
|
|
59
|
+
tertiary: standardColors.gray6.light
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
variables: variables
|
|
64
|
+
},
|
|
65
|
+
dark: {
|
|
66
|
+
dark: true,
|
|
67
|
+
colors: {
|
|
68
|
+
pink: 'pink',
|
|
69
|
+
label: {
|
|
70
|
+
primary: '#FFFFFF',
|
|
71
|
+
secondary: standardColors.gray2.dark,
|
|
72
|
+
tertiary: standardColors.gray3.dark,
|
|
73
|
+
quaternary: standardColors.gray4.dark
|
|
74
|
+
},
|
|
75
|
+
accent: {
|
|
76
|
+
primary: standardColors.blue.dark,
|
|
77
|
+
success: standardColors.green.dark,
|
|
78
|
+
warning: standardColors.orange.dark,
|
|
79
|
+
destructive: standardColors.red.dark,
|
|
80
|
+
info: standardColors.cyan.dark
|
|
81
|
+
},
|
|
82
|
+
separator: {
|
|
83
|
+
default: standardColors.gray3.dark,
|
|
84
|
+
opaque: standardColors.gray4.dark
|
|
85
|
+
},
|
|
86
|
+
state: {
|
|
87
|
+
placeholder: standardColors.gray3.dark,
|
|
88
|
+
disabled: standardColors.gray4.dark,
|
|
89
|
+
link: standardColors.blue.dark,
|
|
90
|
+
highlight: standardColors.gray5.dark,
|
|
91
|
+
shadow: '#00000066'
|
|
92
|
+
},
|
|
93
|
+
background: {
|
|
94
|
+
primary: '#000000',
|
|
95
|
+
secondary: standardColors.gray6.dark,
|
|
96
|
+
tertiary: standardColors.gray5.dark,
|
|
97
|
+
grouped: {
|
|
98
|
+
primary: standardColors.gray6.dark,
|
|
99
|
+
secondary: standardColors.gray5.dark,
|
|
100
|
+
tertiary: standardColors.gray4.dark
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
variables: variables
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
typography: {
|
|
109
|
+
defaultTypography: 'default',
|
|
110
|
+
fonts: {
|
|
111
|
+
default: {
|
|
112
|
+
sans: [
|
|
113
|
+
'system-ui',
|
|
114
|
+
'-apple-system',
|
|
115
|
+
'BlinkMacSystemFont',
|
|
116
|
+
'Segoe UI',
|
|
117
|
+
'Roboto',
|
|
118
|
+
'Helvetica Neue',
|
|
119
|
+
'Arial',
|
|
120
|
+
'sans-serif',
|
|
121
|
+
'Apple Color Emoji',
|
|
122
|
+
'Segoe UI Emoji',
|
|
123
|
+
'Segoe UI Symbol'
|
|
124
|
+
],
|
|
125
|
+
mono: [
|
|
126
|
+
'SFMono-Regular',
|
|
127
|
+
'ui-monospace',
|
|
128
|
+
'SF Mono',
|
|
129
|
+
'Menlo',
|
|
130
|
+
'Monaco',
|
|
131
|
+
'Consolas',
|
|
132
|
+
'Liberation Mono',
|
|
133
|
+
'Courier New',
|
|
134
|
+
'monospace'
|
|
135
|
+
],
|
|
136
|
+
serif: ['Merriweather', 'Georgia', 'Cambria', 'Times New Roman', 'Times', 'serif']
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
styles: {
|
|
141
|
+
spacing: '0.125rem', // 2px
|
|
142
|
+
shape: {
|
|
143
|
+
sm: '0.125rem', // 2px
|
|
144
|
+
md: '0.25rem', // 4px
|
|
145
|
+
lg: '0.5rem', // 8px
|
|
146
|
+
xl: '0.75rem', // 12px
|
|
147
|
+
'2xl': '1rem', // 16px
|
|
148
|
+
'3xl': '1.5rem', // 24px
|
|
149
|
+
full: '9999px' // 9999px
|
|
150
|
+
},
|
|
151
|
+
dialog: {
|
|
152
|
+
xs: '18.75rem', // 300px
|
|
153
|
+
sm: '25rem', // 400px
|
|
154
|
+
md: '37.5rem', // 600px
|
|
155
|
+
lg: '53.125rem', // 850px
|
|
156
|
+
xl: '75rem' // 1200px
|
|
157
|
+
},
|
|
158
|
+
modal: {
|
|
159
|
+
xs: '18.75rem', // 300px
|
|
160
|
+
sm: '25rem', // 400px
|
|
161
|
+
md: '37.5rem', // 600px
|
|
162
|
+
lg: '53.125rem', // 850px
|
|
163
|
+
xl: '75rem' // 1200px
|
|
164
|
+
},
|
|
165
|
+
animation: {
|
|
166
|
+
'ripple-duration': '0.4s'
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function getAssets(): {
|
|
2
|
+
shape(params?: string): string | undefined;
|
|
3
|
+
className(key: string, type: string, value: string | boolean | Array<string> | {
|
|
4
|
+
[key: string]: string;
|
|
5
|
+
}): string | undefined;
|
|
6
|
+
color(color?: string): string | undefined;
|
|
7
|
+
unit(value?: string | number): string | undefined;
|
|
8
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { x11ColorNames } from '../x11-colors.js';
|
|
2
|
+
export function getAssets() {
|
|
3
|
+
return {
|
|
4
|
+
shape(params) {
|
|
5
|
+
if (params) {
|
|
6
|
+
if (params === 'none' || params == '0')
|
|
7
|
+
return '0';
|
|
8
|
+
return `var(--system-shape-${params})`;
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
className(key, type, value) {
|
|
12
|
+
if (typeof value === 'string')
|
|
13
|
+
return `kit-${key}--${type}-${value}`;
|
|
14
|
+
else if (typeof value === 'boolean' && value)
|
|
15
|
+
return `kit-${key}--${type}`;
|
|
16
|
+
else if (typeof value === 'object') {
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
return value
|
|
19
|
+
.map((media) => `${media === 'base' ? '' : `${media}:`}kit--${type}`)
|
|
20
|
+
.join(' ');
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return Object.entries(value)
|
|
24
|
+
.map(([media, value]) => `${media === 'base' ? '' : `${media}:`}kit-${key}--${type}-${value}`)
|
|
25
|
+
.join(' ');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
color(color) {
|
|
30
|
+
if (color) {
|
|
31
|
+
if (color.includes('#') ||
|
|
32
|
+
color.includes('rgb') ||
|
|
33
|
+
color.includes('rgba') ||
|
|
34
|
+
color.includes('oklch') ||
|
|
35
|
+
x11ColorNames.includes(color.toLowerCase()))
|
|
36
|
+
return color;
|
|
37
|
+
if (color.includes('transparent') || color.includes('inherit') || color.includes('initial'))
|
|
38
|
+
return color;
|
|
39
|
+
return `var(--kit-${color})`;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
unit(value) {
|
|
43
|
+
if (typeof value === 'number')
|
|
44
|
+
return `${value}px`;
|
|
45
|
+
if (typeof value === 'string') {
|
|
46
|
+
const cleaned = value.trim();
|
|
47
|
+
const isOnlyNumericLike = /^[\d.,]+$/.test(cleaned);
|
|
48
|
+
if (isOnlyNumericLike)
|
|
49
|
+
return `${value}px`;
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PositionElement } from '../../../components/dropdown/types.js';
|
|
2
|
+
type Location = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
export declare function getPositions(): {
|
|
4
|
+
readonly values: PositionElement;
|
|
5
|
+
update(activator: HTMLElement | PointerEvent, element: HTMLElement, location?: Location, centered?: boolean, avoidCollisions?: boolean): void;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { innerWidth, innerHeight } from 'svelte/reactivity/window';
|
|
2
|
+
export function getPositions() {
|
|
3
|
+
// state
|
|
4
|
+
const axis = $state({
|
|
5
|
+
x: 0,
|
|
6
|
+
y: 0,
|
|
7
|
+
location: null
|
|
8
|
+
});
|
|
9
|
+
return {
|
|
10
|
+
get values() {
|
|
11
|
+
return axis;
|
|
12
|
+
},
|
|
13
|
+
update(activator, element, location, centered, avoidCollisions) {
|
|
14
|
+
if (!activator || !element)
|
|
15
|
+
return;
|
|
16
|
+
const elementRect = element.getBoundingClientRect();
|
|
17
|
+
if (!(activator instanceof HTMLElement)) {
|
|
18
|
+
if (activator.clientX + elementRect.width > innerWidth.current) {
|
|
19
|
+
axis.x = activator.clientX - elementRect.width;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
axis.x = activator.clientX;
|
|
23
|
+
}
|
|
24
|
+
if (activator.clientY + elementRect.height > innerHeight.current) {
|
|
25
|
+
axis.y = activator.clientY - elementRect.height;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
axis.y = activator.clientY;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else if (activator instanceof HTMLElement) {
|
|
32
|
+
const activatorRect = activator.getBoundingClientRect();
|
|
33
|
+
const spacing = 0;
|
|
34
|
+
const _activator = activatorRect.y + activatorRect.height;
|
|
35
|
+
const _element = elementRect.height + spacing;
|
|
36
|
+
if (location === 'top' || location === 'bottom') {
|
|
37
|
+
if (avoidCollisions) {
|
|
38
|
+
if (location === 'top') {
|
|
39
|
+
if (activatorRect.y - _element < 0) {
|
|
40
|
+
axis.y = activatorRect.bottom + spacing;
|
|
41
|
+
axis.location = 'bottom';
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
axis.y = activatorRect.top - _element;
|
|
45
|
+
axis.location = 'top';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
if (_activator + _element > innerHeight.current) {
|
|
50
|
+
axis.y = activatorRect.top - _element;
|
|
51
|
+
axis.location = 'top';
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
axis.y = activatorRect.bottom + spacing;
|
|
55
|
+
axis.location = 'bottom';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
if (location === 'top') {
|
|
61
|
+
axis.y = activatorRect.top - _element;
|
|
62
|
+
axis.location = 'top';
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
axis.y = activatorRect.bottom + spacing;
|
|
66
|
+
axis.location = 'bottom';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (centered &&
|
|
70
|
+
activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
|
|
71
|
+
activatorRect.left + elementRect.width < innerWidth.current) {
|
|
72
|
+
axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
|
|
73
|
+
}
|
|
74
|
+
else if (activatorRect.left + elementRect.width > innerWidth.current) {
|
|
75
|
+
axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
axis.x = activatorRect.left;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (location === 'left' || location === 'right') {
|
|
82
|
+
if (avoidCollisions) {
|
|
83
|
+
if (location === 'left' && !(activatorRect.left - elementRect.width < 0)) {
|
|
84
|
+
axis.x = activatorRect.left - (elementRect.width + spacing);
|
|
85
|
+
axis.location = 'left';
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
if (activatorRect.left + activatorRect.width + elementRect.width + spacing >
|
|
89
|
+
innerWidth.current) {
|
|
90
|
+
axis.x = activatorRect.left - (elementRect.width + spacing);
|
|
91
|
+
axis.location = 'left';
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
axis.x = activatorRect.left + activatorRect.width + spacing;
|
|
95
|
+
axis.location = 'right';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
if (location === 'left') {
|
|
101
|
+
axis.x = activatorRect.left - (elementRect.width + spacing);
|
|
102
|
+
axis.location = 'left';
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
axis.x = activatorRect.left + activatorRect.width + spacing;
|
|
106
|
+
axis.location = 'right';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (centered &&
|
|
110
|
+
activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
|
|
111
|
+
activatorRect.top + elementRect.height < innerHeight.current) {
|
|
112
|
+
axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
|
|
113
|
+
}
|
|
114
|
+
else if (activatorRect.y + elementRect.height > innerHeight.current) {
|
|
115
|
+
axis.y = activatorRect.y - elementRect.height + activatorRect.height;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
axis.y = activatorRect.y;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
if (centered &&
|
|
123
|
+
activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
|
|
124
|
+
activatorRect.left + elementRect.width < innerWidth.current) {
|
|
125
|
+
axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
|
|
126
|
+
}
|
|
127
|
+
else if (activatorRect.left + elementRect.width > innerWidth.current) {
|
|
128
|
+
axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
axis.x = activatorRect.left;
|
|
132
|
+
}
|
|
133
|
+
if (centered &&
|
|
134
|
+
activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
|
|
135
|
+
activatorRect.top + elementRect.height < innerHeight.current) {
|
|
136
|
+
axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
|
|
137
|
+
}
|
|
138
|
+
else if (activatorRect.bottom + elementRect.height > innerHeight.current) {
|
|
139
|
+
axis.y = activatorRect.top - elementRect.height;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
axis.y = activatorRect.bottom;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PositionElement } from '../../../components/popover/types.js';
|
|
2
|
+
type Location = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
export declare function getPositions(): {
|
|
4
|
+
readonly values: PositionElement;
|
|
5
|
+
update(activator: HTMLElement, element: HTMLElement, location?: Location, centered?: boolean, avoidCollisions?: boolean): void;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { innerWidth, innerHeight } from 'svelte/reactivity/window';
|
|
2
|
+
export function getPositions() {
|
|
3
|
+
// state
|
|
4
|
+
const axis = $state({
|
|
5
|
+
x: 0,
|
|
6
|
+
y: 0,
|
|
7
|
+
location: null
|
|
8
|
+
});
|
|
9
|
+
return {
|
|
10
|
+
get values() {
|
|
11
|
+
return axis;
|
|
12
|
+
},
|
|
13
|
+
update(activator, element, location, centered, avoidCollisions) {
|
|
14
|
+
if (!activator || !element)
|
|
15
|
+
return;
|
|
16
|
+
const elementRect = element.getBoundingClientRect();
|
|
17
|
+
if (activator instanceof HTMLElement) {
|
|
18
|
+
const activatorRect = activator.getBoundingClientRect();
|
|
19
|
+
const spacing = 6;
|
|
20
|
+
const _activator = activatorRect.y + activatorRect.height;
|
|
21
|
+
const _element = elementRect.height + spacing;
|
|
22
|
+
if (location === 'top' || location === 'bottom') {
|
|
23
|
+
if (avoidCollisions) {
|
|
24
|
+
if (location === 'top') {
|
|
25
|
+
if (activatorRect.y - _element < 0) {
|
|
26
|
+
axis.y = activatorRect.bottom + spacing;
|
|
27
|
+
axis.location = 'bottom';
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
axis.y = activatorRect.top - _element;
|
|
31
|
+
axis.location = 'top';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
if (_activator + _element > innerHeight.current) {
|
|
36
|
+
axis.y = activatorRect.top - _element;
|
|
37
|
+
axis.location = 'top';
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
axis.y = activatorRect.bottom + spacing;
|
|
41
|
+
axis.location = 'bottom';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
if (location === 'top') {
|
|
47
|
+
axis.y = activatorRect.top - _element;
|
|
48
|
+
axis.location = 'top';
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
axis.y = activatorRect.bottom + spacing;
|
|
52
|
+
axis.location = 'bottom';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (centered &&
|
|
56
|
+
activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
|
|
57
|
+
activatorRect.left + elementRect.width < innerWidth.current) {
|
|
58
|
+
axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
|
|
59
|
+
}
|
|
60
|
+
else if (activatorRect.left + elementRect.width > innerWidth.current) {
|
|
61
|
+
axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
axis.x = activatorRect.left;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (location === 'left' || location === 'right') {
|
|
68
|
+
if (avoidCollisions) {
|
|
69
|
+
if (location === 'left' && !(activatorRect.left - elementRect.width < 0)) {
|
|
70
|
+
axis.x = activatorRect.left - (elementRect.width + spacing);
|
|
71
|
+
axis.location = 'left';
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
if (activatorRect.left + activatorRect.width + elementRect.width + spacing >
|
|
75
|
+
innerWidth.current) {
|
|
76
|
+
axis.x = activatorRect.left - (elementRect.width + spacing);
|
|
77
|
+
axis.location = 'left';
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
axis.x = activatorRect.left + activatorRect.width + spacing;
|
|
81
|
+
axis.location = 'right';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
if (location === 'left') {
|
|
87
|
+
axis.x = activatorRect.left - (elementRect.width + spacing);
|
|
88
|
+
axis.location = 'left';
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
axis.x = activatorRect.left + activatorRect.width + spacing;
|
|
92
|
+
axis.location = 'right';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (centered &&
|
|
96
|
+
activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
|
|
97
|
+
activatorRect.top + elementRect.height < innerHeight.current) {
|
|
98
|
+
axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
|
|
99
|
+
}
|
|
100
|
+
else if (activatorRect.y + elementRect.height > innerHeight.current) {
|
|
101
|
+
axis.y = activatorRect.y - elementRect.height + activatorRect.height;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
axis.y = activatorRect.y;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
if (centered &&
|
|
109
|
+
activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
|
|
110
|
+
activatorRect.left + elementRect.width < innerWidth.current) {
|
|
111
|
+
axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
|
|
112
|
+
}
|
|
113
|
+
else if (activatorRect.left + elementRect.width > innerWidth.current) {
|
|
114
|
+
axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
axis.x = activatorRect.left;
|
|
118
|
+
}
|
|
119
|
+
if (centered &&
|
|
120
|
+
activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
|
|
121
|
+
activatorRect.top + elementRect.height < innerHeight.current) {
|
|
122
|
+
axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
|
|
123
|
+
}
|
|
124
|
+
else if (activatorRect.bottom + elementRect.height > innerHeight.current) {
|
|
125
|
+
axis.y = activatorRect.top - elementRect.height;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
axis.y = activatorRect.bottom;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PositionElement } from '../../../components/tooltip/types.js';
|
|
2
|
+
type Location = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
export declare function getPositionsTooltip(): {
|
|
4
|
+
readonly values: PositionElement;
|
|
5
|
+
update(activator: HTMLElement, element: HTMLElement, location?: Location, centered?: boolean, avoidCollisions?: boolean): void;
|
|
6
|
+
};
|
|
7
|
+
export {};
|