@hkdigital/lib-sveltekit 0.0.31
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/README.md +104 -0
- package/dist/classes/index.d.ts +2 -0
- package/dist/classes/index.js +2 -0
- package/dist/classes/stores/SubscribersCount.d.ts +39 -0
- package/dist/classes/stores/SubscribersCount.js +107 -0
- package/dist/classes/stores/index.d.ts +1 -0
- package/dist/classes/stores/index.js +1 -0
- package/dist/classes/streams/LogTransformStream.d.ts +4 -0
- package/dist/classes/streams/LogTransformStream.js +19 -0
- package/dist/classes/streams/ServerEventsStore.d.ts +22 -0
- package/dist/classes/streams/ServerEventsStore.js +110 -0
- package/dist/classes/streams/TimeStampSource.d.ts +13 -0
- package/dist/classes/streams/TimeStampSource.js +26 -0
- package/dist/classes/streams/index.d.ts +3 -0
- package/dist/classes/streams/index.js +3 -0
- package/dist/components/area/HkArea.svelte +49 -0
- package/dist/components/area/HkArea.svelte.d.ts +12 -0
- package/dist/components/area/HkGridArea.svelte +77 -0
- package/dist/components/area/HkGridArea.svelte.d.ts +20 -0
- package/dist/components/area/index.d.ts +2 -0
- package/dist/components/area/index.js +2 -0
- package/dist/components/icon/HkIcon.svelte +86 -0
- package/dist/components/icon/HkIcon.svelte.d.ts +10 -0
- package/dist/components/icon/HkTabIcon.svelte +112 -0
- package/dist/components/icon/HkTabIcon.svelte.d.ts +19 -0
- package/dist/components/icon/index.d.ts +3 -0
- package/dist/components/icon/index.js +4 -0
- package/dist/components/icon/typedef.d.ts +13 -0
- package/dist/components/icon/typedef.js +16 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +2 -0
- package/dist/components/layout/HkAppLayout.state.svelte.d.ts +6 -0
- package/dist/components/layout/HkAppLayout.state.svelte.js +25 -0
- package/dist/components/layout/HkAppLayout.svelte +251 -0
- package/dist/components/layout/HkAppLayout.svelte.d.ts +8 -0
- package/dist/components/layout/HkGridLayers.svelte +72 -0
- package/dist/components/layout/HkGridLayers.svelte.d.ts +20 -0
- package/dist/components/layout/index.d.ts +3 -0
- package/dist/components/layout/index.js +9 -0
- package/dist/components/tab-bar/HkTabBar.state.svelte.d.ts +54 -0
- package/dist/components/tab-bar/HkTabBar.state.svelte.js +149 -0
- package/dist/components/tab-bar/HkTabBar.svelte +74 -0
- package/dist/components/tab-bar/HkTabBar.svelte.d.ts +16 -0
- package/dist/components/tab-bar/HkTabBarSelector.state.svelte.d.ts +19 -0
- package/dist/components/tab-bar/HkTabBarSelector.state.svelte.js +93 -0
- package/dist/components/tab-bar/HkTabBarSelector.svelte +49 -0
- package/dist/components/tab-bar/HkTabBarSelector.svelte.d.ts +17 -0
- package/dist/components/tab-bar/index.d.ts +5 -0
- package/dist/components/tab-bar/index.js +17 -0
- package/dist/components/tab-bar/typedef.d.ts +6 -0
- package/dist/components/tab-bar/typedef.js +8 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.js +2 -0
- package/dist/constants/regexp/index.d.ts +3 -0
- package/dist/constants/regexp/index.js +31 -0
- package/dist/constants/regexp/inspiratie.js__ +95 -0
- package/dist/constants/regexp/text.d.ts +47 -0
- package/dist/constants/regexp/text.js +49 -0
- package/dist/constants/regexp/user.d.ts +6 -0
- package/dist/constants/regexp/user.js +33 -0
- package/dist/constants/regexp/web.d.ts +1 -0
- package/dist/constants/regexp/web.js +3 -0
- package/dist/constants/time.d.ts +19 -0
- package/dist/constants/time.js +28 -0
- package/dist/css/test.css +3 -0
- package/dist/css/utilities.postcss +44 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +9 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/logger.d.ts +24 -0
- package/dist/server/logger.js +94 -0
- package/dist/states/index.d.ts +1 -0
- package/dist/states/index.js +1 -0
- package/dist/states/navigation.svelte.d.ts +23 -0
- package/dist/states/navigation.svelte.js +55 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/index.js +1 -0
- package/dist/stores/theme.d.ts +28 -0
- package/dist/stores/theme.js +80 -0
- package/dist/util/expect/index.d.ts +39 -0
- package/dist/util/expect/index.js +145 -0
- package/dist/util/function.js__ +150 -0
- package/dist/util/index.d.ts +2 -0
- package/dist/util/index.js +2 -0
- package/dist/util/singleton/index.d.ts +34 -0
- package/dist/util/singleton/index.js +97 -0
- package/dist/util/svelte/index.d.ts +2 -0
- package/dist/util/svelte/index.js +2 -0
- package/dist/util/svelte/observe/index.d.ts +10 -0
- package/dist/util/svelte/observe/index.js +49 -0
- package/dist/util/svelte/state-context/index.d.ts +17 -0
- package/dist/util/svelte/state-context/index.js +83 -0
- package/dist/util/time.js__ +330 -0
- package/dist/valibot/index.d.ts +3 -0
- package/dist/valibot/index.js +30 -0
- package/dist/valibot/user.d.ts +6 -0
- package/dist/valibot/user.js +23 -0
- package/dist/zod/all.d.ts +6 -0
- package/dist/zod/all.js +33 -0
- package/dist/zod/generic.d.ts +6 -0
- package/dist/zod/generic.js +11 -0
- package/dist/zod/javascript.d.ts +8 -0
- package/dist/zod/javascript.js +32 -0
- package/dist/zod/user.d.ts +9 -0
- package/dist/zod/user.js +16 -0
- package/dist/zod/web.d.ts +21 -0
- package/dist/zod/web.js +57 -0
- package/package.json +144 -0
package/README.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# HKdigital's lib Sveltekit
|
2
|
+
|
3
|
+
Base library that we use to power up our Sveltekit projects
|
4
|
+
|
5
|
+
This is a library for [SvelteKit](https://svelte.dev/) projects.
|
6
|
+
It contains common code and components that we use to create our projects.
|
7
|
+
|
8
|
+
## Status
|
9
|
+
|
10
|
+
**EARLY DEVELOPMENT RELEASE**
|
11
|
+
This package is incomplete and not fully tested.
|
12
|
+
Do not use in production environments yet.
|
13
|
+
|
14
|
+
## A note about tailwindcss
|
15
|
+
|
16
|
+
Components in this package use [tailwindcss](https://tailwindcss.com/).
|
17
|
+
|
18
|
+
To compile tailwind classes inside this package, you must add the package location to your tailwindcss plugin configuration (instructions below).
|
19
|
+
|
20
|
+
## Using the library
|
21
|
+
|
22
|
+
### Install
|
23
|
+
|
24
|
+
The library can be installed as a normal NPM library.
|
25
|
+
|
26
|
+
```bash
|
27
|
+
pnpm add @hkdigital/lib-sveltekit
|
28
|
+
```
|
29
|
+
|
30
|
+
### Update
|
31
|
+
|
32
|
+
```bash
|
33
|
+
ncu "@hkdigital/*" -u && pnpm install
|
34
|
+
```
|
35
|
+
|
36
|
+
### Import JS & Svelte
|
37
|
+
|
38
|
+
All exports are in subfolders.
|
39
|
+
|
40
|
+
For example to import a constant from `constants/regexp/index.js`
|
41
|
+
|
42
|
+
```svelte
|
43
|
+
import { CHAR } from '@hkdigital/lib-sveltekit-test/constants/regexp';
|
44
|
+
```
|
45
|
+
|
46
|
+
### import CSS
|
47
|
+
|
48
|
+
Vite should include postcss-import, but the only solution to get it working for now is to use a relative path to the node_modules folder.
|
49
|
+
|
50
|
+
For example:
|
51
|
+
|
52
|
+
```css
|
53
|
+
/* src/app.css */
|
54
|
+
@import '../node_modules/@hkdigital/lib-sveltekit-test/dist/css/utilities.postcss';
|
55
|
+
```
|
56
|
+
|
57
|
+
### Enable tailwind processing
|
58
|
+
|
59
|
+
Allow the tailwind CSS processor to work on the library inside node_modules
|
60
|
+
|
61
|
+
```js
|
62
|
+
// tailwind.config.js
|
63
|
+
export default {
|
64
|
+
content: [
|
65
|
+
'./node_modules/@hkdigital/**/*.{html,js,svelte,ts}',
|
66
|
+
'./src/**/*.{html,js,svelte,ts}',
|
67
|
+
```
|
68
|
+
|
69
|
+
## Building the showcase app
|
70
|
+
|
71
|
+
To build your library:
|
72
|
+
|
73
|
+
```bash
|
74
|
+
npm run package
|
75
|
+
```
|
76
|
+
|
77
|
+
To create a production version of your showcase app:
|
78
|
+
|
79
|
+
```bash
|
80
|
+
npm run build
|
81
|
+
```
|
82
|
+
|
83
|
+
You can preview the production build with `npm run preview`.
|
84
|
+
|
85
|
+
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
|
86
|
+
|
87
|
+
## Developing
|
88
|
+
|
89
|
+
To develop this library, clone the repository and install the dependencies, then start the development server of the test runners. Checkout the [package.json](./package.json) file for more details.
|
90
|
+
|
91
|
+
Everything inside `src/lib` is part of the library, everything inside `src/routes` is the showcase app of this library.
|
92
|
+
|
93
|
+
## Publishing
|
94
|
+
|
95
|
+
The name of this library is `@hkdigital/lib-sveltekit` and it is published on [NPM](https://npmjs.com). You need NPM credentials to publish in the scope `@hkdigital`.
|
96
|
+
|
97
|
+
### Contribute
|
98
|
+
If your wish to contribute to this library, please contact us [HKdigital](https://hkdigital.nl/contact). Alternatively, the license permits you to fork the library and publish under an alternative name. Change the package name in [package.json](./package.json) to do so.
|
99
|
+
|
100
|
+
```bash
|
101
|
+
npm login
|
102
|
+
npm version patch
|
103
|
+
npm publish --access public
|
104
|
+
```
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/**
|
2
|
+
* Class that can be used to add a `SubscribersCount` store to classes
|
3
|
+
* or other objects
|
4
|
+
*/
|
5
|
+
export default class SubscribersCount {
|
6
|
+
/**
|
7
|
+
* Create a writable store with added 'subscribeCount' functionality
|
8
|
+
*/
|
9
|
+
static writable(...args: any[]): any;
|
10
|
+
/**
|
11
|
+
* Add subscriber count functionality to an existing store by wrapping
|
12
|
+
* the store with a Proxy
|
13
|
+
*
|
14
|
+
* @template T;
|
15
|
+
*
|
16
|
+
* @param {import('svelte/store').Writable<T>} store
|
17
|
+
*/
|
18
|
+
static wrap<T>(store: import("svelte/store").Writable<T>): any;
|
19
|
+
increment(): void;
|
20
|
+
decrement(): void;
|
21
|
+
/**
|
22
|
+
* Subscribe to `SubscribersCount` store
|
23
|
+
*
|
24
|
+
* @param {(value:number)=>void} fn
|
25
|
+
*
|
26
|
+
* @returns {()=>void} unsubscribe
|
27
|
+
*/
|
28
|
+
subscribe(fn: (value: number) => void): () => void;
|
29
|
+
/**
|
30
|
+
* Subscribe to `SubscribersCount` store and receive an update once if the
|
31
|
+
* count is zero.
|
32
|
+
*
|
33
|
+
* @param {(value:number)=>void} fn
|
34
|
+
*
|
35
|
+
* @returns {()=>void} unsubscribe
|
36
|
+
*/
|
37
|
+
onceEmpty(fn: (value: number) => void): () => void;
|
38
|
+
#private;
|
39
|
+
}
|
@@ -0,0 +1,107 @@
|
|
1
|
+
import { writable, get } from 'svelte/store';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Class that can be used to add a `SubscribersCount` store to classes
|
5
|
+
* or other objects
|
6
|
+
*/
|
7
|
+
export default class SubscribersCount {
|
8
|
+
#count;
|
9
|
+
|
10
|
+
constructor() {
|
11
|
+
this.#count = writable(0);
|
12
|
+
}
|
13
|
+
|
14
|
+
increment() {
|
15
|
+
this.#count.update((value) => value + 1);
|
16
|
+
}
|
17
|
+
|
18
|
+
decrement() {
|
19
|
+
this.#count.update((value) => value - 1);
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Subscribe to `SubscribersCount` store
|
24
|
+
*
|
25
|
+
* @param {(value:number)=>void} fn
|
26
|
+
*
|
27
|
+
* @returns {()=>void} unsubscribe
|
28
|
+
*/
|
29
|
+
subscribe(fn) {
|
30
|
+
return this.#count.subscribe(fn);
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Subscribe to `SubscribersCount` store and receive an update once if the
|
35
|
+
* count is zero.
|
36
|
+
*
|
37
|
+
* @param {(value:number)=>void} fn
|
38
|
+
*
|
39
|
+
* @returns {()=>void} unsubscribe
|
40
|
+
*/
|
41
|
+
onceEmpty(fn) {
|
42
|
+
let unsubscribe = this.#count.subscribe((value) => {
|
43
|
+
if (value === 0) {
|
44
|
+
unsubscribe();
|
45
|
+
fn(value);
|
46
|
+
}
|
47
|
+
});
|
48
|
+
|
49
|
+
return unsubscribe;
|
50
|
+
}
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Create a writable store with added 'subscribeCount' functionality
|
54
|
+
*/
|
55
|
+
static writable() {
|
56
|
+
const store = writable(...arguments);
|
57
|
+
|
58
|
+
return SubscribersCount.wrap(store);
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Add subscriber count functionality to an existing store by wrapping
|
63
|
+
* the store with a Proxy
|
64
|
+
*
|
65
|
+
* @template T;
|
66
|
+
*
|
67
|
+
* @param {import('svelte/store').Writable<T>} store
|
68
|
+
*/
|
69
|
+
static wrap(store) {
|
70
|
+
// expect.store( store );
|
71
|
+
|
72
|
+
const counter = new SubscribersCount();
|
73
|
+
|
74
|
+
const handler = {
|
75
|
+
/**
|
76
|
+
* @param {*} target
|
77
|
+
* @param {string} prop
|
78
|
+
*/
|
79
|
+
get(target, prop) {
|
80
|
+
switch (prop) {
|
81
|
+
case 'subscribe': {
|
82
|
+
return /* subscribe */ function () {
|
83
|
+
counter.increment();
|
84
|
+
const unsubscribe = target[prop](...arguments);
|
85
|
+
|
86
|
+
return /* unsubscribe */ () => {
|
87
|
+
counter.decrement();
|
88
|
+
unsubscribe();
|
89
|
+
};
|
90
|
+
};
|
91
|
+
}
|
92
|
+
|
93
|
+
case 'value':
|
94
|
+
return get(store);
|
95
|
+
|
96
|
+
case 'subscribersCount':
|
97
|
+
return counter;
|
98
|
+
}
|
99
|
+
|
100
|
+
return Reflect.get(target, prop);
|
101
|
+
// return target[prop];
|
102
|
+
}
|
103
|
+
};
|
104
|
+
|
105
|
+
return new Proxy(store, handler);
|
106
|
+
}
|
107
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default as SubscribersCount } from "./SubscribersCount.js";
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default as SubscribersCount } from './SubscribersCount.js';
|
@@ -0,0 +1,19 @@
|
|
1
|
+
export default class LogTransformStream extends TransformStream {
|
2
|
+
constructor() {
|
3
|
+
const transformer = {
|
4
|
+
/**
|
5
|
+
* Log the chunk and enqueue the unchanged chunk
|
6
|
+
*
|
7
|
+
* @param {*} chunk
|
8
|
+
* @param {*} controller
|
9
|
+
*/
|
10
|
+
transform: (chunk, controller) => {
|
11
|
+
console.log('log', chunk);
|
12
|
+
controller.enqueue(chunk);
|
13
|
+
}
|
14
|
+
};
|
15
|
+
|
16
|
+
super(transformer);
|
17
|
+
}
|
18
|
+
start() {}
|
19
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
export default class ServerEventsStore {
|
2
|
+
/**
|
3
|
+
* @param {object} _
|
4
|
+
* @param {Zods.AbsOrRelUrl} _.url
|
5
|
+
*/
|
6
|
+
constructor({ url }: {
|
7
|
+
url: Zods.AbsOrRelUrl;
|
8
|
+
});
|
9
|
+
/** @type {SubscribersCount} */
|
10
|
+
subscribersCount: SubscribersCount;
|
11
|
+
/**
|
12
|
+
* Subscribe to Server Send Events
|
13
|
+
*
|
14
|
+
* @param {import("svelte/store").Subscriber<object|null>} fn
|
15
|
+
*
|
16
|
+
* @returns {()=>void} unsubscribe
|
17
|
+
*/
|
18
|
+
subscribe(fn: import("svelte/store").Subscriber<object | null>): () => void;
|
19
|
+
#private;
|
20
|
+
}
|
21
|
+
import SubscribersCount from '../stores/SubscribersCount.js';
|
22
|
+
import * as Zods from '../../zod/all.js';
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import { writable } from 'svelte/store';
|
2
|
+
|
3
|
+
// eslint-disable-next-line no-unused-vars
|
4
|
+
import * as Zods from '../../zod/all.js';
|
5
|
+
|
6
|
+
import SubscribersCount from '../stores/SubscribersCount.js';
|
7
|
+
|
8
|
+
// > Class
|
9
|
+
|
10
|
+
export default class ServerEventsStore {
|
11
|
+
/** @type {Zods.AbsOrRelUrl} */
|
12
|
+
#url;
|
13
|
+
|
14
|
+
/** @type {import("svelte/store").Writable<object|null>} */
|
15
|
+
#store;
|
16
|
+
|
17
|
+
/** @type {boolean} */
|
18
|
+
#starting = false;
|
19
|
+
|
20
|
+
/** @type {ReadableStream<Uint8Array>|null} */
|
21
|
+
#stream = null;
|
22
|
+
|
23
|
+
/** @type {SubscribersCount} */
|
24
|
+
subscribersCount;
|
25
|
+
|
26
|
+
/**
|
27
|
+
* @param {object} _
|
28
|
+
* @param {Zods.AbsOrRelUrl} _.url
|
29
|
+
*/
|
30
|
+
constructor({ url }) {
|
31
|
+
this.#url = Zods.AbsOrRelUrl.parse(url);
|
32
|
+
|
33
|
+
this.#store = writable(null);
|
34
|
+
|
35
|
+
this.subscribersCount = new SubscribersCount();
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Subscribe to Server Send Events
|
40
|
+
*
|
41
|
+
* @param {import("svelte/store").Subscriber<object|null>} fn
|
42
|
+
*
|
43
|
+
* @returns {()=>void} unsubscribe
|
44
|
+
*/
|
45
|
+
subscribe(fn) {
|
46
|
+
this.subscribersCount.increment();
|
47
|
+
|
48
|
+
const unsubscribe = this.#store?.subscribe(fn);
|
49
|
+
|
50
|
+
this.#tryStartStream();
|
51
|
+
|
52
|
+
return () => {
|
53
|
+
this.subscribersCount.decrement();
|
54
|
+
unsubscribe?.();
|
55
|
+
};
|
56
|
+
}
|
57
|
+
|
58
|
+
async #tryStartStream() {
|
59
|
+
if (this.#stream || this.#starting) {
|
60
|
+
return;
|
61
|
+
}
|
62
|
+
|
63
|
+
try {
|
64
|
+
this.#starting = true;
|
65
|
+
|
66
|
+
const aborter = new AbortController();
|
67
|
+
const signal = aborter.signal;
|
68
|
+
|
69
|
+
const response = await fetch(this.#url, { signal });
|
70
|
+
|
71
|
+
const stream = (this.#stream = response.body);
|
72
|
+
|
73
|
+
this.#starting = false;
|
74
|
+
|
75
|
+
const reader =
|
76
|
+
// @ts-ignore
|
77
|
+
stream.pipeThrough(new TextDecoderStream()).getReader();
|
78
|
+
|
79
|
+
// const textDecoder = new TextDecoder('utf-8');
|
80
|
+
|
81
|
+
while (!signal.aborted) {
|
82
|
+
const { value, done } = await reader.read();
|
83
|
+
|
84
|
+
if (undefined === value) {
|
85
|
+
break;
|
86
|
+
}
|
87
|
+
|
88
|
+
const obj = JSON.parse(value);
|
89
|
+
// const obj = JSON.parse(textDecoder.decode(value));
|
90
|
+
|
91
|
+
if (!done) {
|
92
|
+
this.#store.set(obj);
|
93
|
+
}
|
94
|
+
|
95
|
+
// console.log({ ...obj, done });
|
96
|
+
|
97
|
+
if (done) {
|
98
|
+
break;
|
99
|
+
}
|
100
|
+
} // end for
|
101
|
+
} catch (e) {
|
102
|
+
this.#starting = false;
|
103
|
+
this.#stream = null;
|
104
|
+
|
105
|
+
if (e instanceof Error && e.name !== 'AbortError') {
|
106
|
+
throw e;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export default class TimestampSource {
|
2
|
+
/**
|
3
|
+
* Stream start function
|
4
|
+
*
|
5
|
+
* @param {ReadableStreamDefaultController} ctr
|
6
|
+
*/
|
7
|
+
start(ctr: ReadableStreamDefaultController): void;
|
8
|
+
/**
|
9
|
+
* Stop generation of new stream output
|
10
|
+
*/
|
11
|
+
cancel(): void;
|
12
|
+
#private;
|
13
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
export default class TimestampSource {
|
2
|
+
/** @type {number|NodeJS.Timeout|undefined} */
|
3
|
+
#interval;
|
4
|
+
|
5
|
+
constructor() {}
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Stream start function
|
9
|
+
*
|
10
|
+
* @param {ReadableStreamDefaultController} ctr
|
11
|
+
*/
|
12
|
+
start(ctr) {
|
13
|
+
ctr.enqueue(JSON.stringify({ now: Date.now() }));
|
14
|
+
|
15
|
+
this.#interval = setInterval(() => {
|
16
|
+
return ctr.enqueue(JSON.stringify({ now: Date.now() }));
|
17
|
+
}, 1000);
|
18
|
+
}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Stop generation of new stream output
|
22
|
+
*/
|
23
|
+
cancel() {
|
24
|
+
clearInterval(this.#interval);
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<script>
|
2
|
+
/**
|
3
|
+
* Area component
|
4
|
+
* An area is actually a DIV that can be styled and can contain content
|
5
|
+
*
|
6
|
+
* Following component guidelines from Skeleton
|
7
|
+
* @see https://next.skeleton.dev/docs/resources/contribute/components
|
8
|
+
*/
|
9
|
+
|
10
|
+
/**
|
11
|
+
* @type {{
|
12
|
+
* base?: string,
|
13
|
+
* bg?: string,
|
14
|
+
* padding?: string,
|
15
|
+
* margin?: string,
|
16
|
+
* classes?: string,
|
17
|
+
* style?: string,
|
18
|
+
* children: import('svelte').Snippet
|
19
|
+
* } & { [attr: string]: * }}
|
20
|
+
*/
|
21
|
+
let {
|
22
|
+
// Style
|
23
|
+
base,
|
24
|
+
bg,
|
25
|
+
padding,
|
26
|
+
margin,
|
27
|
+
classes,
|
28
|
+
style,
|
29
|
+
|
30
|
+
// Snippets
|
31
|
+
children,
|
32
|
+
|
33
|
+
// DOM Element
|
34
|
+
domElem = $bindable(),
|
35
|
+
|
36
|
+
// Attributes
|
37
|
+
...attrs
|
38
|
+
} = $props();
|
39
|
+
</script>
|
40
|
+
|
41
|
+
<div
|
42
|
+
data-hk-area
|
43
|
+
class="{base} {bg} {padding} {margin} {classes}"
|
44
|
+
bind:this={domElem}
|
45
|
+
{style}
|
46
|
+
{...attrs}
|
47
|
+
>
|
48
|
+
{@render children()}
|
49
|
+
</div>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export default HkArea;
|
2
|
+
declare const HkArea: import("svelte").Component<{
|
3
|
+
base?: string;
|
4
|
+
bg?: string;
|
5
|
+
padding?: string;
|
6
|
+
margin?: string;
|
7
|
+
classes?: string;
|
8
|
+
style?: string;
|
9
|
+
children: import("svelte").Snippet;
|
10
|
+
} & {
|
11
|
+
[attr: string]: any;
|
12
|
+
}, {}, "domElem">;
|
@@ -0,0 +1,77 @@
|
|
1
|
+
<script>
|
2
|
+
/**
|
3
|
+
* Grid area component
|
4
|
+
* This component contains a DIV that has display: grid set. It is
|
5
|
+
* wrapped in a box which makes it possible to add box attributes
|
6
|
+
* such as margins.
|
7
|
+
*
|
8
|
+
* Following component guidelines from Skeleton
|
9
|
+
* @see https://next.skeleton.dev/docs/resources/contribute/components
|
10
|
+
*/
|
11
|
+
|
12
|
+
import HkArea from './HkArea.svelte';
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @type {{
|
16
|
+
* base?: string,
|
17
|
+
* bg?: string,
|
18
|
+
* padding?: string,
|
19
|
+
* margin?: string,
|
20
|
+
* classes?: string,
|
21
|
+
* style?: string,
|
22
|
+
* boxBase?: string,
|
23
|
+
* boxBg?: string,
|
24
|
+
* boxPadding?: string,
|
25
|
+
* boxMargin?: string,
|
26
|
+
* boxClasses?: string,
|
27
|
+
* boxAttrs?: { [attr: string]: * },
|
28
|
+
* children: import('svelte').Snippet
|
29
|
+
* } & { [attr: string]: * }}
|
30
|
+
*/
|
31
|
+
let {
|
32
|
+
// Style
|
33
|
+
base,
|
34
|
+
bg,
|
35
|
+
padding,
|
36
|
+
margin,
|
37
|
+
classes,
|
38
|
+
style,
|
39
|
+
boxBase,
|
40
|
+
boxBg,
|
41
|
+
boxPadding,
|
42
|
+
boxMargin,
|
43
|
+
boxClasses,
|
44
|
+
boxAttrs,
|
45
|
+
|
46
|
+
// Snippets
|
47
|
+
children,
|
48
|
+
|
49
|
+
// DOM Element's
|
50
|
+
domElem = $bindable(),
|
51
|
+
boxDomElem = $bindable(),
|
52
|
+
|
53
|
+
// Attributes
|
54
|
+
...attrs
|
55
|
+
} = $props();
|
56
|
+
</script>
|
57
|
+
|
58
|
+
<div
|
59
|
+
data-hk-grid-area-box
|
60
|
+
class="{boxBase} {boxBg} {boxPadding} {boxMargin} {boxClasses}"
|
61
|
+
{...boxAttrs}
|
62
|
+
bind:this={boxDomElem}
|
63
|
+
>
|
64
|
+
<HkArea
|
65
|
+
data-hk-grid-area
|
66
|
+
base="grid {base}"
|
67
|
+
bind:domElem
|
68
|
+
{bg}
|
69
|
+
{padding}
|
70
|
+
{margin}
|
71
|
+
{classes}
|
72
|
+
{style}
|
73
|
+
{...attrs}
|
74
|
+
>
|
75
|
+
{@render children()}
|
76
|
+
</HkArea>
|
77
|
+
</div>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
export default HkGridArea;
|
2
|
+
declare const HkGridArea: import("svelte").Component<{
|
3
|
+
base?: string;
|
4
|
+
bg?: string;
|
5
|
+
padding?: string;
|
6
|
+
margin?: string;
|
7
|
+
classes?: string;
|
8
|
+
style?: string;
|
9
|
+
boxBase?: string;
|
10
|
+
boxBg?: string;
|
11
|
+
boxPadding?: string;
|
12
|
+
boxMargin?: string;
|
13
|
+
boxClasses?: string;
|
14
|
+
boxAttrs?: {
|
15
|
+
[attr: string]: any;
|
16
|
+
};
|
17
|
+
children: import("svelte").Snippet;
|
18
|
+
} & {
|
19
|
+
[attr: string]: any;
|
20
|
+
}, {}, "domElem" | "boxDomElem">;
|