sveltacular 0.0.1

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 (152) hide show
  1. package/README.md +11 -0
  2. package/dist/forms/button/button.stories.svelte +33 -0
  3. package/dist/forms/button/button.stories.svelte.d.ts +14 -0
  4. package/dist/forms/button/button.svelte +129 -0
  5. package/dist/forms/button/button.svelte.d.ts +26 -0
  6. package/dist/forms/check-box/check-box.stories.svelte +13 -0
  7. package/dist/forms/check-box/check-box.stories.svelte.d.ts +14 -0
  8. package/dist/forms/check-box/check-box.svelte +26 -0
  9. package/dist/forms/check-box/check-box.svelte.d.ts +21 -0
  10. package/dist/forms/check-box/check-input.svelte +32 -0
  11. package/dist/forms/check-box/check-input.svelte.d.ts +20 -0
  12. package/dist/forms/date-box/date-box.stories.svelte +17 -0
  13. package/dist/forms/date-box/date-box.stories.svelte.d.ts +14 -0
  14. package/dist/forms/date-box/date-box.svelte +68 -0
  15. package/dist/forms/date-box/date-box.svelte.d.ts +23 -0
  16. package/dist/forms/dropdown-box/dropdown-box.stories.svelte +15 -0
  17. package/dist/forms/dropdown-box/dropdown-box.stories.svelte.d.ts +14 -0
  18. package/dist/forms/dropdown-box/dropdown-box.svelte +36 -0
  19. package/dist/forms/dropdown-box/dropdown-box.svelte.d.ts +25 -0
  20. package/dist/forms/form-field.svelte +22 -0
  21. package/dist/forms/form-field.svelte.d.ts +19 -0
  22. package/dist/forms/form-label.svelte +14 -0
  23. package/dist/forms/form-label.svelte.d.ts +19 -0
  24. package/dist/forms/form.svelte +12 -0
  25. package/dist/forms/form.svelte.d.ts +20 -0
  26. package/dist/forms/number-box/number-box.stories.svelte +21 -0
  27. package/dist/forms/number-box/number-box.stories.svelte.d.ts +14 -0
  28. package/dist/forms/number-box/number-box.svelte +83 -0
  29. package/dist/forms/number-box/number-box.svelte.d.ts +28 -0
  30. package/dist/forms/switch/switch.stories.svelte +13 -0
  31. package/dist/forms/switch/switch.stories.svelte.d.ts +14 -0
  32. package/dist/forms/switch/switch.svelte +73 -0
  33. package/dist/forms/switch/switch.svelte.d.ts +20 -0
  34. package/dist/forms/text-area/text-area.stories.svelte +13 -0
  35. package/dist/forms/text-area/text-area.stories.svelte.d.ts +14 -0
  36. package/dist/forms/text-area/text-area.svelte +34 -0
  37. package/dist/forms/text-area/text-area.svelte.d.ts +25 -0
  38. package/dist/forms/text-box/text-box.stories.svelte +17 -0
  39. package/dist/forms/text-box/text-box.stories.svelte.d.ts +14 -0
  40. package/dist/forms/text-box/text-box.svelte +83 -0
  41. package/dist/forms/text-box/text-box.svelte.d.ts +30 -0
  42. package/dist/forms/upload-dropzone/upload-dropzone.stories.svelte +11 -0
  43. package/dist/forms/upload-dropzone/upload-dropzone.stories.svelte.d.ts +14 -0
  44. package/dist/forms/upload-dropzone/upload-dropzone.svelte +82 -0
  45. package/dist/forms/upload-dropzone/upload-dropzone.svelte.d.ts +18 -0
  46. package/dist/generic/card/card.stories.svelte +9 -0
  47. package/dist/generic/card/card.stories.svelte.d.ts +14 -0
  48. package/dist/generic/card/card.svelte +39 -0
  49. package/dist/generic/card/card.svelte.d.ts +19 -0
  50. package/dist/generic/divider/divider.stories.svelte +9 -0
  51. package/dist/generic/divider/divider.stories.svelte.d.ts +14 -0
  52. package/dist/generic/divider/divider.svelte +10 -0
  53. package/dist/generic/divider/divider.svelte.d.ts +23 -0
  54. package/dist/generic/link/link.stories.svelte +21 -0
  55. package/dist/generic/link/link.stories.svelte.d.ts +14 -0
  56. package/dist/generic/link/link.svelte +41 -0
  57. package/dist/generic/link/link.svelte.d.ts +22 -0
  58. package/dist/generic/overlay.svelte +24 -0
  59. package/dist/generic/overlay.svelte.d.ts +27 -0
  60. package/dist/generic/pill/pill.stories.svelte +29 -0
  61. package/dist/generic/pill/pill.stories.svelte.d.ts +14 -0
  62. package/dist/generic/pill/pill.svelte +35 -0
  63. package/dist/generic/pill/pill.svelte.d.ts +20 -0
  64. package/dist/generic/scorecard/scorecard.stories.svelte +9 -0
  65. package/dist/generic/scorecard/scorecard.stories.svelte.d.ts +14 -0
  66. package/dist/generic/scorecard/scorecard.svelte +28 -0
  67. package/dist/generic/scorecard/scorecard.svelte.d.ts +18 -0
  68. package/dist/icons/angle-right-icon.svelte +12 -0
  69. package/dist/icons/angle-right-icon.svelte.d.ts +14 -0
  70. package/dist/icons/angle-up-icon.svelte +9 -0
  71. package/dist/icons/angle-up-icon.svelte.d.ts +23 -0
  72. package/dist/icons/home-icon.svelte +8 -0
  73. package/dist/icons/home-icon.svelte.d.ts +14 -0
  74. package/dist/icons/svg-icon.svelte +16 -0
  75. package/dist/icons/svg-icon.svelte.d.ts +24 -0
  76. package/dist/icons/upload-icon.svelte +9 -0
  77. package/dist/icons/upload-icon.svelte.d.ts +23 -0
  78. package/dist/index.d.ts +0 -0
  79. package/dist/index.js +2 -0
  80. package/dist/layout/flex-col.svelte +14 -0
  81. package/dist/layout/flex-col.svelte.d.ts +20 -0
  82. package/dist/layout/flex-item.svelte +7 -0
  83. package/dist/layout/flex-item.svelte.d.ts +27 -0
  84. package/dist/layout/flex-row.svelte +33 -0
  85. package/dist/layout/flex-row.svelte.d.ts +20 -0
  86. package/dist/modals/alert.stories.svelte +19 -0
  87. package/dist/modals/alert.stories.svelte.d.ts +14 -0
  88. package/dist/modals/alert.svelte +44 -0
  89. package/dist/modals/alert.svelte.d.ts +23 -0
  90. package/dist/modals/confirm.stories.svelte +9 -0
  91. package/dist/modals/confirm.stories.svelte.d.ts +14 -0
  92. package/dist/modals/confirm.svelte +57 -0
  93. package/dist/modals/confirm.svelte.d.ts +27 -0
  94. package/dist/modals/dialog-body.svelte +9 -0
  95. package/dist/modals/dialog-body.svelte.d.ts +27 -0
  96. package/dist/modals/dialog-footer.svelte +19 -0
  97. package/dist/modals/dialog-footer.svelte.d.ts +27 -0
  98. package/dist/modals/dialog-header.svelte +38 -0
  99. package/dist/modals/dialog-header.svelte.d.ts +20 -0
  100. package/dist/modals/dialog-window.svelte +33 -0
  101. package/dist/modals/dialog-window.svelte.d.ts +19 -0
  102. package/dist/modals/prompt.stories.svelte +9 -0
  103. package/dist/modals/prompt.stories.svelte.d.ts +14 -0
  104. package/dist/modals/prompt.svelte +66 -0
  105. package/dist/modals/prompt.svelte.d.ts +30 -0
  106. package/dist/navigation/accordian/accordian.stories.svelte +18 -0
  107. package/dist/navigation/accordian/accordian.stories.svelte.d.ts +14 -0
  108. package/dist/navigation/accordian/accordian.svelte +62 -0
  109. package/dist/navigation/accordian/accordian.svelte.d.ts +19 -0
  110. package/dist/navigation/app-bar/app-bar.stories.svelte +21 -0
  111. package/dist/navigation/app-bar/app-bar.stories.svelte.d.ts +14 -0
  112. package/dist/navigation/app-bar/app-bar.svelte +53 -0
  113. package/dist/navigation/app-bar/app-bar.svelte.d.ts +22 -0
  114. package/dist/navigation/breadcrumbs/breadcrumbs.stories.svelte +16 -0
  115. package/dist/navigation/breadcrumbs/breadcrumbs.stories.svelte.d.ts +14 -0
  116. package/dist/navigation/breadcrumbs/breadcrumbs.svelte +56 -0
  117. package/dist/navigation/breadcrumbs/breadcrumbs.svelte.d.ts +20 -0
  118. package/dist/navigation/side-bar/side-bar.stories.svelte +19 -0
  119. package/dist/navigation/side-bar/side-bar.stories.svelte.d.ts +14 -0
  120. package/dist/navigation/side-bar/side-bar.svelte +33 -0
  121. package/dist/navigation/side-bar/side-bar.svelte.d.ts +18 -0
  122. package/dist/navigation/tabs/tab-group.svelte +20 -0
  123. package/dist/navigation/tabs/tab-group.svelte.d.ts +21 -0
  124. package/dist/navigation/tabs/tab.svelte +87 -0
  125. package/dist/navigation/tabs/tab.svelte.d.ts +21 -0
  126. package/dist/navigation/tabs/tabs.stories.svelte +20 -0
  127. package/dist/navigation/tabs/tabs.stories.svelte.d.ts +14 -0
  128. package/dist/tables/data-grid.stories.svelte +40 -0
  129. package/dist/tables/data-grid.stories.svelte.d.ts +14 -0
  130. package/dist/tables/data-grid.svelte +43 -0
  131. package/dist/tables/data-grid.svelte.d.ts +18 -0
  132. package/dist/tables/table-body.svelte +3 -0
  133. package/dist/tables/table-body.svelte.d.ts +27 -0
  134. package/dist/tables/table-cell.svelte +13 -0
  135. package/dist/tables/table-cell.svelte.d.ts +18 -0
  136. package/dist/tables/table-footer-cell.svelte +12 -0
  137. package/dist/tables/table-footer-cell.svelte.d.ts +18 -0
  138. package/dist/tables/table-footer-row.svelte +3 -0
  139. package/dist/tables/table-footer-row.svelte.d.ts +27 -0
  140. package/dist/tables/table-footer.svelte +11 -0
  141. package/dist/tables/table-footer.svelte.d.ts +27 -0
  142. package/dist/tables/table-header-cell.svelte +18 -0
  143. package/dist/tables/table-header-cell.svelte.d.ts +18 -0
  144. package/dist/tables/table-header-row.svelte +4 -0
  145. package/dist/tables/table-header-row.svelte.d.ts +27 -0
  146. package/dist/tables/table-header.svelte +14 -0
  147. package/dist/tables/table-header.svelte.d.ts +27 -0
  148. package/dist/tables/table-row.svelte +15 -0
  149. package/dist/tables/table-row.svelte.d.ts +27 -0
  150. package/dist/tables/table.svelte +10 -0
  151. package/dist/tables/table.svelte.d.ts +27 -0
  152. package/package.json +73 -0
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # Sveltacular
2
+
3
+ I got tired of creating the same components over and over, so I decided to make an open source library of Svelte components.
4
+
5
+ This library is TypeScript and SASS based. It uses vanilla CSS without any frameworks to get in the way.
6
+
7
+ ## Run Storybook
8
+
9
+ ```
10
+ npm run storybook
11
+ ```
@@ -0,0 +1,33 @@
1
+ <script>import { Meta, Story } from "@storybook/addon-svelte-csf";
2
+ import Button from "./button.svelte";
3
+ </script>
4
+
5
+ <Meta title="Forms/Button" component={Button} />
6
+
7
+ <Story name="Primary">
8
+ <Button style="primary">Click Me</Button>
9
+ </Story>
10
+
11
+ <Story name="Secondary">
12
+ <Button style="secondary">Click Me</Button>
13
+ </Story>
14
+
15
+ <Story name="Tertiary">
16
+ <Button style="tertiary">Click Me</Button>
17
+ </Story>
18
+
19
+ <Story name="Danger">
20
+ <Button style="danger">Click Me</Button>
21
+ </Story>
22
+
23
+ <Story name="Positive">
24
+ <Button style="positive">Click Me</Button>
25
+ </Story>
26
+
27
+ <Story name="Negative">
28
+ <Button style="negative">Click Me</Button>
29
+ </Story>
30
+
31
+ <Story name="Link">
32
+ <Button style="link">Click Me</Button>
33
+ </Story>
@@ -0,0 +1,14 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export type ButtonProps = typeof __propDef.props;
10
+ export type ButtonEvents = typeof __propDef.events;
11
+ export type ButtonSlots = typeof __propDef.slots;
12
+ export default class Button extends SvelteComponent<ButtonProps, ButtonEvents, ButtonSlots> {
13
+ }
14
+ export {};
@@ -0,0 +1,129 @@
1
+ <script>import { navigateTo } from "../../../helpers/navigate-to.js";
2
+ import { createEventDispatcher } from "svelte";
3
+ export let href = void 0;
4
+ export let size = "md";
5
+ export let style = "secondary";
6
+ export let type = "button";
7
+ export let block = false;
8
+ export let disabled = false;
9
+ const dispatch = createEventDispatcher();
10
+ const click = () => {
11
+ dispatch("click");
12
+ if (href) {
13
+ navigateTo(href);
14
+ }
15
+ };
16
+ </script>
17
+
18
+ <button {type} on:click={click} class="{size} {style}" class:block {disabled}>
19
+ <slot />
20
+ </button>
21
+
22
+ <style>button {
23
+ display: inline-block;
24
+ min-width: 10rem;
25
+ cursor: pointer;
26
+ margin-top: 0.5rem;
27
+ margin-bottom: 0.5rem;
28
+ background-color: #5c5c5c;
29
+ border: 1px solid #b7b7b7;
30
+ border-radius: 0.25rem;
31
+ color: #e2e2e2;
32
+ cursor: pointer;
33
+ display: inline-block;
34
+ font-size: 0.875rem;
35
+ font-weight: 500;
36
+ line-height: 1.25rem;
37
+ padding: 0.5rem 1rem;
38
+ text-align: center;
39
+ text-decoration: none;
40
+ transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.2s ease-in-out, fill 0.2s ease-in-out, stroke 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
41
+ user-select: none;
42
+ white-space: nowrap;
43
+ }
44
+ button.block {
45
+ display: block;
46
+ width: 100%;
47
+ }
48
+ button.sm {
49
+ font-size: 0.75rem;
50
+ line-height: 1rem;
51
+ padding: 0.25rem 0.5rem;
52
+ }
53
+ button.lg {
54
+ font-size: 1rem;
55
+ line-height: 1.5rem;
56
+ padding: 0.75rem 1.5rem;
57
+ }
58
+ button.xl {
59
+ font-size: 1.25rem;
60
+ line-height: 1.75rem;
61
+ padding: 1rem 2rem;
62
+ }
63
+ button.full {
64
+ width: 100%;
65
+ padding: 0.5rem 0;
66
+ display: block;
67
+ min-width: auto;
68
+ flex-grow: 1;
69
+ }
70
+ button:hover {
71
+ background-color: #4c4c4c;
72
+ }
73
+ button.primary {
74
+ background-color: #1e88e5;
75
+ border-color: #1e88e5;
76
+ color: #fff;
77
+ }
78
+ button.primary:hover {
79
+ background-color: #1976d2;
80
+ border-color: #1976d2;
81
+ }
82
+ button.link, button.ghost {
83
+ background-color: transparent;
84
+ border-color: transparent;
85
+ color: var(--sv-color-link);
86
+ text-decoration: underline;
87
+ }
88
+ button.link:hover, button.ghost:hover {
89
+ background-color: transparent;
90
+ border-color: transparent;
91
+ color: var(--sv-color-link-hover);
92
+ }
93
+ button.positive {
94
+ background-color: #43a047;
95
+ border-color: #43a047;
96
+ color: #fff;
97
+ }
98
+ button.positive:hover {
99
+ background-color: #388e3c;
100
+ border-color: #388e3c;
101
+ }
102
+ button.danger {
103
+ background-color: #8d0200;
104
+ border-color: #8d0200;
105
+ color: #fff;
106
+ }
107
+ button.danger:hover {
108
+ background-color: #c62828;
109
+ border-color: #c62828;
110
+ }
111
+ button.negative {
112
+ background-color: #e53935;
113
+ border-color: #e53935;
114
+ color: #fff;
115
+ }
116
+ button.negative:hover {
117
+ background-color: #c62828;
118
+ border-color: #c62828;
119
+ }
120
+ button.tertiary {
121
+ background-color: transparent;
122
+ border-color: var(--sv-color-fg);
123
+ color: var(--sv-color-fg);
124
+ }
125
+ button.tertiary:hover {
126
+ background-color: var(--sv-color-fg);
127
+ color: var(--sv-color-bg);
128
+ border-color: var(--sv-color-bg);
129
+ }</style>
@@ -0,0 +1,26 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { ButtonStyle, FormFieldSizeOptions } from '../../../types/form.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ href?: string | undefined;
6
+ size?: FormFieldSizeOptions | undefined;
7
+ style?: ButtonStyle | undefined;
8
+ type?: "submit" | "button" | "reset" | undefined;
9
+ block?: boolean | undefined;
10
+ disabled?: boolean | undefined;
11
+ };
12
+ events: {
13
+ click: CustomEvent<void>;
14
+ } & {
15
+ [evt: string]: CustomEvent<any>;
16
+ };
17
+ slots: {
18
+ default: {};
19
+ };
20
+ };
21
+ export type ButtonProps = typeof __propDef.props;
22
+ export type ButtonEvents = typeof __propDef.events;
23
+ export type ButtonSlots = typeof __propDef.slots;
24
+ export default class Button extends SvelteComponent<ButtonProps, ButtonEvents, ButtonSlots> {
25
+ }
26
+ export {};
@@ -0,0 +1,13 @@
1
+ <script>import { Meta, Story } from "@storybook/addon-svelte-csf";
2
+ import CheckBox from "./check-box.svelte";
3
+ </script>
4
+
5
+ <Meta title="Forms/CheckBox" component={CheckBox} />
6
+
7
+ <Story name="Standard">
8
+ <CheckBox isChecked={true}>Turn on sync</CheckBox>
9
+ </Story>
10
+
11
+ <Story name="No Label">
12
+ <CheckBox isChecked={false} />
13
+ </Story>
@@ -0,0 +1,14 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export type CheckBoxProps = typeof __propDef.props;
10
+ export type CheckBoxEvents = typeof __propDef.events;
11
+ export type CheckBoxSlots = typeof __propDef.slots;
12
+ export default class CheckBox extends SvelteComponent<CheckBoxProps, CheckBoxEvents, CheckBoxSlots> {
13
+ }
14
+ export {};
@@ -0,0 +1,26 @@
1
+ <script>import { uniqueId } from "../../../helpers/unique-id.js";
2
+ import CheckInput from "./check-input.svelte";
3
+ import { createEventDispatcher } from "svelte";
4
+ export let value = void 0;
5
+ export let isChecked = false;
6
+ const id = uniqueId();
7
+ const dispatch = createEventDispatcher();
8
+ </script>
9
+
10
+ <div>
11
+ <CheckInput {id} bind:value bind:isChecked on:change={() => dispatch('change', isChecked)} />
12
+ {#if $$slots.default}
13
+ <label for={id}>
14
+ <slot />
15
+ </label>
16
+ {/if}
17
+ </div>
18
+
19
+ <style>div label {
20
+ display: inline-block;
21
+ vertical-align: middle;
22
+ margin-left: 0.5em;
23
+ cursor: pointer;
24
+ font-size: 1rem;
25
+ line-height: 2rem;
26
+ }</style>
@@ -0,0 +1,21 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ value?: string | number | boolean | undefined;
5
+ isChecked?: boolean | undefined;
6
+ };
7
+ events: {
8
+ change: CustomEvent<boolean>;
9
+ } & {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {
13
+ default: {};
14
+ };
15
+ };
16
+ export type CheckBoxProps = typeof __propDef.props;
17
+ export type CheckBoxEvents = typeof __propDef.events;
18
+ export type CheckBoxSlots = typeof __propDef.slots;
19
+ export default class CheckBox extends SvelteComponent<CheckBoxProps, CheckBoxEvents, CheckBoxSlots> {
20
+ }
21
+ export {};
@@ -0,0 +1,32 @@
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ export let id = void 0;
3
+ export let value = void 0;
4
+ export let isChecked = false;
5
+ const dispatch = createEventDispatcher();
6
+ </script>
7
+
8
+ <input
9
+ type="checkbox"
10
+ {id}
11
+ bind:value
12
+ bind:checked={isChecked}
13
+ on:change={() => dispatch('change', isChecked)}
14
+ />
15
+
16
+ <style>input {
17
+ display: inline-block;
18
+ vertical-align: middle;
19
+ margin: 0;
20
+ padding: 0;
21
+ width: 1em;
22
+ height: 1em;
23
+ border: 0.1em solid #000;
24
+ border-radius: 0.2em;
25
+ background-color: #fff;
26
+ cursor: pointer;
27
+ transition: background-color 0.3s ease-in-out;
28
+ }
29
+
30
+ input:checked {
31
+ background-color: #000;
32
+ }</style>
@@ -0,0 +1,20 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ id?: string | undefined;
5
+ value?: string | number | boolean | undefined;
6
+ isChecked?: boolean | undefined;
7
+ };
8
+ events: {
9
+ change: CustomEvent<boolean>;
10
+ } & {
11
+ [evt: string]: CustomEvent<any>;
12
+ };
13
+ slots: {};
14
+ };
15
+ export type CheckInputProps = typeof __propDef.props;
16
+ export type CheckInputEvents = typeof __propDef.events;
17
+ export type CheckInputSlots = typeof __propDef.slots;
18
+ export default class CheckInput extends SvelteComponent<CheckInputProps, CheckInputEvents, CheckInputSlots> {
19
+ }
20
+ export {};
@@ -0,0 +1,17 @@
1
+ <script>import { Meta, Story } from "@storybook/addon-svelte-csf";
2
+ import DateBox from "./date-box.svelte";
3
+ </script>
4
+
5
+ <Meta title="Forms/DateBox" component={DateBox} />
6
+
7
+ <Story name="Date">
8
+ <DateBox type="date">Birthdate</DateBox>
9
+ </Story>
10
+
11
+ <Story name="Date + Time">
12
+ <DateBox type="datetime-local">Deadline</DateBox>
13
+ </Story>
14
+
15
+ <Story name="Date (Nullable)">
16
+ <DateBox type="date" nullable={true}>End Date</DateBox>
17
+ </Story>
@@ -0,0 +1,14 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export type DateBoxProps = typeof __propDef.props;
10
+ export type DateBoxEvents = typeof __propDef.events;
11
+ export type DateBoxSlots = typeof __propDef.slots;
12
+ export default class DateBox extends SvelteComponent<DateBoxProps, DateBoxEvents, DateBoxSlots> {
13
+ }
14
+ export {};
@@ -0,0 +1,68 @@
1
+ <script>import { currentDateTime } from "../../../helpers/date.js";
2
+ import { uniqueId } from "../../../helpers/unique-id.js";
3
+ import CheckInput from "../check-box/check-input.svelte";
4
+ import FormField from "../form-field.svelte";
5
+ import FormLabel from "../form-label.svelte";
6
+ const id = uniqueId();
7
+ export let value = "";
8
+ export let placeholder = "";
9
+ export let nullable = false;
10
+ export let enabled = true;
11
+ export let type = "date";
12
+ export let required = false;
13
+ const defaultValue = value || currentDateTime();
14
+ const checkChanged = () => {
15
+ if (nullable) {
16
+ value = enabled ? defaultValue : "";
17
+ }
18
+ };
19
+ $:
20
+ disabled = !enabled;
21
+ </script>
22
+
23
+ <FormField>
24
+ <FormLabel {id} {required}><slot /></FormLabel>
25
+ <div class:nullable class:disabled>
26
+ <span class="input">
27
+ <input {...{ type }} {id} {placeholder} {disabled} bind:value {required} />
28
+ </span>
29
+ {#if nullable}
30
+ <span class="toggle">
31
+ <CheckInput bind:isChecked={enabled} on:change={checkChanged} />
32
+ </span>
33
+ {/if}
34
+ </div>
35
+ </FormField>
36
+
37
+ <style>input {
38
+ width: 100%;
39
+ padding: 0.5rem 1rem;
40
+ border-radius: 0.25rem;
41
+ border: 1px solid #b7b7b7;
42
+ background-color: #fff;
43
+ color: #5c5c5c;
44
+ font-size: 0.875rem;
45
+ font-weight: 500;
46
+ line-height: 1.25rem;
47
+ transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.2s ease-in-out, fill 0.2s ease-in-out, stroke 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
48
+ user-select: none;
49
+ white-space: nowrap;
50
+ }
51
+
52
+ div {
53
+ display: block;
54
+ position: relative;
55
+ }
56
+ div.nullable input {
57
+ padding-left: 2.5rem;
58
+ }
59
+ div.nullable .toggle {
60
+ position: absolute;
61
+ top: 0.55rem;
62
+ left: 0.75rem;
63
+ }
64
+ div.disabled input {
65
+ background-color: #f5f5f5;
66
+ border-color: #e0e0e0;
67
+ color: #a0a0a0;
68
+ }</style>
@@ -0,0 +1,23 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ value?: string | undefined;
5
+ placeholder?: string | undefined;
6
+ nullable?: boolean | undefined;
7
+ enabled?: boolean | undefined;
8
+ type?: "date" | "datetime-local" | undefined;
9
+ required?: boolean | undefined;
10
+ };
11
+ events: {
12
+ [evt: string]: CustomEvent<any>;
13
+ };
14
+ slots: {
15
+ default: {};
16
+ };
17
+ };
18
+ export type DateBoxProps = typeof __propDef.props;
19
+ export type DateBoxEvents = typeof __propDef.events;
20
+ export type DateBoxSlots = typeof __propDef.slots;
21
+ export default class DateBox extends SvelteComponent<DateBoxProps, DateBoxEvents, DateBoxSlots> {
22
+ }
23
+ export {};
@@ -0,0 +1,15 @@
1
+ <script>import { Meta, Story } from "@storybook/addon-svelte-csf";
2
+ import DropdownBox from "./dropdown-box.svelte";
3
+ const items = [
4
+ { name: "SvelteKit", value: "svelte " },
5
+ { name: "Angular", value: "angular " },
6
+ { name: "React", value: "react " },
7
+ { name: "Vue", value: "vue " }
8
+ ];
9
+ </script>
10
+
11
+ <Meta title="Forms/DropdownBox" component={DropdownBox} />
12
+
13
+ <Story name="Simple">
14
+ <DropdownBox {items}>Best JavaScript Framework</DropdownBox>
15
+ </Story>
@@ -0,0 +1,14 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export type DropdownBoxProps = typeof __propDef.props;
10
+ export type DropdownBoxEvents = typeof __propDef.events;
11
+ export type DropdownBoxSlots = typeof __propDef.slots;
12
+ export default class DropdownBox extends SvelteComponent<DropdownBoxProps, DropdownBoxEvents, DropdownBoxSlots> {
13
+ }
14
+ export {};
@@ -0,0 +1,36 @@
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ import FormField from "../form-field.svelte";
3
+ import FormLabel from "../form-label.svelte";
4
+ import { uniqueId } from "../../../helpers/unique-id.js";
5
+ const dispatch = createEventDispatcher();
6
+ const id = uniqueId();
7
+ export let value = "";
8
+ export let items = [];
9
+ export let size = "md";
10
+ export let disabled = false;
11
+ export let required = false;
12
+ </script>
13
+
14
+ <FormField {size}>
15
+ <FormLabel {id} {required}><slot /></FormLabel>
16
+ <select {id} bind:value on:change={() => dispatch('change', value)} {required} {disabled}>
17
+ {#each items as item}
18
+ <option value={item.value}>{item.name}</option>
19
+ {/each}
20
+ </select>
21
+ </FormField>
22
+
23
+ <style>select {
24
+ width: 100%;
25
+ padding: 0.5rem 1rem;
26
+ border-radius: 0.25rem;
27
+ border: 1px solid #b7b7b7;
28
+ background-color: #fff;
29
+ color: #5c5c5c;
30
+ font-size: 0.875rem;
31
+ font-weight: 500;
32
+ line-height: 1.25rem;
33
+ transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.2s ease-in-out, fill 0.2s ease-in-out, stroke 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
34
+ user-select: none;
35
+ white-space: nowrap;
36
+ }</style>
@@ -0,0 +1,25 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { DropdownOption, FormFieldSizeOptions } from '../../../types/form.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ value?: string | undefined;
6
+ items?: DropdownOption[] | undefined;
7
+ size?: FormFieldSizeOptions | undefined;
8
+ disabled?: boolean | undefined;
9
+ required?: boolean | undefined;
10
+ };
11
+ events: {
12
+ change: CustomEvent<string>;
13
+ } & {
14
+ [evt: string]: CustomEvent<any>;
15
+ };
16
+ slots: {
17
+ default: {};
18
+ };
19
+ };
20
+ export type DropdownBoxProps = typeof __propDef.props;
21
+ export type DropdownBoxEvents = typeof __propDef.events;
22
+ export type DropdownBoxSlots = typeof __propDef.slots;
23
+ export default class DropdownBox extends SvelteComponent<DropdownBoxProps, DropdownBoxEvents, DropdownBoxSlots> {
24
+ }
25
+ export {};
@@ -0,0 +1,22 @@
1
+ <script>const maxWidthMap = {
2
+ sm: "10rem",
3
+ md: "20rem",
4
+ lg: "30rem",
5
+ xl: "auto",
6
+ full: "100%"
7
+ };
8
+ export let size = "md";
9
+ $:
10
+ displayType = ["xl", "full"].includes(size) ? "block" : "inline-block";
11
+ $:
12
+ maxWidth = maxWidthMap[size];
13
+ </script>
14
+
15
+ <div style={`display: ${displayType}; width: 100%; min-width: 10rem; max-width: ${maxWidth}`}>
16
+ <slot />
17
+ </div>
18
+
19
+ <style>div {
20
+ margin-bottom: 1rem;
21
+ margin-right: 1rem;
22
+ }</style>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { FormFieldSizeOptions } from '../../types/form.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ size?: FormFieldSizeOptions | undefined;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export type FormFieldProps = typeof __propDef.props;
15
+ export type FormFieldEvents = typeof __propDef.events;
16
+ export type FormFieldSlots = typeof __propDef.slots;
17
+ export default class FormField extends SvelteComponent<FormFieldProps, FormFieldEvents, FormFieldSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,14 @@
1
+ <script>export let id;
2
+ export let required = false;
3
+ </script>
4
+
5
+ <label for={id} class:required><slot /></label>
6
+
7
+ <style>label {
8
+ display: block;
9
+ margin-bottom: 0.5rem;
10
+ }
11
+ label.required::after {
12
+ content: "*";
13
+ margin-left: 0.25rem;
14
+ }</style>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ id: string;
5
+ required?: boolean | undefined;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export type FormLabelProps = typeof __propDef.props;
15
+ export type FormLabelEvents = typeof __propDef.events;
16
+ export type FormLabelSlots = typeof __propDef.slots;
17
+ export default class FormLabel extends SvelteComponent<FormLabelProps, FormLabelEvents, FormLabelSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,12 @@
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ export let action = "get";
3
+ const dispatch = createEventDispatcher();
4
+ const onSubmit = (e) => {
5
+ e.preventDefault();
6
+ dispatch("submit");
7
+ };
8
+ </script>
9
+
10
+ <form {action} on:submit={onSubmit}>
11
+ <slot />
12
+ </form>