@geoffcox/sterling-svelte 0.0.5 → 0.0.7

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.
@@ -0,0 +1,5 @@
1
+ declare namespace svelte.JSX {
2
+ interface DOMAttributes<T> {
3
+ onclick_outside?: (e: CustomEvent) => void;
4
+ }
5
+ }
package/index.d.ts CHANGED
@@ -7,7 +7,11 @@ export { lightTheme } from './theme/lightTheme';
7
7
  export { neutrals } from './theme/colors';
8
8
  export { toggleDarkTheme } from './theme/toggleDarkTheme';
9
9
  export { type ButtonVariant, type ButtonShape } from './buttons/types';
10
+ export { clickOutside } from './clickOutside';
10
11
  import Button from './buttons/Button.svelte';
11
12
  import Input from './inputs/Input.svelte';
13
+ import List from './lists/List.svelte';
12
14
  import Checkbox from './inputs/Checkbox.svelte';
13
- export { Button, Checkbox, Input };
15
+ import Radio from './inputs/Radio.svelte';
16
+ import Select from './inputs/Select.svelte';
17
+ export { Button, Checkbox, Input, List, Radio, Select };
package/index.js CHANGED
@@ -7,7 +7,11 @@ export { lightTheme } from './theme/lightTheme';
7
7
  export { neutrals } from './theme/colors';
8
8
  export { toggleDarkTheme } from './theme/toggleDarkTheme';
9
9
  export {} from './buttons/types';
10
+ export { clickOutside } from './clickOutside';
10
11
  import Button from './buttons/Button.svelte';
11
12
  import Input from './inputs/Input.svelte';
13
+ import List from './lists/List.svelte';
12
14
  import Checkbox from './inputs/Checkbox.svelte';
13
- export { Button, Checkbox, Input };
15
+ import Radio from './inputs/Radio.svelte';
16
+ import Select from './inputs/Select.svelte';
17
+ export { Button, Checkbox, Input, List, Radio, Select };
@@ -38,7 +38,7 @@ export let disabled = false;
38
38
  <div class="indicator" />
39
39
  </div>
40
40
  <div class="label-content" class:disabled>
41
- <slot />
41
+ <slot name="label" />
42
42
  </div>
43
43
  </label>
44
44
 
@@ -30,7 +30,7 @@ declare const __propDef: {
30
30
  [evt: string]: CustomEvent<any>;
31
31
  };
32
32
  slots: {
33
- default: {};
33
+ label: {};
34
34
  };
35
35
  };
36
36
  export type CheckboxProps = typeof __propDef.props;
@@ -1,4 +1,5 @@
1
1
  <script>export let value = "";
2
+ export let disabled = false;
2
3
  </script>
3
4
 
4
5
  <!--
@@ -8,7 +9,7 @@
8
9
  <!-- svelte-ignore a11y-label-has-associated-control -->
9
10
  {#if $$slots.label}
10
11
  <label class="sterling-input-label">
11
- <div class="label-content">
12
+ <div class="label-content" class:disabled>
12
13
  <slot name="label" />
13
14
  </div>
14
15
  <input
@@ -41,6 +42,7 @@
41
42
  on:reset
42
43
  on:wheel
43
44
  {...$$restProps}
45
+ {disabled}
44
46
  />
45
47
  </label>
46
48
  {:else}
@@ -74,6 +76,7 @@
74
76
  on:reset
75
77
  on:wheel
76
78
  {...$$restProps}
79
+ {disabled}
77
80
  />
78
81
  {/if}
79
82
 
@@ -83,10 +86,15 @@
83
86
  flex-direction: column;
84
87
  }
85
88
 
