@hyvor/design 0.0.62 → 0.0.63

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.
@@ -1,7 +1,10 @@
1
1
  <script>import { setContext } from "svelte";
2
2
  export let selection = "none";
3
+ export let selectionAlign = "start";
3
4
  $:
4
5
  setContext("action-list-selection", selection);
6
+ $:
7
+ setContext("action-list-selection-align", selectionAlign);
5
8
  </script>
6
9
 
7
10
 
@@ -3,6 +3,7 @@ declare const __propDef: {
3
3
  props: {
4
4
  [x: string]: any;
5
5
  selection?: "none" | "single" | "multi" | undefined;
6
+ selectionAlign?: "start" | "end" | undefined;
6
7
  };
7
8
  events: {
8
9
  [evt: string]: CustomEvent<any>;
@@ -1,7 +1,9 @@
1
1
  <script>import { getContext, createEventDispatcher } from "svelte";
2
2
  import Checkbox from "../Checkbox/Checkbox.svelte";
3
3
  import { IconCheck } from "@hyvor/icons";
4
+ import Selected from "./Selected.svelte";
4
5
  const selection = getContext("action-list-selection");
6
+ const selectionAlign = getContext("action-list-selection-align");
5
7
  export let selected = false;
6
8
  selected = selection !== "none" && selected;
7
9
  export let disabled = false;
@@ -29,19 +31,8 @@ function handleClick() {
29
31
  on:click
30
32
  >
31
33
 
32
- {#if selection !== 'none'}
33
- <span class="selected">
34
- {#if selection === 'multi'}
35
- <span style="transform:scale(0.9);transform-origin:top">
36
- <Checkbox checked={selected}
37
- tabindex="-1" />
38
- </span>
39
- {:else}
40
- {#if selected}
41
- <IconCheck />
42
- {/if}
43
- {/if}
44
- </span>
34
+ {#if selectionAlign === 'start'}
35
+ <Selected {selection} bind:selected />
45
36
  {/if}
46
37
 
47
38
  {#if $$slots.start}
@@ -66,6 +57,10 @@ function handleClick() {
66
57
  </span>
67
58
  {/if}
68
59
 
60
+ {#if selectionAlign === 'end'}
61
+ <Selected {selection} bind:selected />
62
+ {/if}
63
+
69
64
  </div>
70
65
 
71
66
  <style>
@@ -88,14 +83,6 @@ function handleClick() {
88
83
  background-color: #fffafa;
89
84
  }
90
85
 
91
- .selected {
92
- width: 30px;
93
- display: inline-flex;
94
- align-items: center;
95
- justify-content: center;
96
- pointer-events: none;
97
- }
98
-
99
86
  .start, .middle, .end {
100
87
  display: inline-flex;
101
88
  align-items: center;
@@ -0,0 +1,30 @@
1
+ <script>import Checkbox from "../Checkbox/Checkbox.svelte";
2
+ import { IconCheck } from "@hyvor/icons";
3
+ export let selection;
4
+ export let selected;
5
+ </script>
6
+
7
+ {#if selection !== 'none'}
8
+ <span class="selected">
9
+ {#if selection === 'multi'}
10
+ <span style="transform:scale(0.9);transform-origin:top">
11
+ <Checkbox checked={selected}
12
+ tabindex="-1" />
13
+ </span>
14
+ {:else}
15
+ {#if selected}
16
+ <IconCheck />
17
+ {/if}
18
+ {/if}
19
+ </span>
20
+ {/if}
21
+
22
+ <style>
23
+ .selected {
24
+ width: 30px;
25
+ display: inline-flex;
26
+ align-items: center;
27
+ justify-content: center;
28
+ pointer-events: none;
29
+ }
30
+ </style>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ selection: 'none' | 'single' | 'multi';
5
+ selected: boolean;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type SelectedProps = typeof __propDef.props;
13
+ export type SelectedEvents = typeof __propDef.events;
14
+ export type SelectedSlots = typeof __propDef.slots;
15
+ export default class Selected extends SvelteComponent<SelectedProps, SelectedEvents, SelectedSlots> {
16
+ }
17
+ export {};
@@ -53,17 +53,24 @@ export let button = {};
53
53
 
54
54
  </svelte:element>
55
55
 
56
+
56
57
  <style>.slot.start {
57
58
  margin-right: 6px;
58
59
  display: inline-flex;
59
60
  align-items: center;
60
61
  }
62
+ .slot.start:empty {
63
+ margin-right: 0;
64
+ }
61
65
 
62
66
  .slot.end {
63
67
  margin-left: 6px;
64
68
  display: inline-flex;
65
69
  align-items: center;
66
70
  }
71
+ .slot.end:empty {
72
+ margin-left: 0;
73
+ }
67
74
 
68
75
  .button {
69
76
  position: relative;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyvor/design",
3
- "version": "0.0.62",
3
+ "version": "0.0.63",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "scripts": {