y200subcontrols 0.0.29 → 0.0.30

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
+
@@ -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,92 @@
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
+ let dialog;
9
+ export function openDialog() {
10
+ setTimeout(() => {
11
+ dialog.classList.add("scale-0");
12
+ dialog.showModal();
13
+ dialog.classList.remove("scale-0");
14
+ }, 50);
15
+ }
16
+ export function dismissDialog() {
17
+ if (!dialog) return;
18
+ dialog.classList.add("scale-0");
19
+ setTimeout(() => {
20
+ dialog.close();
21
+ }, 501);
22
+ }
23
+ function fireCancelDialog() {
24
+ dispatch("cancel");
25
+ }
26
+ function dialogClicked(event) {
27
+ if (event.target === dialog) {
28
+ fireCancelDialog();
29
+ }
30
+ }
31
+ </script>
32
+
33
+ <!-- svelte-ignore a11y-click-events-have-key-events -->
34
+ <!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
35
+ <dialog
36
+ bind:this={dialog}
37
+ class="p-2 w-full md:w-3/4 lg:w-2/3 xl:w-1/2
38
+ bg-transparent
39
+
40
+ backdrop:bg-black/20 dark:backdrop:bg-white/20
41
+
42
+ transition-all ease-in-out duration-500
43
+ "
44
+ on:click={dialogClicked}
45
+ >
46
+ <Form on:submit isCard={true} {allowSubmit}>
47
+ <div class="flex" slot="title">
48
+ <slot name="title">Title goes here</slot>
49
+ <div class="ml-auto my-auto">
50
+ <button
51
+ type="button"
52
+ data-close-dialog="true"
53
+ on:click={fireCancelDialog}
54
+ class="text-slate-400 dark:text-slate-200
55
+ hover:text-red-500 px-2 inset-y-0 transition-colors ease-in-out"
56
+ >
57
+ <svg
58
+ class="w-5 h-5"
59
+ aria-hidden="true"
60
+ xmlns="http://www.w3.org/2000/svg"
61
+ width="24"
62
+ height="24"
63
+ fill="none"
64
+ viewBox="0 0 24 24"
65
+ >
66
+ <path
67
+ stroke="currentColor"
68
+ stroke-linecap="round"
69
+ stroke-linejoin="round"
70
+ stroke-width="2"
71
+ d="M6 18 17.94 6M18 18 6.06 6"
72
+ />
73
+ </svg>
74
+ </button>
75
+ </div>
76
+ </div>
77
+ <slot />
78
+
79
+ <div slot="buttons" class="grid {allowSubmit ? 'grid-cols-2' : 'grid-cols-1'} gap-2 my-2">
80
+ <slot name="buttons">
81
+ {#if allowSubmit}
82
+ <Button type="submit" isLoading={busy}>
83
+ <span>Ok</span>
84
+ </Button>
85
+ {/if}
86
+ <Button type="button" buttonStyle="dark" disabled={busy} on:click={fireCancelDialog}
87
+ >Cancel</Button
88
+ >
89
+ </slot>
90
+ </div>
91
+ </Form>
92
+ </dialog>
@@ -0,0 +1,31 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ allowSubmit?: boolean;
5
+ busy?: boolean;
6
+ dialogSize?: "sm" | "md" | "lg";
7
+ openDialog?: () => void;
8
+ dismissDialog?: () => void;
9
+ };
10
+ events: {
11
+ submit: CustomEvent<any>;
12
+ cancel: CustomEvent<any>;
13
+ } & {
14
+ [evt: string]: CustomEvent<any>;
15
+ };
16
+ slots: {
17
+ title: {};
18
+ default: {};
19
+ buttons: {};
20
+ };
21
+ exports?: {} | undefined;
22
+ bindings?: string | undefined;
23
+ };
24
+ export type ModalDialogProps = typeof __propDef.props;
25
+ export type ModalDialogEvents = typeof __propDef.events;
26
+ export type ModalDialogSlots = typeof __propDef.slots;
27
+ export default class ModalDialog extends SvelteComponent<ModalDialogProps, ModalDialogEvents, ModalDialogSlots> {
28
+ get openDialog(): () => void;
29
+ get dismissDialog(): () => void;
30
+ }
31
+ 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.30",
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
+ }