86
- .sterling-input-label > .label-content {
89
+ .label-content {
87
90
  font-size: 0.7em;
88
91
  margin: 0.5em 0 0 0.7em;
89
92
  color: var(--Display__color--subtle);
93
+ transition: background-color 250ms, color 250ms, border-color 250ms;
94
+ }
95
+
96
+ .label-content.disabled {
97
+ color: var(--Display__color--disabled);
90
98
  }
91
99
 
92
100
  .sterling-input-label,
@@ -144,6 +152,7 @@
144
152
 
145
153
  .sterling-input::placeholder {
146
154
  color: var(--Display__color--faint);
155
+ transition: background-color 250ms, color 250ms, border-color 250ms;
147
156
  }
148
157
 
149
158
  .sterling-input:disabled::placeholder {
@@ -3,6 +3,7 @@ declare const __propDef: {
3
3
  props: {
4
4
  [x: string]: any;
5
5
  value?: string | undefined;
6
+ disabled?: boolean | undefined;
6
7
  };
7
8
  events: {
8
9
  blur: FocusEvent;
@@ -1,6 +1,7 @@
1
1
  <script>import { onMount } from "svelte";
2
2
  export let checked = false;
3
3
  export let group = void 0;
4
+ export let disabled = false;
4
5
  const onChange = (e) => {
5
6
  if (e.currentTarget.checked) {
6
7
  group = $$restProps.value;
@@ -52,11 +53,12 @@ $: {
52
53
  on:wheel
53
54
  checked={group === $$restProps.value}
54
55
  {...$$restProps}
56
+ {disabled}
55
57
  />
56
58
  <div class="indicator" />
57
59
  </div>
58
- <div class="label-content">
59
- <slot />
60
+ <div class="label-content" class:disabled>
61
+ <slot name="label" />
60
62
  </div>
61
63
  </label>
62
64
 
@@ -153,6 +155,11 @@ $: {
153
155
  }
154
156
 
155
157
  .label-content {
156
- color: var(--Common__color);
158
+ color: var(--Input__color);
159
+ transition: background-color 250ms, color 250ms, border-color 250ms;
160
+ }
161
+
162
+ .label-content.disabled {
163
+ color: var(--Input__color--disabled);
157
164
  }
158
165
  </style>
@@ -4,6 +4,7 @@ declare const __propDef: {
4
4
  [x: string]: any;
5
5
  checked?: boolean | undefined;
6
6
  group?: any | undefined | null;
7
+ disabled?: boolean | undefined;
7
8
  };
8
9
  events: {
9
10
  blur: FocusEvent;
@@ -30,7 +31,7 @@ declare const __propDef: {
30
31
  [evt: string]: CustomEvent<any>;
31
32
  };
32
33
  slots: {
33
- default: {};
34
+ label: {};
34
35
  };
35
36
  };
36
37
  export type RadioProps = typeof __propDef.props;
@@ -137,8 +137,7 @@ const onPendingItemSelected = (event) => {
137
137
 
138
138
  <!--
139
139
  @component
140
- Pops up a list of items when clicked.
141
- A single item can be selected and is displayed as the value.
140
+ A single item that can be selected from a popup list of items.
142
141
  -->
143
142
  <div
144
143
  bind:this={selectRef}
@@ -178,7 +177,7 @@ A single item can be selected and is displayed as the value.
178
177
  <!-- svelte-ignore a11y-label-has-associated-control -->
179
178
  <label class="sterling-select-label">
180
179
  {#if $$slots.label}
181
- <div class="label-content">
180
+ <div class="label-content" class:disabled>
182
181
  <slot name="label" />
183
182
  </div>
184
183
  {/if}
@@ -189,7 +188,7 @@ A single item can be selected and is displayed as the value.
189
188
  </slot>
190
189
  </div>
191
190
  <div class="button">
192
- <slot name="button">
191
+ <slot name="button" {open}>
193
192
  <div class="chevron" />
194
193
  </slot>
195
194
  </div>
@@ -241,6 +240,15 @@ A single item can be selected and is displayed as the value.
241
240
  </div>
242
241
 
243
242
  <style>
243
+ /*
244
+ sterling-select
245
+ sterling-select-label
246
+ label-content
247
+ input
248
+ value
249
+ button
250
+ (popup)
251
+ */
244
252
  .sterling-select {
245
253
  background-color: var(--Input__background-color);
246
254
  border-color: var(--Input__border-color);
@@ -248,10 +256,7 @@ A single item can be selected and is displayed as the value.
248
256
  border-style: var(--Input__border-style);
249
257
  border-width: var(--Input__border-width);
250
258
  color: var(--Input__color);
251
- display: flex;
252
- flex-direction: row;
253
259
  padding: 0;
254
- position: relative;
255
260
  transition: background-color 250ms, color 250ms, border-color 250ms;
256
261
  }
257
262
 
@@ -279,21 +284,23 @@ A single item can be selected and is displayed as the value.
279
284
  outline: none;
280
285
  }
281
286
 
282
- .label {
283
- display: flex;
284
- flex-direction: column;
285
- }
286
-
287
287
  .label-content {
288
288
  font-size: 0.7em;
289
289
  margin: 0.5em 0.7em 0 0.7em;
290
290
  color: var(--Display__color--subtle);
291
+ transition: background-color 250ms, color 250ms, border-color 250ms;
292
+ }
293
+
294
+ .label-content.disabled {
295
+ color: var(--Display__color--disabled);
291
296
  }
292
297
 
293
298
  .input {
294
- display: flex;
295
- flex-direction: row;
296
- align-items: stretch;
299
+ display: grid;
300
+ grid-template-columns: 1fr auto;
301
+ grid-template-rows: auto;
302
+ align-content: center;
303
+ align-items: center;
297
304
  }
298
305
 
299
306
  .value {
@@ -341,8 +348,7 @@ A single item can be selected and is displayed as the value.
341
348
  display: none;
342
349
  overflow: hidden;
343
350
  position: absolute;
344
- box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 1px -1px, rgba(0, 0, 0, 0.14) 0px 1px 1px 0px,
345
- rgba(0, 0, 0, 0.12) 0px 1px 3px 0px;
351
+ box-shadow: rgba(0, 0, 0, 0.4) 2px 2px 4px -1px;
346
352
  width: fit-content;
347
353
  height: fit-content;
348
354
  z-index: 1;
@@ -37,7 +37,9 @@ declare const __propDef: {
37
37
  slots: {
38
38
  label: {};
39
39
  value: {};
40
- button: {};
40
+ button: {
41
+ open: boolean;
42
+ };
41
43
  list: {};
42
44
  default: {
43
45
  disabled: boolean;
@@ -50,10 +52,7 @@ declare const __propDef: {
50
52
  export type SelectProps = typeof __propDef.props;
51
53
  export type SelectEvents = typeof __propDef.events;
52
54
  export type SelectSlots = typeof __propDef.slots;
53
- /**
54
- * Pops up a list of items when clicked.
55
- * A single item can be selected and is displayed as the value.
56
- */
55
+ /** A single item that can be selected from a popup list of items. */
57
56
  export default class Select extends SvelteComponentTyped<SelectProps, SelectEvents, SelectSlots> {
58
57
  }
59
58
  export {};
package/lists/List.svelte CHANGED
@@ -93,7 +93,7 @@ A list of items where a single item can be selected.
93
93
  {#if $$slots.label}
94
94
  <!-- svelte-ignore a11y-label-has-associated-control -->
95
95
  <label class="sterling-list-label" class:horizontal class:disabled>
96
- <div class="label-content">
96
+ <div class="label-content" class:disabled>
97
97
  <slot name="label" />
98
98
  </div>
99
99
  <div
@@ -265,6 +265,7 @@ A list of items where a single item can be selected.
265
265
  cursor: not-allowed;
266
266
  }
267
267
 
268
+ /* The background, border, and outline are removed when labeled as the label provides them */
268
269
  .sterling-list.labeled,
269
270
  .sterling-list.labeled:hover,
270
271
  .sterling-list.labeled:focus-visible,
@@ -284,6 +285,13 @@ A list of items where a single item can be selected.
284
285
  font-size: 0.7em;
285
286
  margin: 0.5em 0.7em;
286
287
  color: var(--Display__color--subtle);
288
+ transition: background-color 250ms, color 250ms, border-color 250ms;
289
+ }
290
+
291
+ .label-content.disabled {
292
+ font-size: 0.7em;
293
+ margin: 0.5em 0.7em;
294
+ color: var(--Display__color--disabled);
287
295
  }
288
296
 
289
297
  .list-item {
@@ -293,7 +301,7 @@ A list of items where a single item can be selected.
293
301
  padding: 0.5em;
294
302
  outline: none;
295
303
  text-overflow: ellipsis;
296
- transition: background-color 150ms, color 150ms;
304
+ transition: background-color 250ms, color 250ms, border-color 250ms;
297
305
  white-space: nowrap;
298
306
  }
299
307
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geoffcox/sterling-svelte",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "devDependencies": {
5
5
  "@fontsource/fira-mono": "^4.5.10",
6
6
  "@fontsource/overpass": "^4.5.10",
@@ -9,6 +9,7 @@
9
9
  "@sveltejs/adapter-static": "^1.0.0",
10
10
  "@sveltejs/kit": "^1.0.0",
11
11
  "@sveltejs/package": "^1.0.0",
12
+ "@types/uuid": "^9.0.0",
12
13
  "@typescript-eslint/eslint-plugin": "^5.45.0",
13
14
  "@typescript-eslint/parser": "^5.45.0",
14
15
  "eslint": "^8.28.0",