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.
Files changed (228) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -1
  3. package/bin/configuration.js +303 -0
  4. package/bin/helper.js +59 -0
  5. package/bin/index.js +33 -0
  6. package/bin/presets.js +26 -0
  7. package/bin/prompts.js +67 -0
  8. package/dist/actions/accordion.svelte.d.ts +9 -0
  9. package/dist/actions/accordion.svelte.js +24 -0
  10. package/dist/actions/index.d.ts +2 -0
  11. package/dist/actions/index.js +2 -0
  12. package/dist/actions/use-theme.d.ts +1 -0
  13. package/dist/actions/use-theme.js +18 -0
  14. package/dist/assets/icons/arrow-down.svelte +12 -0
  15. package/dist/assets/icons/arrow-down.svelte.d.ts +18 -0
  16. package/dist/assets/icons/arrow-up.svelte +12 -0
  17. package/dist/assets/icons/arrow-up.svelte.d.ts +18 -0
  18. package/dist/assets/icons/close-fill.svelte +12 -0
  19. package/dist/assets/icons/close-fill.svelte.d.ts +18 -0
  20. package/dist/assets/icons/loading-fill.svelte +31 -0
  21. package/dist/assets/icons/loading-fill.svelte.d.ts +18 -0
  22. package/dist/components/accordion/accordion.css +36 -0
  23. package/dist/components/accordion/accordion.svelte +39 -0
  24. package/dist/components/accordion/accordion.svelte.d.ts +4 -0
  25. package/dist/components/accordion/modules/accordion-item.css +68 -0
  26. package/dist/components/accordion/modules/accordion-item.svelte +94 -0
  27. package/dist/components/accordion/modules/accordion-item.svelte.d.ts +4 -0
  28. package/dist/components/accordion/types.d.ts +33 -0
  29. package/dist/components/accordion/types.js +1 -0
  30. package/dist/components/alert/alert.css +130 -0
  31. package/dist/components/alert/alert.svelte +89 -0
  32. package/dist/components/alert/alert.svelte.d.ts +4 -0
  33. package/dist/components/alert/types.d.ts +28 -0
  34. package/dist/components/alert/types.js +1 -0
  35. package/dist/components/app/app.css +26 -0
  36. package/dist/components/app/app.svelte +79 -0
  37. package/dist/components/app/app.svelte.d.ts +4 -0
  38. package/dist/components/app/types.d.ts +10 -0
  39. package/dist/components/app/types.js +1 -0
  40. package/dist/components/appbar/appbar.css +38 -0
  41. package/dist/components/appbar/appbar.svelte +40 -0
  42. package/dist/components/appbar/appbar.svelte.d.ts +4 -0
  43. package/dist/components/appbar/types.d.ts +15 -0
  44. package/dist/components/appbar/types.js +1 -0
  45. package/dist/components/aspect-ratio/aspect-ratio.css +19 -0
  46. package/dist/components/aspect-ratio/aspect-ratio.svelte +25 -0
  47. package/dist/components/aspect-ratio/aspect-ratio.svelte.d.ts +4 -0
  48. package/dist/components/aspect-ratio/types.d.ts +5 -0
  49. package/dist/components/aspect-ratio/types.js +1 -0
  50. package/dist/components/avatar/avatar.css +102 -0
  51. package/dist/components/avatar/avatar.svelte +46 -0
  52. package/dist/components/avatar/avatar.svelte.d.ts +4 -0
  53. package/dist/components/avatar/types.d.ts +22 -0
  54. package/dist/components/avatar/types.js +1 -0
  55. package/dist/components/button/button.css +240 -0
  56. package/dist/components/button/button.svelte +102 -0
  57. package/dist/components/button/button.svelte.d.ts +4 -0
  58. package/dist/components/button/types.d.ts +29 -0
  59. package/dist/components/button/types.js +1 -0
  60. package/dist/components/card/card.css +105 -0
  61. package/dist/components/card/card.svelte +67 -0
  62. package/dist/components/card/card.svelte.d.ts +4 -0
  63. package/dist/components/card/types.d.ts +20 -0
  64. package/dist/components/card/types.js +1 -0
  65. package/dist/components/chip/chip.css +224 -0
  66. package/dist/components/chip/chip.svelte +131 -0
  67. package/dist/components/chip/chip.svelte.d.ts +4 -0
  68. package/dist/components/chip/types.d.ts +32 -0
  69. package/dist/components/chip/types.js +1 -0
  70. package/dist/components/dialog/dialog.css +129 -0
  71. package/dist/components/dialog/dialog.svelte +67 -0
  72. package/dist/components/dialog/dialog.svelte.d.ts +4 -0
  73. package/dist/components/dialog/types.d.ts +24 -0
  74. package/dist/components/dialog/types.js +1 -0
  75. package/dist/components/dropdown/dropdown.css +13 -0
  76. package/dist/components/dropdown/dropdown.svelte +115 -0
  77. package/dist/components/dropdown/dropdown.svelte.d.ts +4 -0
  78. package/dist/components/dropdown/types.d.ts +26 -0
  79. package/dist/components/dropdown/types.js +1 -0
  80. package/dist/components/icon/icon.css +78 -0
  81. package/dist/components/icon/icon.svelte +49 -0
  82. package/dist/components/icon/icon.svelte.d.ts +4 -0
  83. package/dist/components/icon/types.d.ts +16 -0
  84. package/dist/components/icon/types.js +1 -0
  85. package/dist/components/index.d.ts +22 -0
  86. package/dist/components/index.js +23 -0
  87. package/dist/components/list/list.css +149 -0
  88. package/dist/components/list/list.svelte +44 -0
  89. package/dist/components/list/list.svelte.d.ts +4 -0
  90. package/dist/components/list/modules/list-item.css +67 -0
  91. package/dist/components/list/modules/list-item.svelte +76 -0
  92. package/dist/components/list/modules/list-item.svelte.d.ts +4 -0
  93. package/dist/components/list/types.d.ts +33 -0
  94. package/dist/components/list/types.js +1 -0
  95. package/dist/components/modal/modal.css +137 -0
  96. package/dist/components/modal/modal.svelte +112 -0
  97. package/dist/components/modal/modal.svelte.d.ts +4 -0
  98. package/dist/components/modal/types.d.ts +26 -0
  99. package/dist/components/modal/types.js +1 -0
  100. package/dist/components/popover/popover.css +13 -0
  101. package/dist/components/popover/popover.svelte +73 -0
  102. package/dist/components/popover/popover.svelte.d.ts +4 -0
  103. package/dist/components/popover/types.d.ts +20 -0
  104. package/dist/components/popover/types.js +1 -0
  105. package/dist/components/separator/separator.css +42 -0
  106. package/dist/components/separator/separator.svelte +37 -0
  107. package/dist/components/separator/separator.svelte.d.ts +4 -0
  108. package/dist/components/separator/types.d.ts +15 -0
  109. package/dist/components/separator/types.js +1 -0
  110. package/dist/components/spacer/spacer.css +3 -0
  111. package/dist/components/spacer/spacer.svelte +7 -0
  112. package/dist/components/spacer/spacer.svelte.d.ts +4 -0
  113. package/dist/components/spacer/types.d.ts +4 -0
  114. package/dist/components/spacer/types.js +1 -0
  115. package/dist/components/textfield/textfield.css +298 -0
  116. package/dist/components/textfield/textfield.svelte +193 -0
  117. package/dist/components/textfield/textfield.svelte.d.ts +4 -0
  118. package/dist/components/textfield/types.d.ts +37 -0
  119. package/dist/components/textfield/types.js +1 -0
  120. package/dist/components/toolbar/toolbar.css +106 -0
  121. package/dist/components/toolbar/toolbar.svelte +47 -0
  122. package/dist/components/toolbar/toolbar.svelte.d.ts +4 -0
  123. package/dist/components/toolbar/types.d.ts +27 -0
  124. package/dist/components/toolbar/types.js +1 -0
  125. package/dist/components/tooltip/tooltip.css +116 -0
  126. package/dist/components/tooltip/tooltip.svelte +113 -0
  127. package/dist/components/tooltip/tooltip.svelte.d.ts +4 -0
  128. package/dist/components/tooltip/types.d.ts +23 -0
  129. package/dist/components/tooltip/types.js +1 -0
  130. package/dist/entry-bundler.d.ts +12 -0
  131. package/dist/entry-bundler.js +107 -0
  132. package/dist/index.d.ts +3 -1
  133. package/dist/index.js +23 -3
  134. package/dist/internal/config/presets.d.ts +149 -0
  135. package/dist/internal/config/presets.js +169 -0
  136. package/dist/internal/config/variables.d.ts +3 -0
  137. package/dist/internal/config/variables.js +3 -0
  138. package/dist/internal/core/actions/assets.svelte.d.ts +8 -0
  139. package/dist/internal/core/actions/assets.svelte.js +54 -0
  140. package/dist/internal/core/actions/dropdown.svelte.d.ts +7 -0
  141. package/dist/internal/core/actions/dropdown.svelte.js +148 -0
  142. package/dist/internal/core/actions/popover.svelte.d.ts +7 -0
  143. package/dist/internal/core/actions/popover.svelte.js +134 -0
  144. package/dist/internal/core/actions/tooltip.svelte.d.ts +7 -0
  145. package/dist/internal/core/actions/tooltip.svelte.js +131 -0
  146. package/dist/internal/core/animations/ripple.d.ts +12 -0
  147. package/dist/internal/core/animations/ripple.js +93 -0
  148. package/dist/{server/modules → internal/core/bin}/ansi.d.ts +0 -1
  149. package/dist/{server/modules → internal/core/bin}/ansi.js +0 -11
  150. package/dist/internal/core/bin/terminal.d.ts +1 -0
  151. package/dist/internal/core/bin/terminal.js +12 -0
  152. package/dist/internal/core/css.d.ts +1 -0
  153. package/dist/internal/core/css.js +16 -0
  154. package/dist/internal/core/formatter/component.d.ts +5 -0
  155. package/dist/internal/core/formatter/component.js +60 -0
  156. package/dist/internal/core/formatter/device.d.ts +5 -0
  157. package/dist/internal/core/formatter/device.js +66 -0
  158. package/dist/internal/core/formatter/index.d.ts +7 -0
  159. package/dist/internal/core/formatter/index.js +35 -0
  160. package/dist/internal/core/formatter/style.d.ts +4 -0
  161. package/dist/internal/core/formatter/style.js +15 -0
  162. package/dist/internal/core/formatter/theme.d.ts +5 -0
  163. package/dist/internal/core/formatter/theme.js +44 -0
  164. package/dist/internal/core/formatter/typography.d.ts +5 -0
  165. package/dist/internal/core/formatter/typography.js +12 -0
  166. package/dist/internal/core/standard-colors.d.ts +75 -0
  167. package/dist/internal/core/standard-colors.js +75 -0
  168. package/dist/{server/modules/x11.d.ts → internal/core/x11-colors.d.ts} +1 -1
  169. package/dist/internal/helpers/colors.d.ts +1 -0
  170. package/dist/{server/modules → internal/helpers}/colors.js +2 -2
  171. package/dist/internal/helpers/convert.d.ts +1 -0
  172. package/dist/internal/helpers/convert.js +17 -0
  173. package/dist/internal/helpers/deep-merge.d.ts +44 -0
  174. package/dist/internal/helpers/deep-merge.js +80 -0
  175. package/dist/internal/helpers/outside.d.ts +9 -0
  176. package/dist/internal/helpers/outside.js +34 -0
  177. package/dist/internal/helpers/parser.d.ts +10 -0
  178. package/dist/internal/helpers/parser.js +93 -0
  179. package/dist/internal/helpers/scroll.d.ts +1 -0
  180. package/dist/internal/helpers/scroll.js +5 -0
  181. package/dist/internal/plugins/vite.d.ts +8 -0
  182. package/dist/internal/plugins/vite.js +33 -0
  183. package/dist/internal/types/components.d.ts +14 -0
  184. package/dist/internal/types/components.js +1 -0
  185. package/dist/internal/types/configuration.d.ts +63 -0
  186. package/dist/internal/types/configuration.js +1 -0
  187. package/dist/internal/types/index.d.ts +2 -0
  188. package/dist/internal/types/index.js +2 -0
  189. package/dist/labs/components/btn/btn.svelte +13 -0
  190. package/dist/labs/components/btn/btn.svelte.d.ts +5 -0
  191. package/dist/labs/components/index.d.ts +1 -0
  192. package/dist/labs/components/index.js +2 -0
  193. package/dist/stores/breakpoints.d.ts +6 -0
  194. package/dist/stores/breakpoints.js +14 -0
  195. package/dist/stores/components.d.ts +8 -0
  196. package/dist/stores/components.js +26 -0
  197. package/dist/stores/devices.d.ts +6 -0
  198. package/dist/stores/devices.js +9 -0
  199. package/dist/stores/index.d.ts +5 -0
  200. package/dist/stores/index.js +5 -0
  201. package/dist/stores/themes.d.ts +2 -0
  202. package/dist/stores/themes.js +4 -0
  203. package/dist/stores/viewport.d.ts +7 -0
  204. package/dist/stores/viewport.js +7 -0
  205. package/dist/styles/animation.css +33 -0
  206. package/dist/styles/keyframes.css +30 -0
  207. package/dist/styles/{normalize.css → reset.css} +15 -5
  208. package/dist/styles.css.d.ts +4 -0
  209. package/dist/themes.css +0 -0
  210. package/dist/themes.css.d.ts +4 -0
  211. package/package.json +135 -74
  212. package/dist/app.d.ts +0 -13
  213. package/dist/app.html +0 -12
  214. package/dist/server/modules/colors.d.ts +0 -1
  215. package/dist/server/modules/css.d.ts +0 -1
  216. package/dist/server/modules/css.js +0 -144
  217. package/dist/server/modules/devices.d.ts +0 -1
  218. package/dist/server/modules/devices.js +0 -43
  219. package/dist/server/modules/importer.d.ts +0 -1
  220. package/dist/server/modules/importer.js +0 -13
  221. package/dist/server/modules/themes.d.ts +0 -4
  222. package/dist/server/modules/themes.js +0 -94
  223. package/dist/server/vite.d.ts +0 -11
  224. package/dist/server/vite.js +0 -17
  225. package/dist/styles/variables.css +0 -7
  226. /package/dist/{server/modules → internal/core}/minify.d.ts +0 -0
  227. /package/dist/{server/modules → internal/core}/minify.js +0 -0
  228. /package/dist/{server/modules/x11.js → internal/core/x11-colors.js} +0 -0
