plasma-svelte 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.
- package/README.md +65 -0
- package/dist/accordion/Accordion.svelte +28 -0
- package/dist/accordion/Accordion.svelte.d.ts +8 -0
- package/dist/accordion/AccordionItem.svelte +193 -0
- package/dist/accordion/AccordionItem.svelte.d.ts +14 -0
- package/dist/avatar/Avatar.svelte +178 -0
- package/dist/avatar/Avatar.svelte.d.ts +16 -0
- package/dist/badge/Badge.svelte +162 -0
- package/dist/badge/Badge.svelte.d.ts +16 -0
- package/dist/breadcrumb/Breadcrumb.svelte +59 -0
- package/dist/breadcrumb/Breadcrumb.svelte.d.ts +9 -0
- package/dist/breadcrumb/BreadcrumbItem.svelte +151 -0
- package/dist/breadcrumb/BreadcrumbItem.svelte.d.ts +14 -0
- package/dist/button/Button.svelte +274 -0
- package/dist/button/Button.svelte.d.ts +22 -0
- package/dist/button/ButtonGroup.svelte +98 -0
- package/dist/button/ButtonGroup.svelte.d.ts +12 -0
- package/dist/card/Card.svelte +191 -0
- package/dist/card/Card.svelte.d.ts +18 -0
- package/dist/checkbox/Checkbox.svelte +199 -0
- package/dist/checkbox/Checkbox.svelte.d.ts +12 -0
- package/dist/datepicker/DatePicker.svelte +509 -0
- package/dist/datepicker/DatePicker.svelte.d.ts +14 -0
- package/dist/divider/Divider.svelte +112 -0
- package/dist/divider/Divider.svelte.d.ts +13 -0
- package/dist/drawer/Drawer.svelte +330 -0
- package/dist/drawer/Drawer.svelte.d.ts +21 -0
- package/dist/dropzone/DropZone.svelte +282 -0
- package/dist/dropzone/DropZone.svelte.d.ts +17 -0
- package/dist/emptystate/EmptyState.svelte +169 -0
- package/dist/emptystate/EmptyState.svelte.d.ts +15 -0
- package/dist/headerbar/HeaderBar.svelte +210 -0
- package/dist/headerbar/HeaderBar.svelte.d.ts +17 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +44 -0
- package/dist/input/Input.svelte +227 -0
- package/dist/input/Input.svelte.d.ts +14 -0
- package/dist/layout/Flex.svelte +110 -0
- package/dist/layout/Flex.svelte.d.ts +20 -0
- package/dist/layout/Grid.svelte +78 -0
- package/dist/layout/Grid.svelte.d.ts +19 -0
- package/dist/layout/Space.svelte +64 -0
- package/dist/layout/Space.svelte.d.ts +16 -0
- package/dist/layout/utils.d.ts +2 -0
- package/dist/layout/utils.js +19 -0
- package/dist/menu/Menu.svelte +156 -0
- package/dist/menu/Menu.svelte.d.ts +14 -0
- package/dist/menu/MenuDivider.svelte +19 -0
- package/dist/menu/MenuDivider.svelte.d.ts +6 -0
- package/dist/menu/MenuItem.svelte +126 -0
- package/dist/menu/MenuItem.svelte.d.ts +13 -0
- package/dist/message/InlineMessage.svelte +226 -0
- package/dist/message/InlineMessage.svelte.d.ts +15 -0
- package/dist/modal/ConfirmDialog.svelte +151 -0
- package/dist/modal/ConfirmDialog.svelte.d.ts +19 -0
- package/dist/modal/Modal.svelte +279 -0
- package/dist/modal/Modal.svelte.d.ts +18 -0
- package/dist/pagination/Pagination.svelte +258 -0
- package/dist/pagination/Pagination.svelte.d.ts +16 -0
- package/dist/progress/ProgressBar.svelte +179 -0
- package/dist/progress/ProgressBar.svelte.d.ts +15 -0
- package/dist/radio/Radio.svelte +161 -0
- package/dist/radio/Radio.svelte.d.ts +13 -0
- package/dist/searchfield/SearchField.svelte +246 -0
- package/dist/searchfield/SearchField.svelte.d.ts +15 -0
- package/dist/select/Select.svelte +392 -0
- package/dist/select/Select.svelte.d.ts +20 -0
- package/dist/sidebar/Sidebar.svelte +78 -0
- package/dist/sidebar/Sidebar.svelte.d.ts +11 -0
- package/dist/sidebar/SidebarGroup.svelte +51 -0
- package/dist/sidebar/SidebarGroup.svelte.d.ts +9 -0
- package/dist/sidebar/SidebarItem.svelte +185 -0
- package/dist/sidebar/SidebarItem.svelte.d.ts +16 -0
- package/dist/slider/Slider.svelte +204 -0
- package/dist/slider/Slider.svelte.d.ts +16 -0
- package/dist/spinbox/SpinBox.svelte +299 -0
- package/dist/spinbox/SpinBox.svelte.d.ts +20 -0
- package/dist/spinner/Spinner.svelte +130 -0
- package/dist/spinner/Spinner.svelte.d.ts +11 -0
- package/dist/style/base.css +178 -0
- package/dist/style/index.css +2 -0
- package/dist/style/token.css +230 -0
- package/dist/switch/Switch.svelte +199 -0
- package/dist/switch/Switch.svelte.d.ts +13 -0
- package/dist/table/Table.svelte +305 -0
- package/dist/table/Table.svelte.d.ts +32 -0
- package/dist/tabs/Tabs.svelte +216 -0
- package/dist/tabs/Tabs.svelte.d.ts +21 -0
- package/dist/textarea/TextArea.svelte +114 -0
- package/dist/textarea/TextArea.svelte.d.ts +14 -0
- package/dist/timepicker/TimePicker.svelte +452 -0
- package/dist/timepicker/TimePicker.svelte.d.ts +16 -0
- package/dist/tooltip/Tooltip.svelte +122 -0
- package/dist/tooltip/Tooltip.svelte.d.ts +12 -0
- package/package.json +66 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
type InputSize = "sm" | "md" | "lg" | "small" | "medium" | "large";
|
|
6
|
+
|
|
7
|
+
interface Props extends Omit<HTMLInputAttributes, "size" | "prefix"> {
|
|
8
|
+
value?: string | number;
|
|
9
|
+
size?: InputSize;
|
|
10
|
+
invalid?: boolean;
|
|
11
|
+
clearable?: boolean;
|
|
12
|
+
prefix?: Snippet;
|
|
13
|
+
suffix?: Snippet;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
value = $bindable(""),
|
|
18
|
+
size = "md",
|
|
19
|
+
type = "text",
|
|
20
|
+
placeholder = "",
|
|
21
|
+
disabled = false,
|
|
22
|
+
readonly = false,
|
|
23
|
+
invalid = false,
|
|
24
|
+
clearable = false,
|
|
25
|
+
prefix,
|
|
26
|
+
suffix,
|
|
27
|
+
class: customClass = "",
|
|
28
|
+
...restProps
|
|
29
|
+
}: Props = $props();
|
|
30
|
+
|
|
31
|
+
// Normalize size strings
|
|
32
|
+
const resolvedSize = $derived(
|
|
33
|
+
size === "small"
|
|
34
|
+
? "sm"
|
|
35
|
+
: size === "large"
|
|
36
|
+
? "lg"
|
|
37
|
+
: size === "medium"
|
|
38
|
+
? "md"
|
|
39
|
+
: size,
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
function handleClear() {
|
|
43
|
+
value = "";
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<div
|
|
48
|
+
class="plasma-input-container plasma-input--{resolvedSize} {customClass}"
|
|
49
|
+
class:plasma-input--disabled={disabled}
|
|
50
|
+
class:plasma-input--invalid={invalid}
|
|
51
|
+
class:plasma-input--readonly={readonly}
|
|
52
|
+
>
|
|
53
|
+
{#if prefix}
|
|
54
|
+
<div class="plasma-input-prefix">
|
|
55
|
+
{@render prefix()}
|
|
56
|
+
</div>
|
|
57
|
+
{/if}
|
|
58
|
+
|
|
59
|
+
<input
|
|
60
|
+
{type}
|
|
61
|
+
{placeholder}
|
|
62
|
+
{disabled}
|
|
63
|
+
{readonly}
|
|
64
|
+
bind:value
|
|
65
|
+
class="plasma-input-field"
|
|
66
|
+
{...restProps}
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
{#if clearable && value && !disabled && !readonly}
|
|
70
|
+
<button
|
|
71
|
+
type="button"
|
|
72
|
+
class="plasma-input-clear-btn"
|
|
73
|
+
onclick={handleClear}
|
|
74
|
+
tabindex="-1"
|
|
75
|
+
aria-label="Clear input"
|
|
76
|
+
>
|
|
77
|
+
<svg
|
|
78
|
+
role="img"
|
|
79
|
+
aria-label="prefix-icon"
|
|
80
|
+
viewBox="0 0 16 16"
|
|
81
|
+
width="12"
|
|
82
|
+
height="12"
|
|
83
|
+
fill="currentColor"
|
|
84
|
+
>
|
|
85
|
+
<path
|
|
86
|
+
d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"
|
|
87
|
+
/>
|
|
88
|
+
</svg>
|
|
89
|
+
</button>
|
|
90
|
+
{/if}
|
|
91
|
+
|
|
92
|
+
{#if suffix}
|
|
93
|
+
<div class="plasma-input-suffix">
|
|
94
|
+
{@render suffix()}
|
|
95
|
+
</div>
|
|
96
|
+
{/if}
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<style>
|
|
100
|
+
.plasma-input-container {
|
|
101
|
+
position: relative;
|
|
102
|
+
display: inline-flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
width: 100%;
|
|
105
|
+
box-sizing: border-box;
|
|
106
|
+
font-family: var(--plasma-font-sans);
|
|
107
|
+
background-color: var(--plasma-color-view-bg);
|
|
108
|
+
border: 1px solid var(--plasma-color-border);
|
|
109
|
+
border-radius: var(--plasma-radius-md);
|
|
110
|
+
color: var(--plasma-color-text);
|
|
111
|
+
transition: var(--plasma-transition-fast);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.plasma-input-container:hover:not(.plasma-input--disabled):not(
|
|
115
|
+
:focus-within
|
|
116
|
+
) {
|
|
117
|
+
border-color: var(--plasma-color-border-hover);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.plasma-input-container:focus-within:not(.plasma-input--disabled) {
|
|
121
|
+
border-color: var(--plasma-color-highlight);
|
|
122
|
+
box-shadow: var(--plasma-shadow-focus);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* --------------------------------------------------------------------------
|
|
126
|
+
Invalid State
|
|
127
|
+
-------------------------------------------------------------------------- */
|
|
128
|
+
.plasma-input-container.plasma-input--invalid {
|
|
129
|
+
border-color: var(--plasma-color-negative);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.plasma-input-container.plasma-input--invalid:focus-within {
|
|
133
|
+
box-shadow: 0 0 0 2px rgba(218, 68, 83, 0.35);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* --------------------------------------------------------------------------
|
|
137
|
+
Inner Input Field
|
|
138
|
+
-------------------------------------------------------------------------- */
|
|
139
|
+
.plasma-input-field {
|
|
140
|
+
width: 100%;
|
|
141
|
+
flex: 1;
|
|
142
|
+
min-width: 0;
|
|
143
|
+
border: none;
|
|
144
|
+
outline: none;
|
|
145
|
+
background: transparent;
|
|
146
|
+
color: inherit;
|
|
147
|
+
font-family: inherit;
|
|
148
|
+
font-size: inherit;
|
|
149
|
+
line-height: 1.5;
|
|
150
|
+
padding: 0;
|
|
151
|
+
}
|
|
152
|
+
/* --------------------------------------------------------------------------
|
|
153
|
+
Disabled & Readonly
|
|
154
|
+
-------------------------------------------------------------------------- */
|
|
155
|
+
.plasma-input-container.plasma-input--disabled {
|
|
156
|
+
opacity: 0.45;
|
|
157
|
+
cursor: not-allowed;
|
|
158
|
+
background-color: var(--plasma-color-surface-sunken);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.plasma-input-container.plasma-input--disabled .plasma-input-field {
|
|
162
|
+
cursor: not-allowed;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.plasma-input-container.plasma-input--readonly {
|
|
166
|
+
background-color: var(--plasma-color-surface-sunken);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.plasma-input-field::placeholder {
|
|
170
|
+
color: var(--plasma-color-text-muted);
|
|
171
|
+
opacity: 0.75;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* --------------------------------------------------------------------------
|
|
175
|
+
Prefix, Suffix & Clear Button
|
|
176
|
+
-------------------------------------------------------------------------- */
|
|
177
|
+
.plasma-input-prefix,
|
|
178
|
+
.plasma-input-suffix {
|
|
179
|
+
display: inline-flex;
|
|
180
|
+
align-items: center;
|
|
181
|
+
color: var(--plasma-color-text-muted);
|
|
182
|
+
flex-shrink: 0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.plasma-input-clear-btn {
|
|
186
|
+
display: inline-flex;
|
|
187
|
+
align-items: center;
|
|
188
|
+
justify-content: center;
|
|
189
|
+
background: transparent;
|
|
190
|
+
border: none;
|
|
191
|
+
color: var(--plasma-color-text-muted);
|
|
192
|
+
cursor: pointer;
|
|
193
|
+
padding: 2px;
|
|
194
|
+
border-radius: var(--plasma-radius-full);
|
|
195
|
+
transition: var(--plasma-transition-fast);
|
|
196
|
+
flex-shrink: 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.plasma-input-clear-btn:hover {
|
|
200
|
+
color: var(--plasma-color-text);
|
|
201
|
+
background-color: var(--plasma-color-surface-hover);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* --------------------------------------------------------------------------
|
|
205
|
+
Sizing
|
|
206
|
+
-------------------------------------------------------------------------- */
|
|
207
|
+
.plasma-input--sm {
|
|
208
|
+
height: var(--plasma-control-height-sm);
|
|
209
|
+
padding: 0 var(--plasma-space-sm);
|
|
210
|
+
font-size: var(--plasma-font-size-xs);
|
|
211
|
+
gap: var(--plasma-space-2xs);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.plasma-input--md {
|
|
215
|
+
height: var(--plasma-control-height-md);
|
|
216
|
+
padding: 0 var(--plasma-space-md);
|
|
217
|
+
font-size: var(--plasma-font-size-base);
|
|
218
|
+
gap: var(--plasma-space-xs);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.plasma-input--lg {
|
|
222
|
+
height: var(--plasma-control-height-lg);
|
|
223
|
+
padding: 0 var(--plasma-space-lg);
|
|
224
|
+
font-size: var(--plasma-font-size-md);
|
|
225
|
+
gap: var(--plasma-space-sm);
|
|
226
|
+
}
|
|
227
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
3
|
+
type InputSize = "sm" | "md" | "lg" | "small" | "medium" | "large";
|
|
4
|
+
interface Props extends Omit<HTMLInputAttributes, "size" | "prefix"> {
|
|
5
|
+
value?: string | number;
|
|
6
|
+
size?: InputSize;
|
|
7
|
+
invalid?: boolean;
|
|
8
|
+
clearable?: boolean;
|
|
9
|
+
prefix?: Snippet;
|
|
10
|
+
suffix?: Snippet;
|
|
11
|
+
}
|
|
12
|
+
declare const Input: import("svelte").Component<Props, {}, "value">;
|
|
13
|
+
type Input = ReturnType<typeof Input>;
|
|
14
|
+
export default Input;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
import { resolveSpacing, type PlasmaSpacing } from "./utils.js";
|
|
5
|
+
|
|
6
|
+
type FlexDirection = "row" | "column" | "row-reverse" | "column-reverse";
|
|
7
|
+
type FlexJustify =
|
|
8
|
+
| "start"
|
|
9
|
+
| "end"
|
|
10
|
+
| "center"
|
|
11
|
+
| "between"
|
|
12
|
+
| "around"
|
|
13
|
+
| "evenly"
|
|
14
|
+
| "flex-start"
|
|
15
|
+
| "flex-end"
|
|
16
|
+
| "space-between"
|
|
17
|
+
| "space-around"
|
|
18
|
+
| "space-evenly";
|
|
19
|
+
type FlexAlign =
|
|
20
|
+
| "start"
|
|
21
|
+
| "end"
|
|
22
|
+
| "center"
|
|
23
|
+
| "baseline"
|
|
24
|
+
| "stretch"
|
|
25
|
+
| "flex-start"
|
|
26
|
+
| "flex-end";
|
|
27
|
+
type FlexWrap = boolean | "wrap" | "nowrap" | "wrap-reverse";
|
|
28
|
+
|
|
29
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
30
|
+
vertical?: boolean;
|
|
31
|
+
direction?: FlexDirection;
|
|
32
|
+
justify?: FlexJustify;
|
|
33
|
+
align?: FlexAlign;
|
|
34
|
+
wrap?: FlexWrap;
|
|
35
|
+
gap?: PlasmaSpacing;
|
|
36
|
+
inline?: boolean;
|
|
37
|
+
children?: Snippet;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let {
|
|
41
|
+
vertical = false,
|
|
42
|
+
direction,
|
|
43
|
+
justify,
|
|
44
|
+
align,
|
|
45
|
+
wrap = false,
|
|
46
|
+
gap = "sm",
|
|
47
|
+
inline = false,
|
|
48
|
+
children,
|
|
49
|
+
class: customClass = "",
|
|
50
|
+
style = "",
|
|
51
|
+
...restProps
|
|
52
|
+
}: Props = $props();
|
|
53
|
+
|
|
54
|
+
const resolvedDirection = $derived(
|
|
55
|
+
direction || (vertical ? "column" : "row")
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const resolvedJustify = $derived.by(() => {
|
|
59
|
+
if (!justify) return undefined;
|
|
60
|
+
switch (justify) {
|
|
61
|
+
case "start": return "flex-start";
|
|
62
|
+
case "end": return "flex-end";
|
|
63
|
+
case "between": return "space-between";
|
|
64
|
+
case "around": return "space-around";
|
|
65
|
+
case "evenly": return "space-evenly";
|
|
66
|
+
default: return justify;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const resolvedAlign = $derived.by(() => {
|
|
71
|
+
if (!align) return undefined;
|
|
72
|
+
switch (align) {
|
|
73
|
+
case "start": return "flex-start";
|
|
74
|
+
case "end": return "flex-end";
|
|
75
|
+
default: return align;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const resolvedWrap = $derived.by(() => {
|
|
80
|
+
if (typeof wrap === "boolean") return wrap ? "wrap" : "nowrap";
|
|
81
|
+
return wrap;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const resolvedGap = $derived(resolveSpacing(gap));
|
|
85
|
+
|
|
86
|
+
const computedStyle = $derived.by(() => {
|
|
87
|
+
const rules: string[] = [];
|
|
88
|
+
rules.push(`display: ${inline ? "inline-flex" : "flex"};`);
|
|
89
|
+
rules.push(`flex-direction: ${resolvedDirection};`);
|
|
90
|
+
if (resolvedJustify) rules.push(`justify-content: ${resolvedJustify};`);
|
|
91
|
+
if (resolvedAlign) rules.push(`align-items: ${resolvedAlign};`);
|
|
92
|
+
if (resolvedWrap) rules.push(`flex-wrap: ${resolvedWrap};`);
|
|
93
|
+
if (resolvedGap) rules.push(`gap: ${resolvedGap};`);
|
|
94
|
+
return `${rules.join(" ")} ${style}`;
|
|
95
|
+
});
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<div
|
|
99
|
+
class="plasma-flex {customClass}"
|
|
100
|
+
style={computedStyle}
|
|
101
|
+
{...restProps}
|
|
102
|
+
>
|
|
103
|
+
{@render children?.()}
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<style>
|
|
107
|
+
.plasma-flex {
|
|
108
|
+
box-sizing: border-box;
|
|
109
|
+
}
|
|
110
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
import { type PlasmaSpacing } from "./utils.js";
|
|
4
|
+
type FlexDirection = "row" | "column" | "row-reverse" | "column-reverse";
|
|
5
|
+
type FlexJustify = "start" | "end" | "center" | "between" | "around" | "evenly" | "flex-start" | "flex-end" | "space-between" | "space-around" | "space-evenly";
|
|
6
|
+
type FlexAlign = "start" | "end" | "center" | "baseline" | "stretch" | "flex-start" | "flex-end";
|
|
7
|
+
type FlexWrap = boolean | "wrap" | "nowrap" | "wrap-reverse";
|
|
8
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
vertical?: boolean;
|
|
10
|
+
direction?: FlexDirection;
|
|
11
|
+
justify?: FlexJustify;
|
|
12
|
+
align?: FlexAlign;
|
|
13
|
+
wrap?: FlexWrap;
|
|
14
|
+
gap?: PlasmaSpacing;
|
|
15
|
+
inline?: boolean;
|
|
16
|
+
children?: Snippet;
|
|
17
|
+
}
|
|
18
|
+
declare const Flex: import("svelte").Component<Props, {}, "">;
|
|
19
|
+
type Flex = ReturnType<typeof Flex>;
|
|
20
|
+
export default Flex;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
import { resolveSpacing, type PlasmaSpacing } from "./utils.js";
|
|
5
|
+
|
|
6
|
+
type GridAlign = "start" | "end" | "center" | "stretch";
|
|
7
|
+
type GridJustify = "start" | "end" | "center" | "stretch";
|
|
8
|
+
|
|
9
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
cols?: number | string;
|
|
11
|
+
rows?: number | string;
|
|
12
|
+
gap?: PlasmaSpacing;
|
|
13
|
+
rowGap?: PlasmaSpacing;
|
|
14
|
+
colGap?: PlasmaSpacing;
|
|
15
|
+
align?: GridAlign;
|
|
16
|
+
justify?: GridJustify;
|
|
17
|
+
inline?: boolean;
|
|
18
|
+
children?: Snippet;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
cols = 1,
|
|
23
|
+
rows,
|
|
24
|
+
gap = "md",
|
|
25
|
+
rowGap,
|
|
26
|
+
colGap,
|
|
27
|
+
align,
|
|
28
|
+
justify,
|
|
29
|
+
inline = false,
|
|
30
|
+
children,
|
|
31
|
+
class: customClass = "",
|
|
32
|
+
style = "",
|
|
33
|
+
...restProps
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
|
|
36
|
+
const resolvedCols = $derived.by(() => {
|
|
37
|
+
if (typeof cols === "number") return `repeat(${cols}, minmax(0, 1fr))`;
|
|
38
|
+
return cols;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const resolvedRows = $derived.by(() => {
|
|
42
|
+
if (rows === undefined) return undefined;
|
|
43
|
+
if (typeof rows === "number") return `repeat(${rows}, minmax(0, 1fr))`;
|
|
44
|
+
return rows;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const resolvedGap = $derived(resolveSpacing(gap));
|
|
48
|
+
const resolvedRowGap = $derived(resolveSpacing(rowGap));
|
|
49
|
+
const resolvedColGap = $derived(resolveSpacing(colGap));
|
|
50
|
+
|
|
51
|
+
const computedStyle = $derived.by(() => {
|
|
52
|
+
const rules: string[] = [];
|
|
53
|
+
rules.push(`display: ${inline ? "inline-grid" : "grid"};`);
|
|
54
|
+
if (resolvedCols) rules.push(`grid-template-columns: ${resolvedCols};`);
|
|
55
|
+
if (resolvedRows) rules.push(`grid-template-rows: ${resolvedRows};`);
|
|
56
|
+
if (resolvedRowGap) rules.push(`row-gap: ${resolvedRowGap};`);
|
|
57
|
+
if (resolvedColGap) rules.push(`column-gap: ${resolvedColGap};`);
|
|
58
|
+
if (!resolvedRowGap && !resolvedColGap && resolvedGap) rules.push(`gap: ${resolvedGap};`);
|
|
59
|
+
if (align) rules.push(`align-items: ${align};`);
|
|
60
|
+
if (justify) rules.push(`justify-items: ${justify};`);
|
|
61
|
+
return `${rules.join(" ")} ${style}`;
|
|
62
|
+
});
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<div
|
|
66
|
+
class="plasma-grid {customClass}"
|
|
67
|
+
style={computedStyle}
|
|
68
|
+
{...restProps}
|
|
69
|
+
>
|
|
70
|
+
{@render children?.()}
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<style>
|
|
74
|
+
.plasma-grid {
|
|
75
|
+
box-sizing: border-box;
|
|
76
|
+
width: 100%;
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
import { type PlasmaSpacing } from "./utils.js";
|
|
4
|
+
type GridAlign = "start" | "end" | "center" | "stretch";
|
|
5
|
+
type GridJustify = "start" | "end" | "center" | "stretch";
|
|
6
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
cols?: number | string;
|
|
8
|
+
rows?: number | string;
|
|
9
|
+
gap?: PlasmaSpacing;
|
|
10
|
+
rowGap?: PlasmaSpacing;
|
|
11
|
+
colGap?: PlasmaSpacing;
|
|
12
|
+
align?: GridAlign;
|
|
13
|
+
justify?: GridJustify;
|
|
14
|
+
inline?: boolean;
|
|
15
|
+
children?: Snippet;
|
|
16
|
+
}
|
|
17
|
+
declare const Grid: import("svelte").Component<Props, {}, "">;
|
|
18
|
+
type Grid = ReturnType<typeof Grid>;
|
|
19
|
+
export default Grid;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
import { resolveSpacing, type PlasmaSpacing } from "./utils.js";
|
|
5
|
+
|
|
6
|
+
type SpaceDirection = "horizontal" | "vertical";
|
|
7
|
+
type SpaceAlign = "start" | "end" | "center" | "baseline";
|
|
8
|
+
|
|
9
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
direction?: SpaceDirection;
|
|
11
|
+
size?: PlasmaSpacing;
|
|
12
|
+
align?: SpaceAlign;
|
|
13
|
+
wrap?: boolean;
|
|
14
|
+
inline?: boolean;
|
|
15
|
+
children?: Snippet;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
direction = "horizontal",
|
|
20
|
+
size = "sm",
|
|
21
|
+
align,
|
|
22
|
+
wrap = false,
|
|
23
|
+
inline = true,
|
|
24
|
+
children,
|
|
25
|
+
class: customClass = "",
|
|
26
|
+
style = "",
|
|
27
|
+
...restProps
|
|
28
|
+
}: Props = $props();
|
|
29
|
+
|
|
30
|
+
const resolvedAlign = $derived.by(() => {
|
|
31
|
+
if (align) {
|
|
32
|
+
if (align === "start") return "flex-start";
|
|
33
|
+
if (align === "end") return "flex-end";
|
|
34
|
+
return align;
|
|
35
|
+
}
|
|
36
|
+
return direction === "horizontal" ? "center" : "stretch";
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const resolvedSize = $derived(resolveSpacing(size));
|
|
40
|
+
|
|
41
|
+
const computedStyle = $derived.by(() => {
|
|
42
|
+
const rules: string[] = [];
|
|
43
|
+
rules.push(`display: ${inline ? "inline-flex" : "flex"};`);
|
|
44
|
+
rules.push(`flex-direction: ${direction === "vertical" ? "column" : "row"};`);
|
|
45
|
+
rules.push(`align-items: ${resolvedAlign};`);
|
|
46
|
+
if (wrap) rules.push("flex-wrap: wrap;");
|
|
47
|
+
if (resolvedSize) rules.push(`gap: ${resolvedSize};`);
|
|
48
|
+
return `${rules.join(" ")} ${style}`;
|
|
49
|
+
});
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<div
|
|
53
|
+
class="plasma-space {customClass}"
|
|
54
|
+
style={computedStyle}
|
|
55
|
+
{...restProps}
|
|
56
|
+
>
|
|
57
|
+
{@render children?.()}
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<style>
|
|
61
|
+
.plasma-space {
|
|
62
|
+
box-sizing: border-box;
|
|
63
|
+
}
|
|
64
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
import { type PlasmaSpacing } from "./utils.js";
|
|
4
|
+
type SpaceDirection = "horizontal" | "vertical";
|
|
5
|
+
type SpaceAlign = "start" | "end" | "center" | "baseline";
|
|
6
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
direction?: SpaceDirection;
|
|
8
|
+
size?: PlasmaSpacing;
|
|
9
|
+
align?: SpaceAlign;
|
|
10
|
+
wrap?: boolean;
|
|
11
|
+
inline?: boolean;
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
}
|
|
14
|
+
declare const Space: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type Space = ReturnType<typeof Space>;
|
|
16
|
+
export default Space;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function resolveSpacing(val) {
|
|
2
|
+
if (val === undefined)
|
|
3
|
+
return undefined;
|
|
4
|
+
if (val === "none" || val === 0)
|
|
5
|
+
return "0px";
|
|
6
|
+
if (val === "2xs" ||
|
|
7
|
+
val === "xs" ||
|
|
8
|
+
val === "sm" ||
|
|
9
|
+
val === "md" ||
|
|
10
|
+
val === "lg" ||
|
|
11
|
+
val === "xl" ||
|
|
12
|
+
val === "2xl") {
|
|
13
|
+
return `var(--plasma-space-${val})`;
|
|
14
|
+
}
|
|
15
|
+
if (typeof val === "number") {
|
|
16
|
+
return `${val}px`;
|
|
17
|
+
}
|
|
18
|
+
return val;
|
|
19
|
+
}
|