@likable-hair/svelte 3.1.23 → 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
  };
@@ -11,7 +11,7 @@ import Dialog from "../../simple/dialogs/Dialog.svelte";
11
11
  let clazz = {};
12
12
  export { clazz as class };
13
13
  let dispatch = createEventDispatcher();
14
- export let menuOpened = false, openingId = "date-picker-text-field", pattern = "dd/MM/yyyy", selectedMonth = void 0, selectedYear = void 0, visibleMonth = void 0, visibleYear = void 0, selectedDate = void 0, placeholder = void 0, mobileDialog = true, maxYearInRange = 2100, minYearInRange = 1970, disabled = false;
14
+ export let menuOpened = false, openingId = "date-picker-text-field", pattern = "dd/MM/yyyy", selectedMonth = void 0, selectedYear = void 0, visibleMonth = void 0, visibleYear = void 0, selectedDate = void 0, placeholder = void 0, mobileDialog = true, maxYearInRange = 2100, minYearInRange = 1970, disabled = false, flipOnOverflow = true;
15
15
  let activator, refreshPosition = false, menuElement, inputElement, mask = {
16
16
  value: void 0
17
17
  }, maskFactoryArgs = {
@@ -211,6 +211,7 @@ $:
211
211
  bind:refreshPosition
212
212
  bind:menuElement
213
213
  bind:openingId={openingId}
214
+ flipOnOverflow={flipOnOverflow}
214
215
  >
215
216
  <div
216
217
  style:background-color="rgb(var(--global-color-background-100))"
@@ -21,6 +21,7 @@ declare const __propDef: {
21
21
  maxYearInRange?: number | undefined;
22
22
  minYearInRange?: number | undefined;
23
23
  disabled?: boolean | undefined;
24
+ flipOnOverflow?: boolean | undefined;
24
25
  };
25
26
  events: {
26
27
  'day-click': CustomEvent<{
@@ -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<{
@@ -124,6 +124,7 @@ $:
124
124
  bind:menuOpened={calendarOpened}
125
125
  on:day-click={() => {calendarOpened = false}}
126
126
  --simple-textfield-width="100%"
127
+ flipOnOverflow
127
128
  >
128
129
  <svelte:fragment slot="append-inner">
129
130
  <Icon
@@ -202,6 +203,7 @@ $:
202
203
  bind:menuOpened={calendarOpened2}
203
204
  on:day-click={() => {calendarOpened2 = false}}
204
205
  --simple-textfield-width="100%"
206
+ flipOnOverflow
205
207
  >
206
208
  <svelte:fragment slot="append-inner">
207
209
  <Icon
@@ -296,7 +296,7 @@ let moreItemsActivator;
296
296
 
297
297
  <MediaQuery let:mAndDown>
298
298
  <div class="filters-wrapper" class:mobile={mAndDown} style:--filter-dot-size={activeFilters.length > 0 ? '22px' : '0px'} style:--filter-dot-content={activeFilters.length > 0 ? `"${activeFilters.length}"` : '""'}>
299
- <div class="filters-container" class:mobile={mAndDown}>
299
+ <div class="filters-container" class:mobile={mAndDown} class:hidden={mAndDown && (!showActiveFilters || activeFilters.length == 0)}>
300
300
  {#if showActiveFilters}
301
301
  {#each activeFilters as filter}
302
302
  <div
@@ -587,6 +587,7 @@ let moreItemsActivator;
587
587
  _borderRadius="5px"
588
588
  anchor="bottom"
589
589
  openingId="select-filter"
590
+ flipOnOverflow
590
591
  >
591
592
  <div
592
593
  style:background-color="rgb(var(--global-color-background-200))"
@@ -917,4 +918,8 @@ let moreItemsActivator;
917
918
  grid-column: span 2;
918
919
  }
919
920
 
921
+ .hidden {
922
+ display: none;
923
+ }
924
+
920
925
  </style>
@@ -59,9 +59,9 @@ function calculateMenuPosition(params) {
59
59
  }
60
60
  }
61
61
  if (flipOnOverflow && !!params.activator) {
62
- if (window.innerHeight + window.scrollY < (_top || 0) + (menuElement?.offsetHeight || 0)) {
63
- let { top: activatorTop } = params.activator.getBoundingClientRect();
64
- _top = activatorTop + window.scrollY - _activatorGap - (menuElement?.offsetHeight || 0);
62
+ let { top: activatorTopDistance } = params.activator.getBoundingClientRect();
63
+ if (window.innerHeight < activatorTopDistance + (menuElement?.offsetHeight || 0) + (menuElement?.offsetHeight || 0) * 0.1) {
64
+ _top = getTopDistance(params.activator) - _activatorGap - (menuElement?.offsetHeight || 0);
65
65
  }
66
66
  if (anchor == "right-center" && window.innerWidth + window.scrollX < (_left || 0) + (menuElement?.offsetWidth || 0)) {
67
67
  let { left: activatorLeft } = params.activator.getBoundingClientRect();
@@ -94,8 +94,38 @@ function calculateMenuPosition(params) {
94
94
  }
95
95
  }
96
96
  }
97
+ function getTopDistance(elem) {
98
+ let positionedAncestor2 = getPositionedAncestor(elem);
99
+ if (!!positionedAncestor2) {
100
+ let top = parseInt(getComputedStyle(positionedAncestor2).top);
101
+ return (isNaN(top) ? 0 : top) + elem.offsetTop - calcScrollY(elem);
102
+ }
103
+ return window.scrollY + elem.getBoundingClientRect().top;
104
+ }
105
+ function calcScrollY(elem) {
106
+ let parent = elem.parentElement;
107
+ let scroll = 0;
108
+ while (!!parent) {
109
+ scroll += parent.scrollTop;
110
+ let parentPosition = getComputedStyle(parent).position;
111
+ if (parentPosition === "absolute" || parentPosition === "fixed")
112
+ break;
113
+ parent = parent.parentElement;
114
+ }
115
+ return scroll;
116
+ }
97
117
  $:
98
118
  if (open) {
119
+ if (!!activator) {
120
+ let parent = activator.parentElement;
121
+ while (!!parent) {
122
+ let parentPosition = getComputedStyle(parent).position;
123
+ parent.addEventListener("scroll", refreshMenuPosition);
124
+ if (parentPosition == "absolute" || parentPosition == "fixed")
125
+ break;
126
+ parent = parent.parentElement;
127
+ }
128
+ }
99
129
  if (!!openingId) {
100
130
  const controllers = document.querySelectorAll(`[data-operation="close"][data-opening-id="${openingId}"]`);
101
131
  for (let k = 0; k < controllers.length; k += 1) {
@@ -251,6 +281,7 @@ $:
251
281
  ></div>
252
282
  {#if open}
253
283
  <div
284
+ role="presentation"
254
285
  bind:this={menuElement}
255
286
  data-menu
256
287
  data-uid={currentUid}
@@ -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.23",
4
+ "version": "3.1.25",
5
5
  "scripts": {
6
6
  "host": "vite --host",
7
7
  "dev": "vite dev",