@@ -0,0 +1,131 @@
1
+ import { innerWidth, innerHeight } from 'svelte/reactivity/window';
2
+ export function getPositionsTooltip() {
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
+ const activatorRect = activator.getBoundingClientRect();
18
+ const spacing = 6;
19
+ if (location === 'top' || location === 'bottom') {
20
+ if (avoidCollisions) {
21
+ if (location === 'top') {
22
+ if (activatorRect.y - (elementRect.height + spacing) < 0) {
23
+ axis.y = activatorRect.bottom + spacing;
24
+ axis.location = 'bottom';
25
+ }
26
+ else {
27
+ axis.y = activatorRect.top - (elementRect.height + spacing);
28
+ axis.location = 'top';
29
+ }
30
+ }
31
+ else {
32
+ if (activatorRect.y + activatorRect.height + (elementRect.height + spacing) >
33
+ innerHeight.current) {
34
+ axis.y = activatorRect.top - (elementRect.height + spacing);
35
+ axis.location = 'top';
36
+ }
37
+ else {
38
+ axis.y = activatorRect.bottom + spacing;
39
+ axis.location = 'bottom';
40
+ }
41
+ }
42
+ }
43
+ else {
44
+ if (location === 'top') {
45
+ axis.y = activatorRect.top - (elementRect.height + spacing);
46
+ axis.location = 'top';
47
+ }
48
+ else {
49
+ axis.y = activatorRect.bottom + spacing;
50
+ axis.location = 'bottom';
51
+ }
52
+ }
53
+ if (centered &&
54
+ activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
55
+ activatorRect.left + elementRect.width < innerWidth.current) {
56
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
57
+ }
58
+ else if (activatorRect.left + elementRect.width > innerWidth.current) {
59
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
60
+ }
61
+ else {
62
+ axis.x = activatorRect.left;
63
+ }
64
+ }
65
+ else if (location === 'left' || location === 'right') {
66
+ if (avoidCollisions) {
67
+ if (location === 'left' && !(activatorRect.left - elementRect.width < 0)) {
68
+ axis.x = activatorRect.left - (elementRect.width + spacing);
69
+ axis.location = 'left';
70
+ }
71
+ else {
72
+ if (activatorRect.left + activatorRect.width + elementRect.width + spacing >
73
+ innerWidth.current) {
74
+ axis.x = activatorRect.left - (elementRect.width + spacing);
75
+ axis.location = 'left';
76
+ }
77
+ else {
78
+ axis.x = activatorRect.left + activatorRect.width + spacing;
79
+ axis.location = 'right';
80
+ }
81
+ }
82
+ }
83
+ else {
84
+ if (location === 'left') {
85
+ axis.x = activatorRect.left - (elementRect.width + spacing);
86
+ axis.location = 'left';
87
+ }
88
+ else {
89
+ axis.x = activatorRect.left + activatorRect.width + spacing;
90
+ axis.location = 'right';
91
+ }
92
+ }
93
+ if (centered &&
94
+ activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
95
+ activatorRect.top + elementRect.height < innerHeight.current) {
96
+ axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
97
+ }
98
+ else if (activatorRect.y + elementRect.height > innerHeight.current) {
99
+ axis.y = activatorRect.y - elementRect.height + activatorRect.height;
100
+ }
101
+ else {
102
+ axis.y = activatorRect.y;
103
+ }
104
+ }
105
+ else {
106
+ if (centered &&
107
+ activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
108
+ activatorRect.left + elementRect.width < innerWidth.current) {
109
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
110
+ }
111
+ else if (activatorRect.left + elementRect.width > innerWidth.current) {
112
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
113
+ }
114
+ else {
115
+ axis.x = activatorRect.left;
116
+ }
117
+ if (centered &&
118
+ activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
119
+ activatorRect.top + elementRect.height < innerHeight.current) {
120
+ axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
121
+ }
122
+ else if (activatorRect.bottom + elementRect.height > innerHeight.current) {
123
+ axis.y = activatorRect.top - elementRect.height;
124
+ }
125
+ else {
126
+ axis.y = activatorRect.bottom;
127
+ }
128
+ }
129
+ }
130
+ };
131
+ }
@@ -0,0 +1,12 @@
1
+ interface RippleOptions {
2
+ component?: string;
3
+ center?: boolean;
4
+ color?: string;
5
+ duration?: number;
6
+ disabled?: boolean;
7
+ }
8
+ export declare function ripple(el: HTMLElement, options?: RippleOptions): {
9
+ destroy(): void;
10
+ update(newOptions: RippleOptions): void;
11
+ };
12
+ export {};
@@ -0,0 +1,93 @@
1
+ const triggerEvents = ['pointerdown', 'touchstart', 'keydown'];
2
+ const cancelEvents = ['mouseleave', 'dragleave', 'touchmove', 'touchcancel', 'pointerup', 'keyup'];
3
+ export function ripple(el, options = {}) {
4
+ const rippleContainer = document.createElement('div');
5
+ addClasses();
6
+ setOptions(options);
7
+ function addClasses(center) {
8
+ const shouldBeCentered = center || options.center;
9
+ if (!rippleContainer.classList.contains('kit-ripple--effect')) {
10
+ rippleContainer.classList.add('kit-ripple--effect');
11
+ }
12
+ if (!shouldBeCentered && rippleContainer.classList.contains('kit-ripple--center')) {
13
+ rippleContainer.classList.remove('kit-ripple--center');
14
+ }
15
+ if (shouldBeCentered) {
16
+ rippleContainer.classList.add('kit-ripple--center');
17
+ }
18
+ }
19
+ function setOptions(options) {
20
+ if (options.disabled || el.hasAttribute('aria-disabled')) {
21
+ rippleContainer.remove();
22
+ }
23
+ else {
24
+ el.appendChild(rippleContainer);
25
+ }
26
+ if (options.duration && options.duration < 0) {
27
+ options.duration = undefined;
28
+ }
29
+ if (options.component) {
30
+ rippleContainer.style.setProperty('--system-ripple-radius', `var(--${options.component}-shape)`);
31
+ }
32
+ if (options.color) {
33
+ rippleContainer.style.setProperty('--system-ripple-color', options.color);
34
+ }
35
+ if (options.duration) {
36
+ rippleContainer.style.setProperty('--system-animation-ripple-duration', `${options.duration}ms`);
37
+ }
38
+ }
39
+ function createRipple(e, center) {
40
+ if (options.disabled || el.hasAttribute('aria-disabled')) {
41
+ return;
42
+ }
43
+ if (e instanceof KeyboardEvent) {
44
+ if (!['Enter', 'Space'].includes(e.code) || e.repeat) {
45
+ return;
46
+ }
47
+ e.preventDefault();
48
+ const click = new PointerEvent('pointerdown');
49
+ createRipple(click, true);
50
+ return;
51
+ }
52
+ addClasses(center);
53
+ const rect = el.getBoundingClientRect();
54
+ const clientX = window.TouchEvent && e instanceof TouchEvent
55
+ ? e.touches[0].clientX
56
+ : e.clientX;
57
+ const clientY = window.TouchEvent && e instanceof TouchEvent
58
+ ? e.touches[0].clientY
59
+ : e.clientY;
60
+ const x = clientX - rect.left > el.offsetWidth / 2 ? 0 : el.offsetWidth;
61
+ const y = clientY - rect.top > el.offsetHeight / 2 ? 0 : el.offsetHeight;
62
+ const radius = Math.hypot(x - (clientX - rect.left), y - (clientY - rect.top));
63
+ const ripple = document.createElement('div');
64
+ ripple.classList.add('kit-ripple');
65
+ ripple.style.left = `${clientX - rect.left - radius}px`;
66
+ ripple.style.top = `${clientY - rect.top - radius}px`;
67
+ ripple.style.width = ripple.style.height = `${radius * 2}px`;
68
+ rippleContainer.appendChild(ripple);
69
+ function removeRipple() {
70
+ if (ripple === null) {
71
+ return;
72
+ }
73
+ ripple.style.opacity = '0';
74
+ setTimeout(() => {
75
+ ripple.remove();
76
+ }, options.duration || 1000);
77
+ cancelEvents.forEach((event) => el.removeEventListener(event, removeRipple));
78
+ }
79
+ cancelEvents.forEach((event) => el.addEventListener(event, removeRipple, { passive: true }));
80
+ }
81
+ triggerEvents.forEach((event) => el.addEventListener(event, createRipple, { passive: event === 'touchstart' }));
82
+ return {
83
+ destroy() {
84
+ triggerEvents.forEach((event) => {
85
+ el.removeEventListener(event, createRipple);
86
+ });
87
+ },
88
+ update(newOptions) {
89
+ options = newOptions;
90
+ setOptions(newOptions);
91
+ }
92
+ };
93
+ }
@@ -38,4 +38,3 @@ export declare const ansi: {
38
38
  };
