y200subcontrols 0.0.29 → 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 CHANGED
@@ -1,6 +1,6 @@
1
- UI Library using sveltekit and tailwindcss
2
-
3
- In your tailwind.config.js file add the following to content
4
-
5
- './node_modules/y200subcontrols/**/*.{html,js,svelte,ts}'
6
-
1
+ UI Library using sveltekit and tailwindcss
2
+
3
+ In your tailwind.config.js file add the following to content
4
+
5
+ './node_modules/y200subcontrols/**/*.{html,js,svelte,ts}'
6
+
@@ -0,0 +1,105 @@
1
+ <script>import Button from "./Button.svelte";
2
+ import ModalDialog from "./ModalDialog.svelte";
3
+ export let message = "Message goes here";
4
+ export let style = "warning";
5
+ let dialog;
6
+ export async function showDialog() {
7
+ const okButton = document.getElementById("okButtonDialog");
8
+ const cancelButton = document.getElementById("cancelButtonDialog");
9
+ const p = new Promise((resolve) => {
10
+ function closeDialog(result) {
11
+ dialog.dismissDialog();
12
+ resolve(result);
13
+ }
14
+ function acceptDialog() {
15
+ closeDialog("accept");
16
+ }
17
+ function cancelDialog() {
18
+ closeDialog("cancel");
19
+ }
20
+ dialog.openDialog();
21
+ okButton?.addEventListener("click", acceptDialog);
22
+ cancelButton?.addEventListener("click", cancelDialog);
23
+ });
24
+ return p;
25
+ }
26
+ </script>
27
+
28
+ <ModalDialog bind:this={dialog} showCloseButton={false} allowSubmit={false}>
29
+ <slot slot="title">Title goes here</slot>
30
+ <div
31
+ class="flex
32
+ {style === 'warning' ? 'text-amber-500' : ''}
33
+ {style === 'info' ? 'text-blue-500' : ''}
34
+ {style === 'danger' ? 'text-red-500' : ''}
35
+ {style === 'success' ? 'text-green-500' : ''}
36
+ "
37
+ >
38
+ <div class="mx-auto">
39
+ {#if style === 'warning' || style === 'danger'}
40
+ <svg
41
+ class="w-10 h-10"
42
+ aria-hidden="true"
43
+ xmlns="http://www.w3.org/2000/svg"
44
+ width="24"
45
+ height="24"
46
+ fill="currentColor"
47
+ viewBox="0 0 24 24"
48
+ >
49
+ <path
50
+ fill-rule="evenodd"
51
+ d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Zm11-4a1 1 0 1 0-2 0v5a1 1 0 1 0 2 0V8Zm-1 7a1 1 0 1 0 0 2h.01a1 1 0 1 0 0-2H12Z"
52
+ clip-rule="evenodd"
53
+ />
54
+ </svg>
55
+ {/if}
56
+ {#if style === 'info'}
57
+ <svg
58
+ class="w-10 h-10"
59
+ aria-hidden="true"
60
+ xmlns="http://www.w3.org/2000/svg"
61
+ width="24"
62
+ height="24"
63
+ fill="currentColor"
64
+ viewBox="0 0 24 24"
65
+ >
66
+ <path
67
+ fill-rule="evenodd"
68
+ d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Zm9.408-5.5a1 1 0 1 0 0 2h.01a1 1 0 1 0 0-2h-.01ZM10 10a1 1 0 1 0 0 2h1v3h-1a1 1 0 1 0 0 2h4a1 1 0 1 0 0-2h-1v-4a1 1 0 0 0-1-1h-2Z"
69
+ clip-rule="evenodd"
70
+ />
71
+ </svg>
72
+ {/if}
73
+ {#if style === 'success'}
74
+ <svg
75
+ class="w-10 h-10"
76
+ aria-hidden="true"
77
+ xmlns="http://www.w3.org/2000/svg"
78
+ width="24"
79
+ height="24"
80
+ fill="currentColor"
81
+ viewBox="0 0 24 24"
82
+ >
83
+ <path
84
+ fill-rule="evenodd"
85
+ d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Zm13.707-1.293a1 1 0 0 0-1.414-1.414L11 12.586l-1.793-1.793a1 1 0 0 0-1.414 1.414l2.5 2.5a1 1 0 0 0 1.414 0l4-4Z"
86
+ clip-rule="evenodd"
87
+ />
88
+ </svg>
89
+ {/if}
90
+ </div>
91
+ </div>
92
+ <slot>
93
+ <div class="text-center">
94
+ {@html message}
95
+ </div>
96
+ </slot>
97
+ <div class="grid grid-cols-2 gap-2" slot="buttons">
98
+ <Button type="button" id="okButtonDialog">
99
+ <span>Ok</span>
100
+ </Button>
101
+ <Button type="button" buttonStyle="dark" id="cancelButtonDialog">
102
+ <span>Cancel</span>
103
+ </Button>
104
+ </div>
105
+ </ModalDialog>
@@ -0,0 +1,23 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ message?: string | undefined;
5
+ style?: "warning" | "info" | "danger" | "success";
6
+ showDialog?: () => Promise<"cancel" | "accept">;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {
12
+ default: {};
13
+ };
14
+ exports?: {} | undefined;
15
+ bindings?: string | undefined;
16
+ };
17
+ export type ConfirmModalDialogProps = typeof __propDef.props;
18
+ export type ConfirmModalDialogEvents = typeof __propDef.events;
19
+ export type ConfirmModalDialogSlots = typeof __propDef.slots;
20
+ export default class ConfirmModalDialog extends SvelteComponent<ConfirmModalDialogProps, ConfirmModalDialogEvents, ConfirmModalDialogSlots> {
21
+ get showDialog(): () => Promise<"cancel" | "accept">;
22
+ }
23
+ export {};
@@ -9,11 +9,12 @@ export let extendedCss = "";
9
9
  export let isCard = true;
10
10
  export let id = void 0;
11
11
  export let buttonSize = "md";
12
+ export let method = "post";
12
13
  let dispatch = createEventDispatcher();
13
14
  function handleSubmit(event) {
14
15
  event.preventDefault();
15
16
  if (!allowSubmit) return;
16
- const inputs = document.querySelectorAll('[data-requires-validation="true"]');
17
+ const inputs = form.querySelectorAll('[data-requires-validation="true"]');
17
18
  for (const input of inputs) {
18
19
  let i = input;
19
20
  i.dataset.validated = "true";
@@ -31,7 +32,16 @@ function handleSubmit(event) {
31
32
  <slot slot="title" name="title" />
32
33
  <!-- svelte-ignore a11y-click-events-have-key-events -->
33
34
  <!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
34
- <form {id} on:click on:mousedown on:mouseup bind:this={form} novalidate on:submit={handleSubmit}>
35
+ <form
36
+ {id}
37
+ on:click
38
+ on:mousedown
39
+ on:mouseup
40
+ bind:this={form}
41
+ novalidate
42
+ on:submit={handleSubmit}
43
+ {method}
44
+ >
35
45
  <div class="my-4">
36
46
  <slot />
37
47
  </div>
@@ -9,6 +9,7 @@ declare const __propDef: {
9
9
  isCard?: boolean;
10
10
  id?: string | undefined;
11
11
  buttonSize?: Size;
12
+ method?: "get" | "post" | "dialog";
12
13
  };
13
14
  events: {
14
15
  click: MouseEvent;
@@ -0,0 +1,95 @@
1
+ <script>import { Button } from "../index.js";
2
+ import { createEventDispatcher } from "svelte";
3
+ import Form from "./Form.svelte";
4
+ const dispatch = createEventDispatcher();
5
+ export let allowSubmit = true;
6
+ export let busy = false;
7
+ export let dialogSize = "md";
8
+ export let showCloseButton = true;
9
+ let dialog;
10
+ export function openDialog() {
11
+ setTimeout(() => {
12
+ dialog.classList.add("scale-0");
13
+ dialog.showModal();
14
+ dialog.classList.remove("scale-0");
15
+ }, 50);
16
+ }
17
+ export function dismissDialog() {
18
+ if (!dialog) return;
19
+ dialog.classList.add("scale-0");
20
+ setTimeout(() => {
21
+ dialog.close();
22
+ }, 501);
23
+ }
24
+ function fireCancelDialog() {
25
+ dispatch("cancel");
26
+ }
27
+ function dialogClicked(event) {
28
+ if (event.target === dialog) {
29
+ fireCancelDialog();
30
+ }
31
+ }
32
+ </script>
33
+
34
+ <!-- svelte-ignore a11y-click-events-have-key-events -->
35
+ <!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
36
+ <dialog
37
+ bind:this={dialog}
38
+ class="p-2 w-full md:w-3/4 lg:w-2/3 xl:w-1/2
39
+ bg-transparent
40
+
41
+ backdrop:bg-black/20 dark:backdrop:bg-white/20
42
+
43
+ transition-all ease-in-out duration-500
44
+ "
45
+ on:click={dialogClicked}
46
+ >
47
+ <Form on:submit isCard={true} {allowSubmit}>
48
+ <div class="flex" slot="title">
49
+ <slot name="title">Title goes here</slot>
50
+ {#if showCloseButton}
51
+ <div class="ml-auto my-auto">
52
+ <button
53
+ type="button"
54
+ data-close-dialog="true"
55
+ on:click={fireCancelDialog}
56
+ class="text-slate-400 dark:text-slate-200
57
+ hover:text-red-500 px-2 inset-y-0 transition-colors ease-in-out"
58
+ >
59
+ <svg
60
+ class="w-5 h-5"
61
+ aria-hidden="true"
62
+ xmlns="http://www.w3.org/2000/svg"
63
+ width="24"
64
+ height="24"
65
+ fill="none"
66
+ viewBox="0 0 24 24"
67
+ >
68
+ <path
69
+ stroke="currentColor"
70
+ stroke-linecap="round"
71
+ stroke-linejoin="round"
72
+ stroke-width="2"
73
+ d="M6 18 17.94 6M18 18 6.06 6"
74
+ />
75
+ </svg>
76
+ </button>
77
+ </div>
78
+ {/if}
79
+ </div>
80
+ <slot />
81
+
82
+ <div slot="buttons" class="grid {allowSubmit ? 'grid-cols-2' : 'grid-cols-1'} gap-2 my-2" >
83
+ <slot name="buttons" >
84
+ {#if allowSubmit}
85
+ <Button type="submit" isLoading={busy}>
86
+ <span>Ok</span>
87
+ </Button>
88
+ {/if}
89
+ <Button type="button" buttonStyle="dark" disabled={busy} on:click={fireCancelDialog}>
90
+ <span>Cancel</span>
91
+ </Button>
92
+ </slot>
93
+ </div>
94
+ </Form>
95
+ </dialog>
@@ -0,0 +1,32 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ allowSubmit?: boolean;
5
+ busy?: boolean;
6
+ dialogSize?: "sm" | "md" | "lg";
7
+ showCloseButton?: boolean;
8
+ openDialog?: () => void;
9
+ dismissDialog?: () => void;
10
+ };
11
+ events: {
12
+ submit: CustomEvent<any>;
13
+ cancel: CustomEvent<any>;
14
+ } & {
15
+ [evt: string]: CustomEvent<any>;
16
+ };
17
+ slots: {
18
+ title: {};
19
+ default: {};
20
+ buttons: {};
21
+ };
22
+ exports?: {} | undefined;
23
+ bindings?: string | undefined;
24
+ };
25
+ export type ModalDialogProps = typeof __propDef.props;
26
+ export type ModalDialogEvents = typeof __propDef.events;
27
+ export type ModalDialogSlots = typeof __propDef.slots;
28
+ export default class ModalDialog extends SvelteComponent<ModalDialogProps, ModalDialogEvents, ModalDialogSlots> {
29
+ get openDialog(): () => void;
30
+ get dismissDialog(): () => void;
31
+ }
32
+ export {};
package/dist/index.d.ts CHANGED
@@ -9,4 +9,5 @@ import LabeledPasswordInput from "./components/LabeledPasswordInput.svelte";
9
9
  import Alert from "./components/Alert.svelte";
10
10
  import HyperLink from "./components/HyperLink.svelte";
11
11
  import LabeledSelect from "./components/LabeledSelect.svelte";
12
- export { Button, LoadingIndicator, Card, CardHeader, Form, ToggleButton, LabeledFormInput, LabeledPasswordInput, Alert, HyperLink, LabeledSelect };
12
+ import ModalDialog from "./components/ModalDialog.svelte";
13
+ export { Button, LoadingIndicator, Card, CardHeader, Form, ToggleButton, LabeledFormInput, LabeledPasswordInput, Alert, HyperLink, LabeledSelect, ModalDialog };
package/dist/index.js CHANGED
@@ -10,4 +10,5 @@ import LabeledPasswordInput from "./components/LabeledPasswordInput.svelte";
10
10
  import Alert from "./components/Alert.svelte";
11
11
  import HyperLink from "./components/HyperLink.svelte";
12
12
  import LabeledSelect from "./components/LabeledSelect.svelte";
13
- export { Button, LoadingIndicator, Card, CardHeader, Form, ToggleButton, LabeledFormInput, LabeledPasswordInput, Alert, HyperLink, LabeledSelect };
13
+ import ModalDialog from "./components/ModalDialog.svelte";
14
+ export { Button, LoadingIndicator, Card, CardHeader, Form, ToggleButton, LabeledFormInput, LabeledPasswordInput, Alert, HyperLink, LabeledSelect, ModalDialog };
package/package.json CHANGED
@@ -1,56 +1,59 @@
1
- {
2
- "name": "y200subcontrols",
3
- "version": "0.0.29",
4
- "scripts": {
5
- "dev": "vite dev",
6
- "build": "vite build && npm run package",
7
- "preview": "vite preview",
8
- "package": "svelte-kit sync && svelte-package && publint",
9
- "prepublishOnly": "npm run package",
10
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
11
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
12
- "lint": "prettier --check . && eslint .",
13
- "format": "prettier --write ."
14
- },
15
- "exports": {
16
- ".": {
17
- "types": "./dist/index.d.ts",
18
- "svelte": "./dist/index.js"
19
- }
20
- },
21
- "files": [
22
- "dist",
23
- "!dist/**/*.test.*",
24
- "!dist/**/*.spec.*"
25
- ],
26
- "peerDependencies": {
27
- "svelte": "^4.0.0"
28
- },
29
- "devDependencies": {
30
- "@sveltejs/adapter-auto": "^3.0.0",
31
- "@sveltejs/kit": "^2.0.0",
32
- "@sveltejs/package": "^2.3.2",
33
- "@sveltejs/vite-plugin-svelte": "^3.0.0",
34
- "@types/eslint": "^8.56.7",
35
- "autoprefixer": "^10.4.19",
36
- "eslint": "^9.0.0",
37
- "eslint-config-prettier": "^9.1.0",
38
- "eslint-plugin-svelte": "^2.36.0",
39
- "globals": "^15.0.0",
40
- "postcss": "^8.4.38",
41
- "prettier": "^3.1.1",
42
- "prettier-plugin-svelte": "^3.1.2",
43
- "publint": "^0.1.9",
44
- "svelte": "^4.2.7",
45
- "svelte-check": "^3.6.0",
46
- "tailwindcss": "^3.4.4",
47
- "tslib": "^2.4.1",
48
- "typescript": "^5.0.0",
49
- "typescript-eslint": "^8.0.0-alpha.20",
50
- "vite": "^5.0.11"
51
- },
52
- "svelte": "./dist/index.js",
53
- "types": "./dist/index.d.ts",
54
- "type": "module",
55
- "license": "MIT"
56
- }
1
+ {
2
+ "name": "y200subcontrols",
3
+ "version": "0.0.31",
4
+ "scripts": {
5
+ "dev": "vite dev",
6
+ "build": "vite build && npm run package",
7
+ "preview": "vite preview",
8
+ "package": "svelte-kit sync && svelte-package && publint",
9
+ "prepublishOnly": "npm run package",
10
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
11
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
12
+ "lint": "prettier --check . && eslint .",
13
+ "format": "prettier --write ."
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "svelte": "./dist/index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "!dist/**/*.test.*",
24
+ "!dist/**/*.spec.*"
25
+ ],
26
+ "peerDependencies": {
27
+ "svelte": "^4.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@sveltejs/adapter-auto": "^3.2.2",
31
+ "@sveltejs/kit": "^2.0.0",
32
+ "@sveltejs/package": "^2.3.2",
33
+ "@sveltejs/vite-plugin-svelte": "^3.0.0",
34
+ "@types/eslint": "^8.56.7",
35
+ "autoprefixer": "^10.4.19",
36
+ "eslint": "^9.0.0",
37
+ "eslint-config-prettier": "^9.1.0",
38
+ "eslint-plugin-svelte": "^2.36.0",
39
+ "globals": "^15.0.0",
40
+ "postcss": "^8.4.38",
41
+ "prettier": "^3.1.1",
42
+ "prettier-plugin-svelte": "^3.1.2",
43
+ "publint": "^0.1.9",
44
+ "svelte": "^4.2.7",
45
+ "svelte-check": "^3.6.0",
46
+ "tailwindcss": "^3.4.4",
47
+ "tslib": "^2.4.1",
48
+ "typescript": "^5.0.0",
49
+ "typescript-eslint": "^8.0.0-alpha.20",
50
+ "vite": "^5.0.11"
51
+ },
52
+ "svelte": "./dist/index.js",
53
+ "types": "./dist/index.d.ts",
54
+ "type": "module",
55
+ "license": "MIT",
56
+ "dependencies": {
57
+ "bootstrap-icons": "^1.11.3"
58
+ }
59
+ }