@likable-hair/svelte 3.1.24 → 3.1.25

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.
@@ -7,7 +7,7 @@ import { createEventDispatcher } from "svelte";
7
7
  import Avatar from "../../simple/media/Avatar.svelte";
8
8
  import ToolTip from "../common/ToolTip.svelte";
9
9
  let dispatch = createEventDispatcher();
10
- export let items = [], values = [], multiple = true, menuOpened = false, openingId = void 0, width = void 0, disabled = false, menuWidth = "144px";
10
+ export let items = [], values = [], multiple = true, menuOpened = false, openingId = void 0, width = void 0, minWidth = "auto", disabled = false, menuWidth = "144px";
11
11
  function handleCloseClick(params) {
12
12
  let unselected = lodash.cloneDeep(values[params.index]);
13
13
  values.splice(params.index, 1);
@@ -43,6 +43,7 @@ let tooltipsActivator = [];
43
43
  bind:menuOpened
44
44
  bind:openingId
45
45
  bind:width
46
+ bind:minWidth
46
47
  bind:disabled
47
48
  menuWidth={menuWidth}
48
49
  >
@@ -16,6 +16,7 @@ declare const __propDef: {
16
16
  menuOpened?: boolean | undefined;
17
17
  openingId?: string | undefined;
18
18
  width?: string | undefined;
19
+ minWidth?: string | undefined;
19
20
  disabled?: boolean | undefined;
20
21
  menuWidth?: string | undefined | null;
21
22
  };
@@ -6,7 +6,7 @@ import Button from "../../simple/buttons/Button.svelte";
6
6
  import Icon from "../../simple/media/Icon.svelte";
7
7
  import { createEventDispatcher } from "svelte";
8
8
  let dispatch = createEventDispatcher();
9
- export let items = [], values = [], multiple = false, lang = "en", searchText = void 0, maxVisibleChips = void 0, placeholder = lang == "en" ? "Select" : "Seleziona", clearable = true, mandatory = true, icon = void 0, menuOpened = false, openingId = void 0, width = void 0, mobileDrawer = false, disabled = false;
9
+ export let items = [], values = [], multiple = false, lang = "en", searchText = void 0, maxVisibleChips = void 0, placeholder = lang == "en" ? "Select" : "Seleziona", clearable = true, mandatory = true, icon = void 0, menuOpened = false, openingId = void 0, width = void 0, minWidth = void 0, menuWidth = width, mobileDrawer = false, disabled = false;
10
10
  $:
11
11
  generatedLabel = values.length == 1 ? values[0].label : `${values.length} Selezionati`;
12
12
  function handleCloseClick(event) {
@@ -36,6 +36,8 @@ function handleCloseClick(event) {
36
36
  bind:openingId
37
37
  bind:width
38
38
  {mobileDrawer}
39
+ bind:minWidth
40
+ bind:menuWidth
39
41
  >
40
42
  <svelte:fragment slot="selection-container" let:openMenu let:handleKeyDown>
41
43
  <Button
@@ -16,6 +16,8 @@ declare const __propDef: {
16
16
  menuOpened?: boolean | undefined;
17
17
  openingId?: string | undefined;
18
18
  width?: string | undefined;
19
+ minWidth?: string | undefined;
20
+ menuWidth?: string | undefined;
19
21
  mobileDrawer?: boolean | undefined;
20
22
  disabled?: boolean | undefined;
21
23
  };
@@ -4,7 +4,7 @@
4
4
  import Icon from "../../simple/media/Icon.svelte";
5
5
  import { createEventDispatcher } from "svelte";
6
6
  let dispatch = createEventDispatcher();
7
- export let items = [], values = [], clearable = false, disabled = false;
7
+ export let items = [], values = [], clearable = false, disabled = false, width = "auto", minWidth = "auto", menuWidth = "60px";
8
8
  let dropdownValues = [];
9
9
  $:
10
10
  dropdownValues = values.map((e) => ({
@@ -51,7 +51,9 @@ function handleChange(event) {
51
51
  bind:disabled
52
52
  bind:values={dropdownValues}
53
53
  on:change={handleChange}
54
- width="60px"
54
+ {width}
55
+ {minWidth}
56
+ {menuWidth}
55
57
  >
56
58
  <svelte:fragment slot="label" let:generatedLabel let:values let:placeholder let:clearable let:handleCloseClick>
57
59
  {#if values.length == 0}
@@ -10,6 +10,9 @@ declare const __propDef: {
10
10
  values?: IconItem[] | undefined;
11
11
  clearable?: boolean | undefined;
12
12
  disabled?: boolean | undefined;
13
+ width?: string | undefined;
14
+ minWidth?: string | undefined;
15
+ menuWidth?: string | undefined;
13
16
  };
14
17
  events: {
15
18
  change: CustomEvent<{
@@ -1,10 +1,22 @@
1
1
  <script>import "./Avatar.css";
2
2
  import "../../../css/main.css";
3
- export let src = void 0, alt = "", text = void 0, referrerpolicy = "no-referrer";
3
+ import { BROWSER } from "esm-env";
4
+ export let src = void 0, alt = "", text = void 0, referrerpolicy = "no-referrer", imageLoadingStatus = "success";
5
+ $:
6
+ if (!!src && BROWSER) {
7
+ let image = new Image();
8
+ image.src = src;
9
+ image.onload = () => {
10
+ imageLoadingStatus = "success";
11
+ };
12
+ image.onerror = () => {
13
+ imageLoadingStatus = "error";
14
+ };
15
+ }
4
16
  </script>
5
17
 
6
18
 
7
- {#if !!src}
19
+ {#if !!src && imageLoadingStatus == 'success'}
8
20
  <img
9
21
  class="avatar"
10
22
  {src}
@@ -12,7 +24,9 @@ export let src = void 0, alt = "", text = void 0, referrerpolicy = "no-referrer"
12
24
  {referrerpolicy}
13
25
  />
14
26
  {:else}
15
- <div class="avatar">{text}</div>
27
+ <slot>
28
+ <div class="avatar">{text || ''}</div>
29
+ </slot>
16
30
  {/if}
17
31
 
18
32
  <style>
@@ -7,11 +7,14 @@ declare const __propDef: {
7
7
  alt?: string | undefined;
8
8
  text?: string | undefined;
9
9
  referrerpolicy?: ReferrerPolicy | null | undefined;
10
+ imageLoadingStatus?: "error" | "success" | undefined;
10
11
  };
11
12
  events: {
12
13
  [evt: string]: CustomEvent<any>;
13
14
  };
14
- slots: {};
15
+ slots: {
16
+ default: {};
17
+ };
15
18
  };
16
19
  export type AvatarProps = typeof __propDef.props;
17
20
  export type AvatarEvents = typeof __propDef.events;
@@ -0,0 +1,6 @@
1
+ :root {
2
+ --descriptive-avatar-default-image-gap: 8px;
3
+ --descriptive-avatar-default-text-gap: 2px;
4
+ --descriptive-avatar-default-font-size: 1.1rem;
5
+ --descriptive-avatar-default-cursor: pointer;
6
+ }
@@ -1,17 +1,45 @@
1
- <script>export let src, title = void 0, description = void 0, direction = "row", reverse = false, avatarSpacing = "10px", width = void 0, maxWidth = void 0, minWidth = void 0, height = void 0, maxHeight = void 0, minHeight = void 0, lazyLoaded = false, borderRadius = "50%", referrerpolicy = "no-referrer";
2
- let textAlignment;
3
- $:
4
- if (direction == "column") {
5
- textAlignment = "center";
6
- } else if (reverse) {
7
- textAlignment = "right";
8
- } else {
9
- textAlignment = "left";
10
- }
1
+ <script>import "./DescriptiveAvatar.css";
2
+ import "../../../css/main.css";
11
3
  import Avatar from "./Avatar.svelte";
4
+ export let src = void 0, title = void 0, subtitle = void 0, avatarText = !title ? void 0 : title.substring(0, 2).toUpperCase(), direction = "row", reverse = false, referrerpolicy = "no-referrer";
12
5
  </script>
13
6
 
14
- <div
7
+ <div
8
+ class="flex image-gapped items-center clickable"
9
+ class:flex-col={direction == 'column'}
10
+ class:flex-reverse={direction == 'row' && reverse}
11
+ class:flex-col-reverse={direction == 'column' && reverse}
12
+ role="presentation"
13
+ on:click
14
+ >
15
+ <Avatar
16
+ {src}
17
+ {referrerpolicy}
18
+ bind:text={avatarText}
19
+ ></Avatar>
20
+ {#if !!title || !!subtitle}
21
+ <slot {title} {subtitle} {avatarText} {src}>
22
+ <div class="flex flex-col text-gapped">
23
+ {#if !!title}
24
+ <div
25
+ class="font-bold title"
26
+ class:text-center={direction == 'column'}
27
+ class:text-end={direction == 'row' && reverse}
28
+ >{title}</div>
29
+ {/if}
30
+ {#if !!subtitle}
31
+ <div
32
+ class="subtitle"
33
+ class:text-center={direction == 'column'}
34
+ class:text-end={direction == 'row' && reverse}
35
+ >{subtitle}</div>
36
+ {/if}
37
+ </div>
38
+ </slot>
39
+ {/if}
40
+ </div>
41
+
42
+ <!-- <div
15
43
  style:align-items="center"
16
44
  style:flex-direction={reverse ? direction + "-reverse" : direction}
17
45
  class="descriptive-avatar-container"
@@ -58,9 +86,9 @@ import Avatar from "./Avatar.svelte";
58
86
  </div>
59
87
  {/if}
60
88
  </div>
61
- </div>
89
+ </div> -->
62
90
 
63
- <style>
91
+ <!-- <style>
64
92
  .descriptive-avatar-container {
65
93
  width: fit-content;
66
94
  display: flex;
@@ -83,4 +111,66 @@ import Avatar from "./Avatar.svelte";
83
111
  font-size: 10pt;
84
112
  font-weight: 300;
85
113
  }
114
+ </style> -->
115
+
116
+ <style>
117
+ .flex {
118
+ display: flex;
119
+ }
120
+
121
+ .flex-col {
122
+ flex-direction: column;
123
+ }
124
+
125
+ .flex-reverse {
126
+ flex-direction: row-reverse;
127
+ }
128
+
129
+ .flex-col-reverse {
130
+ flex-direction: column-reverse;
131
+ }
132
+
133
+ .image-gapped {
134
+ gap: var(
135
+ --descriptive-avatar-image-gap,
136
+ var(--descriptive-avatar-default-image-gap)
137
+ )
138
+ }
139
+
140
+ .text-gapped {
141
+ gap: var(
142
+ --descriptive-avatar-text-gap,
143
+ var(--descriptive-avatar-default-text-gap)
144
+ )
145
+ }
146
+
147
+ .font-bold {
148
+ font-weight: bold;
149
+ }
150
+
151
+ .items-center {
152
+ align-items: center;
153
+ }
154
+
155
+ .text-center {
156
+ text-align: center;
157
+ }
158
+
159
+ .text-end {
160
+ text-align: end;
161
+ }
162
+
163
+ .title {
164
+ font-size: var(
165
+ --descriptive-avatar-font-size,
166
+ var(--descriptive-avatar-default-font-size)
167
+ )
168
+ }
169
+
170
+ .clickable {
171
+ cursor: var(
172
+ --descriptive-avatar-cursor,
173
+ var(--descriptive-avatar-default-cursor)
174
+ );
175
+ }
86
176
  </style>
@@ -1,30 +1,28 @@
1
1
  import { SvelteComponent } from "svelte";
2
+ import './DescriptiveAvatar.css';
3
+ import '../../../css/main.css';
2
4
  declare const __propDef: {
3
5
  props: {
4
- src: string;
6
+ src?: string | undefined;
5
7
  title?: string | undefined;
6
- description?: string | undefined;
8
+ subtitle?: string | undefined;
9
+ avatarText?: string | undefined;
7
10
  direction?: "row" | "column" | undefined;
8
11
  reverse?: boolean | undefined;
9
- avatarSpacing?: string | undefined;
10
- width?: string | undefined;
11
- maxWidth?: string | undefined;
12
- minWidth?: string | undefined;
13
- height?: string | undefined;
14
- maxHeight?: string | undefined;
15
- minHeight?: string | undefined;
16
- lazyLoaded?: boolean | undefined;
17
- borderRadius?: string | undefined;
18
12
  referrerpolicy?: ReferrerPolicy | null | undefined;
19
13
  };
20
14
  events: {
21
15
  click: MouseEvent;
22
- keypress: KeyboardEvent;
23
16
  } & {
24
17
  [evt: string]: CustomEvent<any>;
25
18
  };
26
19
  slots: {
27
- avatar: {};
20
+ default: {
21
+ title: string | undefined;
22
+ subtitle: string | undefined;
23
+ avatarText: string | undefined;
24
+ src: string | undefined;
25
+ };
28
26
  };
29
27
  };
30
28
  export type DescriptiveAvatarProps = typeof __propDef.props;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likable-hair/svelte",
3
3
  "description": "A Svelte component for likablehair and others",
4
- "version": "3.1.24",
4
+ "version": "3.1.25",
5
5
  "scripts": {
6
6
  "host": "vite --host",
7
7
  "dev": "vite dev",