39
39
  };
40
40
  export type Ansi = typeof ansi;
41
- export declare const sendConsole: (type: "info" | "error" | "warn" | "success" | undefined, msg: string) => void;
@@ -42,14 +42,3 @@ export const ansi = {
42
42
  inverse,
43
43
  underline
44
44
  };
45
- export const sendConsole = (type = 'info', msg) => {
46
- const name = ansi.color.cyan('lapikit');
47
- if (type === 'error')
48
- console.error(name, ansi.bold.red('[error]'), msg);
49
- else if (type === 'warn')
50
- console.warn(name, ansi.bold.yellow('[warn]'), msg);
51
- else if (type === 'success')
52
- console.warn(name, ansi.bold.green('[success]'), msg);
53
- else
54
- console.log(name, ansi.bold.blue('[info]'), msg);
55
- };
@@ -0,0 +1 @@
1
+ export declare const terminal: (type: "info" | "error" | "warn" | "success" | undefined, msg: string) => void;
@@ -0,0 +1,12 @@
1
+ import { ansi } from './ansi.js';
2
+ export const terminal = (type = 'info', msg) => {
3
+ const name = ansi.color.cyan('lapikit');
4
+ if (type === 'error')
5
+ console.error(name, ansi.bold.red('[error]'), msg);
6
+ else if (type === 'warn')
7
+ console.warn(name, ansi.bold.yellow('[warn]'), msg);
8
+ else if (type === 'success')
9
+ console.warn(name, ansi.bold.green('[success]'), msg);
10
+ else
11
+ console.log(name, ansi.bold.blue('[info]'), msg);
12
+ };
@@ -0,0 +1 @@
1
+ export declare const processImportStyles: () => Promise<string>;
@@ -0,0 +1,16 @@
1
+ import { fileURLToPath } from 'url';
2
+ import { dirname } from 'path';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = dirname(__filename);
7
+ export const processImportStyles = async () => {
8
+ const _reset = fs.readFileSync(path.resolve(__dirname, './../../styles/reset.css'), 'utf-8');
9
+ const _animation = fs.readFileSync(path.resolve(__dirname, './../../styles/animation.css'), 'utf-8');
10
+ const _keyframes = fs.readFileSync(path.resolve(__dirname, './../../styles/keyframes.css'), 'utf-8');
11
+ let styles = ``;
12
+ styles += `${_reset}\n`;
13
+ styles += `${_animation}\n`;
14
+ styles += `${_keyframes}\n`;
15
+ return styles;
16
+ };
@@ -0,0 +1,5 @@
1
+ export declare function componentFormatter({ breakpoints }: {
2
+ breakpoints: {
3
+ [key: string]: number | string;
4
+ };
5
+ }): Promise<void>;
@@ -0,0 +1,60 @@
1
+ import { fileURLToPath } from 'url';
2
+ import { dirname } from 'path';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import { parserCSSBreakpoints } from '../../helpers/parser.js';
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+ export async function componentFormatter({ breakpoints }) {
9
+ // load svelte component files (includes on components folders)
10
+ function loadSvelteFiles(directory) {
11
+ fs.readdirSync(directory).forEach((File) => {
12
+ const absolutePath = path.join(directory, File);
13
+ if (fs.statSync(absolutePath).isDirectory())
14
+ return loadSvelteFiles(absolutePath);
15
+ else if (absolutePath.endsWith('.css') && !absolutePath.includes('/_')) {
16
+ const fileCSS = fs.readFileSync(absolutePath, 'utf8');
17
+ const content = parserCSSBreakpoints(fileCSS);
18
+ let css = `${content.cleaned}\n`;
19
+ for (const property in breakpoints) {
20
+ if (property !== 'base') {
21
+ const name = `.${/^\d/.test(property) ? `\\3${property}` : property}\\:`;
22
+ const value = typeof breakpoints[property] === 'number'
23
+ ? `${breakpoints[property]}px`
24
+ : breakpoints[property];
25
+ if (content.base !== '' || content.minmax !== '' || content.min !== '') {
26
+ css += `\n@media screen and (min-width: ${value}) {\n`;
27
+ if (content.base !== '')
28
+ css += content.base.replaceAll('[breakpoint]', name);
29
+ if (content.minmax !== '')
30
+ css += content.minmax.replaceAll('[breakpoint]', name);
31
+ if (content.min !== '')
32
+ css += content.min.replaceAll('[breakpoint]', name);
33
+ css += `\n}\n`;
34
+ }
35
+ if (content.max !== '' || content.minmax !== '') {
36
+ css += `\n@media screen and (max-width: ${value}) {\n`;
37
+ if (content.max !== '')
38
+ css += content.max.replaceAll('[breakpoint]', `max\\:${name}`);
39
+ if (content.minmax !== '')
40
+ css += content.all.replaceAll('[breakpoint]', `max\\:${name}`);
41
+ css += `\n}\n`;
42
+ }
43
+ }
44
+ else {
45
+ css += `${content.base.replaceAll('[breakpoint]', '.')}\n`;
46
+ }
47
+ }
48
+ const baseName = path.basename(absolutePath, '.css');
49
+ const svelteFilePath = path.join(path.dirname(absolutePath), `${baseName}.svelte`);
50
+ if (fs.existsSync(svelteFilePath)) {
51
+ let svelteContent = fs.readFileSync(svelteFilePath, 'utf8');
52
+ svelteContent = svelteContent.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, '');
53
+ svelteContent += `<style>\n${css}</style>`;
54
+ fs.writeFileSync(svelteFilePath, svelteContent, 'utf8');
55
+ }
56
+ }
57
+ });
58
+ }
59
+ loadSvelteFiles(path.resolve(__dirname, '../../../components'));
60
+ }
@@ -0,0 +1,5 @@
1
+ export declare function devicesFormatter({ devices }: {
2
+ devices: {
3
+ [key: string]: number | string;
4
+ };
5
+ }): Promise<string>;
@@ -0,0 +1,66 @@
1
+ import { parserValues } from '../../helpers/parser.js';
2
+ export async function devicesFormatter({ devices }) {
3
+ let css = ``;
4
+ const sortedDevices = Object.entries(devices).sort(([, a], [, b]) => {
5
+ const valueA = typeof a === 'string' ? parseInt(a) : a;
6
+ const valueB = typeof b === 'string' ? parseInt(b) : b;
7
+ return valueB - valueA;
8
+ });
9
+ sortedDevices.forEach(([deviceName, breakpoint], index) => {
10
+ const value = parserValues(breakpoint);
11
+ if (index === 0) {
12
+ // the largest device
13
+ css += `@media (max-width: ${value}) {\n`;
14
+ css += ` .kit-device--d-${deviceName} {\n`;
15
+ css += ` display: none !important;\n`;
16
+ css += ` }\n`;
17
+ css += `}\n\n`;
18
+ css += `@media (min-width: ${value}) {\n`;
19
+ css += ` .kit-device--h-${deviceName} {\n`;
20
+ css += ` display: none !important;\n`;
21
+ css += ` }\n`;
22
+ css += `}\n\n`;
23
+ }
24
+ else if (index === sortedDevices.length - 1) {
25
+ const prevDevice = sortedDevices[index - 1];
26
+ const prevValue = parserValues(prevDevice[1]);
27
+ // the smallest device
28
+ css += `@media (min-width: ${prevValue}) {\n`;
29
+ css += ` .kit-device--d-${deviceName} {\n`;
30
+ css += ` display: none !important;\n`;
31
+ css += ` }\n`;
32
+ css += `}\n\n`;
33
+ css += `@media (max-width: ${prevValue}) {\n`;
34
+ css += ` .kit-device--h-${deviceName} {\n`;
35
+ css += ` display: none !important;\n`;
36
+ css += ` }\n`;
37
+ css += `}\n\n`;
38
+ css += `@media (min-width: ${value}) {\n`;
39
+ css += ` .kit-device--od-${deviceName} {\n`;
40
+ css += ` display: none !important;\n`;
41
+ css += ` }\n`;
42
+ css += `}\n\n`;
43
+ css += `@media (max-width: ${value}) {\n`;
44
+ css += ` .kit-device--oh-${deviceName} {\n`;
45
+ css += ` display: none !important;\n`;
46
+ css += ` }\n`;
47
+ css += `}\n\n`;
48
+ }
49
+ else {
50
+ //intermediate devices
51
+ const nextDevice = sortedDevices[index - 1];
52
+ const nextValue = parserValues(nextDevice[1]);
53
+ css += `@media (max-width: ${value}) {\n`;
54
+ css += ` .kit-device--d-${deviceName} {\n`;
55
+ css += ` display: none !important;\n`;
56
+ css += ` }\n`;
57
+ css += `}\n\n`;
58
+ css += `@media (min-width: ${nextValue}) {\n`;
59
+ css += ` .kit-device--h-${deviceName} {\n`;
60
+ css += ` display: none !important;\n`;
61
+ css += ` }\n`;
62
+ css += `}\n\n`;
63
+ }
64
+ });
65
+ return css.trim();
66
+ }
@@ -0,0 +1,7 @@
1
+ import type { DevConfiguration } from '../../types/index.js';
2
+ export declare function liliRabbit(config: DevConfiguration): Promise<{
3
+ themes: string;
4
+ typography: string;
5
+ styles: string;
6
+ devices: string;
7
+ }>;
@@ -0,0 +1,35 @@
1
+ import { preset } from '../../config/presets.js';
2
+ import { deepMerge } from '../../helpers/deep-merge.js';
3
+ import { componentFormatter } from './component.js';
4
+ import { devicesFormatter } from './device.js';
5
+ import { stylesFormatter } from './style.js';
6
+ import { themesFormatter } from './theme.js';
7
+ import { typographyFormatter } from './typography.js';
8
+ export async function liliRabbit(config) {
9
+ // states
10
+ const defaultTheme = config?.theme?.defaultTheme || preset.theme.defaultTheme;
11
+ const defaultTypography = config?.typography?.defaultTypography || preset.typography.defaultTypography;
12
+ // formatter
13
+ const themes = await themesFormatter({
14
+ themes: deepMerge(preset.theme.themes, config?.theme?.themes || {}),
15
+ defaultTheme
16
+ });
17
+ const typography = await typographyFormatter({
18
+ typography: deepMerge(preset.typography.fonts, config?.typography?.fonts || {}),
19
+ defaultTypography
20
+ });
21
+ const styles = await stylesFormatter({ styles: deepMerge(preset.styles, config?.styles || {}) });
22
+ const devices = await devicesFormatter({
23
+ devices: deepMerge(preset.breakpoints.devices, config?.breakpoints?.devices || {})
24
+ });
25
+ // components
26
+ await componentFormatter({
27
+ breakpoints: deepMerge(preset.breakpoints.thresholds, config?.breakpoints?.thresholds || {})
28
+ });
29
+ return {
30
+ themes: themes,
31
+ typography: typography,
32
+ styles: styles,
33
+ devices: devices
34
+ };
35
+ }
@@ -0,0 +1,4 @@
1
+ import type { FragStyles } from '../../types/configuration.js';
2
+ export declare function stylesFormatter({ styles }: {
3
+ styles: FragStyles;
4
+ }): Promise<string>;
@@ -0,0 +1,15 @@
1
+ import { parserValues } from '../../helpers/parser.js';
2
+ export async function stylesFormatter({ styles }) {
3
+ let css = `:root {\n`;
4
+ for (const [name, values] of Object.entries(styles)) {
5
+ if (values && typeof values === 'object') {
6
+ for (const [styleName, styleValue] of Object.entries(values || {})) {
7
+ css += ` --system-${name}-${styleName}: ${parserValues(styleValue)};\n`;
8
+ }
9
+ }
10
+ else {
11
+ css += ` --system-${name}: ${parserValues(values)};\n`;
12
+ }
13
+ }
14
+ return (css += '}\n');
15
+ }
@@ -0,0 +1,5 @@
1
+ import type { FragThemes } from '../../types/index.js';
2
+ export declare function themesFormatter({ themes, defaultTheme }: {
3
+ themes: FragThemes;
4
+ defaultTheme: string;
5
+ }): Promise<string>;
@@ -0,0 +1,44 @@
1
+ import { preset } from '../../config/presets.js';
2
+ import { formatColor } from '../../helpers/colors.js';
3
+ import { deepMerge } from '../../helpers/deep-merge.js';
4
+ import { parserValues } from '../../helpers/parser.js';
5
+ export async function themesFormatter({ themes, defaultTheme = 'light' }) {
6
+ let css = '';
7
+ for (const [name, values] of Object.entries(themes)) {
8
+ const ref = values?.dark ? preset.theme.themes.dark : preset.theme.themes.light;
9
+ let cssTheme = defaultTheme === name ? `:root,\n.kit-theme--${name} {\n` : `.kit-theme--${name} {\n`;
10
+ function flattenColors(obj, prefix = '') {
11
+ const result = {};
12
+ for (const [key, value] of Object.entries(obj)) {
13
+ const newPrefix = prefix ? `${prefix}-${key}` : key;
14
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
15
+ Object.assign(result, flattenColors(value, newPrefix));
16
+ }
17
+ else {
18
+ result[newPrefix] = value;
19
+ }
20
+ }
21
+ return result;
22
+ }
23
+ // colors
24
+ cssTheme += ` color-scheme: ${values?.dark ? 'dark' : 'light'};\n`;
25
+ const mergedColors = deepMerge(ref.colors, values?.colors) || {};
26
+ const flatColors = flattenColors(mergedColors);
27
+ for (const [varName, varValue] of Object.entries(flatColors)) {
28
+ cssTheme += ` --kit-${varName}: ${formatColor(varValue)};\n`;
29
+ }
30
+ // variables
31
+ for (const [name, varValue] of Object.entries(deepMerge(ref.variables, values?.variables) || {})) {
32
+ if (varValue && typeof varValue === 'object') {
33
+ for (const [variableName, variableValue] of Object.entries(varValue || {})) {
34
+ cssTheme += ` --kit-${name}-${variableName}: ${formatColor(parserValues(variableValue))};\n`;
35
+ }
36
+ }
37
+ else {
38
+ cssTheme += ` --kit-${name}: ${formatColor(parserValues(varValue))};\n`;
39
+ }
40
+ }
41
+ css += cssTheme + '}\n';
42
+ }
43
+ return css;
44
+ }
@@ -0,0 +1,5 @@
1
+ import type { FragTypography } from '../../types/configuration.js';
2
+ export declare function typographyFormatter({ typography, defaultTypography }: {
3
+ typography: FragTypography;
4
+ defaultTypography: string;
5
+ }): Promise<string>;
@@ -0,0 +1,12 @@
1
+ import { parserValues } from '../../helpers/parser.js';
2
+ export async function typographyFormatter({ typography, defaultTypography = 'default' }) {
3
+ let css = '';
4
+ for (const [name, values] of Object.entries(typography)) {
5
+ let cssTypo = defaultTypography === name ? `:root {\n` : `.${name} {\n`;
6
+ for (const [fontName, fontValue] of Object.entries(values || {})) {
7
+ cssTypo += ` --kit-font-${fontName}: ${parserValues(fontValue).replaceAll('"', '')};\n`;
8
+ }
9
+ css += cssTypo + '}\n';
10
+ }
11
+ return css;
12
+ }
@@ -0,0 +1,75 @@
1
+ export declare const standardColors: {
2
+ red: {
3
+ light: string;
4
+ dark: string;
5
+ };
6
+ orange: {
7
+ light: string;
8
+ dark: string;
9
+ };
10
+ yellow: {
11
+ light: string;
12
+ dark: string;
13
+ };
14
+ green: {
15
+ light: string;
16
+ dark: string;
17
+ };
18
+ mint: {
19
+ light: string;
20
+ dark: string;
21
+ };
22
+ teal: {
23
+ light: string;
24
+ dark: string;
25
+ };
26
+ cyan: {
27
+ light: string;
28
+ dark: string;
29
+ };
30
+ blue: {
31
+ light: string;
32
+ dark: string;
33
+ };
34
+ indigo: {
35
+ light: string;
36
+ dark: string;
37
+ };
38
+ purple: {
39
+ light: string;
40
+ dark: string;
41
+ };
42
+ pink: {
43
+ light: string;
44
+ dark: string;
45
+ };
46
+ brown: {
47
+ light: string;
48
+ dark: string;
49
+ };
50
+ gray: {
51
+ light: string;
52
+ dark: string;
53
+ };
54
+ gray2: {
55
+ light: string;
56
+ dark: string;
57
+ };
58
+ gray3: {
59
+ light: string;
60
+ dark: string;
61
+ };
62
+ gray4: {
63
+ light: string;
64
+ dark: string;
65
+ };
66
+ gray5: {
67
+ light: string;
68
+ dark: string;
69
+ };
70
+ gray6: {
71
+ light: string;
72
+ dark: string;
73
+ };
74
+ };
75
+ export default standardColors;