@lukso/web-components 1.83.0 → 1.85.0

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.
@@ -34,6 +34,7 @@ exports.LuksoPagination = class LuksoPagination extends shared_tailwindElement_i
34
34
  this.size = "small";
35
35
  this.currentPage = 1;
36
36
  this.totalPages = 0;
37
+ this.isMobile = false;
37
38
  this.styles = index.ce({
38
39
  slots: {
39
40
  wrapper: "flex gap-2",
@@ -69,19 +70,27 @@ exports.LuksoPagination = class LuksoPagination extends shared_tailwindElement_i
69
70
  const prev = current === 1 ? null : current - 1;
70
71
  const next = current === max ? null : current + 1;
71
72
  const items = [1];
72
- if (current === 1 && max === 1)
73
+ if (current === 1 && max === 1) {
73
74
  return { current, prev, next, items };
74
- if (current > 4)
75
+ }
76
+ if (this.isMobile) {
77
+ return { current, prev, next, items: [current] };
78
+ }
79
+ if (current > 4) {
75
80
  items.push("...");
81
+ }
76
82
  const r = 2;
77
83
  const r1 = current - r;
78
84
  const r2 = current + r;
79
- for (let i = Math.max(r1, 2); i <= Math.min(max, r2); i++)
85
+ for (let i = Math.max(r1, 2); i <= Math.min(max, r2); i++) {
80
86
  items.push(i);
81
- if (r2 + 1 < max)
87
+ }
88
+ if (r2 + 1 < max) {
82
89
  items.push("...");
83
- if (r2 < max)
90
+ }
91
+ if (r2 < max) {
84
92
  items.push(max);
93
+ }
85
94
  return { current, prev, next, items };
86
95
  }
87
96
  async pageChangeEvent() {
@@ -194,6 +203,9 @@ __decorateClass([
194
203
  __decorateClass([
195
204
  queryAssignedElements.n({ type: Number, attribute: "total-pages" })
196
205
  ], exports.LuksoPagination.prototype, "totalPages", 2);
206
+ __decorateClass([
207
+ queryAssignedElements.n({ type: Boolean, attribute: "is-mobile" })
208
+ ], exports.LuksoPagination.prototype, "isMobile", 2);
197
209
  __decorateClass([
198
210
  state.t()
199
211
  ], exports.LuksoPagination.prototype, "pagination", 2);
@@ -8,6 +8,7 @@ export declare class LuksoPagination extends LuksoPagination_base {
8
8
  size: InputSize;
9
9
  currentPage: number;
10
10
  totalPages: number;
11
+ isMobile: boolean;
11
12
  private pagination;
12
13
  private styles;
13
14
  willUpdate(changedProperties: PropertyValues<this>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/lukso-pagination/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAOpE,OAAO,yBAAyB,CAAA;AAChC,OAAO,2BAA2B,CAAA;AAElC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAA;;AAS7C,qBACa,eAAgB,SAAQ,oBAA4B;IAE/D,OAAO,EAAE,aAAa,CAAY;IAGlC,IAAI,EAAE,SAAS,CAAU;IAGzB,WAAW,SAAI;IAGf,UAAU,SAAI;IAGd,OAAO,CAAC,UAAU,CAAY;IAE9B,OAAO,CAAC,MAAM,CAmBZ;IAEF,UAAU,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC;IAYlD,OAAO,CAAC,QAAQ;YAsBF,eAAe;YAaf,cAAc;YAKd,cAAc;YAKd,gBAAgB;IAK9B,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,QAAQ;IAIhB,gBAAgB;IAgBhB,gBAAgB;IAgBhB,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;IA4B7D,MAAM;CAaP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,kBAAkB,EAAE,eAAe,CAAA;KACpC;CACF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/lukso-pagination/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAOpE,OAAO,yBAAyB,CAAA;AAChC,OAAO,2BAA2B,CAAA;AAElC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAA;;AAS7C,qBACa,eAAgB,SAAQ,oBAA4B;IAE/D,OAAO,EAAE,aAAa,CAAY;IAGlC,IAAI,EAAE,SAAS,CAAU;IAGzB,WAAW,SAAI;IAGf,UAAU,SAAI;IAGd,QAAQ,UAAQ;IAGhB,OAAO,CAAC,UAAU,CAAY;IAE9B,OAAO,CAAC,MAAM,CAmBZ;IAEF,UAAU,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC;IAYlD,OAAO,CAAC,QAAQ;YAuCF,eAAe;YAaf,cAAc;YAKd,cAAc;YAKd,gBAAgB;IAK9B,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,QAAQ;IAIhB,gBAAgB;IAgBhB,gBAAgB;IAgBhB,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;IA4B7D,MAAM;CAaP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,kBAAkB,EAAE,eAAe,CAAA;KACpC;CACF"}
@@ -30,6 +30,7 @@ let LuksoPagination = class extends TailwindStyledElement(style) {
30
30
  this.size = "small";
31
31
  this.currentPage = 1;
32
32
  this.totalPages = 0;
33
+ this.isMobile = false;
33
34
  this.styles = ce({
34
35
  slots: {
35
36
  wrapper: "flex gap-2",
@@ -65,19 +66,27 @@ let LuksoPagination = class extends TailwindStyledElement(style) {
65
66
  const prev = current === 1 ? null : current - 1;
66
67
  const next = current === max ? null : current + 1;
67
68
  const items = [1];
68
- if (current === 1 && max === 1)
69
+ if (current === 1 && max === 1) {
69
70
  return { current, prev, next, items };
70
- if (current > 4)
71
+ }
72
+ if (this.isMobile) {
73
+ return { current, prev, next, items: [current] };
74
+ }
75
+ if (current > 4) {
71
76
  items.push("...");
77
+ }
72
78
  const r = 2;
73
79
  const r1 = current - r;
74
80
  const r2 = current + r;
75
- for (let i = Math.max(r1, 2); i <= Math.min(max, r2); i++)
81
+ for (let i = Math.max(r1, 2); i <= Math.min(max, r2); i++) {
76
82
  items.push(i);
77
- if (r2 + 1 < max)
83
+ }
84
+ if (r2 + 1 < max) {
78
85
  items.push("...");
79
- if (r2 < max)
86
+ }
87
+ if (r2 < max) {
80
88
  items.push(max);
89
+ }
81
90
  return { current, prev, next, items };
82
91
  }
83
92
  async pageChangeEvent() {
@@ -190,6 +199,9 @@ __decorateClass([
190
199
  __decorateClass([
191
200
  n({ type: Number, attribute: "total-pages" })
192
201
  ], LuksoPagination.prototype, "totalPages", 2);
202
+ __decorateClass([
203
+ n({ type: Boolean, attribute: "is-mobile" })
204
+ ], LuksoPagination.prototype, "isMobile", 2);
193
205
  __decorateClass([
194
206
  t()
195
207
  ], LuksoPagination.prototype, "pagination", 2);
@@ -22,4 +22,6 @@ export declare const NavButtonVariant: any;
22
22
  export declare const NavTextVariant: any;
23
23
  /** Example of link variant. */
24
24
  export declare const LinkVariant: any;
25
+ /** Example mobile pagination. */
26
+ export declare const Mobile: any;
25
27
  //# sourceMappingURL=lukso-pagination.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lukso-pagination.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/lukso-pagination/lukso-pagination.stories.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,SAAS,CAAA;AAEhB,mEAAmE;AACnE,QAAA,MAAM,IAAI,EAAE,IAuEX,CAAA;AAED,eAAe,IAAI,CAAA;AAWnB,qCAAqC;AACrC,eAAO,MAAM,OAAO,KAAoB,CAAA;AAQxC,4CAA4C;AAC5C,eAAO,MAAM,UAAU,KAAoB,CAAA;AAK3C,yCAAyC;AACzC,eAAO,MAAM,OAAO,KAAoB,CAAA;AAKxC,8BAA8B;AAC9B,eAAO,MAAM,UAAU,KAAoB,CAAA;AAK3C,kCAAkC;AAClC,eAAO,MAAM,cAAc,KAAoB,CAAA;AAK/C,kCAAkC;AAClC,eAAO,MAAM,cAAc,KAAoB,CAAA;AAK/C,+BAA+B;AAC/B,eAAO,MAAM,WAAW,KAAoB,CAAA;AAK5C,qCAAqC;AACrC,eAAO,MAAM,gBAAgB,KAAoB,CAAA;AAKjD,mCAAmC;AACnC,eAAO,MAAM,cAAc,KAAoB,CAAA;AAK/C,+BAA+B;AAC/B,eAAO,MAAM,WAAW,KAAoB,CAAA"}
1
+ {"version":3,"file":"lukso-pagination.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/lukso-pagination/lukso-pagination.stories.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,SAAS,CAAA;AAEhB,mEAAmE;AACnE,QAAA,MAAM,IAAI,EAAE,IA0FX,CAAA;AAED,eAAe,IAAI,CAAA;AAmBnB,qCAAqC;AACrC,eAAO,MAAM,OAAO,KAAoB,CAAA;AAQxC,4CAA4C;AAC5C,eAAO,MAAM,UAAU,KAAoB,CAAA;AAK3C,yCAAyC;AACzC,eAAO,MAAM,OAAO,KAAoB,CAAA;AAKxC,8BAA8B;AAC9B,eAAO,MAAM,UAAU,KAAoB,CAAA;AAK3C,kCAAkC;AAClC,eAAO,MAAM,cAAc,KAAoB,CAAA;AAK/C,kCAAkC;AAClC,eAAO,MAAM,cAAc,KAAoB,CAAA;AAK/C,+BAA+B;AAC/B,eAAO,MAAM,WAAW,KAAoB,CAAA;AAK5C,qCAAqC;AACrC,eAAO,MAAM,gBAAgB,KAAoB,CAAA;AAKjD,mCAAmC;AACnC,eAAO,MAAM,cAAc,KAAoB,CAAA;AAK/C,+BAA+B;AAC/B,eAAO,MAAM,WAAW,KAAoB,CAAA;AAK5C,iCAAiC;AACjC,eAAO,MAAM,MAAM,KAAoB,CAAA"}
@@ -12,15 +12,17 @@ require('../../bundle-mjs-d58a83c6.cjs');
12
12
  require('../../directive-8278ab14.cjs');
13
13
 
14
14
  const sliceAddress = (address, startSliceBy = 6, endSliceBy) => {
15
- if (!address) {
15
+ if (!address || typeof address !== "string") {
16
16
  return "";
17
17
  }
18
18
  let sliceAddress2 = "";
19
- endSliceBy = endSliceBy || startSliceBy;
20
- if (address.length < startSliceBy + endSliceBy) {
19
+ const effectiveEndSliceBy = endSliceBy || startSliceBy;
20
+ if (address.length < startSliceBy + effectiveEndSliceBy) {
21
21
  return address;
22
22
  }
23
- sliceAddress2 = address.length > startSliceBy + 2 ? `${address.slice(0, startSliceBy + 2)}...${address.slice(-endSliceBy)}` : address;
23
+ sliceAddress2 = address.length > startSliceBy + 2 ? `${address.slice(0, startSliceBy + 2)}...${address.slice(
24
+ -effectiveEndSliceBy
25
+ )}` : address;
24
26
  return sliceAddress2;
25
27
  };
26
28
 
@@ -8,15 +8,17 @@ import '../../bundle-mjs-fbc6e2a8.js';
8
8
  import '../../directive-2bb7789e.js';
9
9
 
10
10
  const sliceAddress = (address, startSliceBy = 6, endSliceBy) => {
11
- if (!address) {
11
+ if (!address || typeof address !== "string") {
12
12
  return "";
13
13
  }
14
14
  let sliceAddress2 = "";
15
- endSliceBy = endSliceBy || startSliceBy;
16
- if (address.length < startSliceBy + endSliceBy) {
15
+ const effectiveEndSliceBy = endSliceBy || startSliceBy;
16
+ if (address.length < startSliceBy + effectiveEndSliceBy) {
17
17
  return address;
18
18
  }
19
- sliceAddress2 = address.length > startSliceBy + 2 ? `${address.slice(0, startSliceBy + 2)}...${address.slice(-endSliceBy)}` : address;
19
+ sliceAddress2 = address.length > startSliceBy + 2 ? `${address.slice(0, startSliceBy + 2)}...${address.slice(
20
+ -effectiveEndSliceBy
21
+ )}` : address;
20
22
  return sliceAddress2;
21
23
  };
22
24
 
@@ -0,0 +1,3 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
3
+ //# sourceMappingURL=vitest.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../../vitest.config.ts"],"names":[],"mappings":";AAEA,wBAKE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lukso/web-components",
3
- "version": "1.83.0",
3
+ "version": "1.85.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=detect-social-media.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-social-media.spec.d.ts","sourceRoot":"","sources":["../../../src/shared/tools/__tests__/detect-social-media.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Detect social media from a given URL
3
+ *
4
+ * @param url
5
+ * @returns
6
+ */
7
+ export declare const detectSocialMedia: (url?: string) => string;
8
+ //# sourceMappingURL=detect-social-media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-social-media.d.ts","sourceRoot":"","sources":["../../src/shared/tools/detect-social-media.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,SAAU,MAAM,WAqB7C,CAAA"}
package/tools/index.cjs CHANGED
@@ -12,18 +12,54 @@ require('fs');
12
12
  require('path');
13
13
 
14
14
  const sliceAddress = (address, startSliceBy = 6, endSliceBy) => {
15
- if (!address) {
15
+ if (!address || typeof address !== "string") {
16
16
  return "";
17
17
  }
18
18
  let sliceAddress2 = "";
19
- endSliceBy = endSliceBy || startSliceBy;
20
- if (address.length < startSliceBy + endSliceBy) {
19
+ const effectiveEndSliceBy = endSliceBy || startSliceBy;
20
+ if (address.length < startSliceBy + effectiveEndSliceBy) {
21
21
  return address;
22
22
  }
23
- sliceAddress2 = address.length > startSliceBy + 2 ? `${address.slice(0, startSliceBy + 2)}...${address.slice(-endSliceBy)}` : address;
23
+ sliceAddress2 = address.length > startSliceBy + 2 ? `${address.slice(0, startSliceBy + 2)}...${address.slice(
24
+ -effectiveEndSliceBy
25
+ )}` : address;
24
26
  return sliceAddress2;
25
27
  };
26
28
 
29
+ const SOCIAL_MEDIA = {
30
+ facebook: ["facebook.com", "messenger.com", "fb.com", "fb.me"],
31
+ x: ["x.com", "twitter.com", "t.co"],
32
+ instagram: ["instagram.com"],
33
+ medium: ["medium.com"],
34
+ discord: ["discord.com", "discordapp.com", "discord.gg"],
35
+ snapchat: ["snapchat.com"],
36
+ whatsapp: ["whatsapp.com", "wa.me"],
37
+ telegram: ["telegram.com", "t.me", "telegram.org"],
38
+ linkedin: ["linkedin.com"],
39
+ github: ["github.com"],
40
+ "universal-page": ["universal.page"],
41
+ youtube: ["youtube.com", "youtu.be"]
42
+ };
43
+ const detectSocialMedia = (url) => {
44
+ if (!url) {
45
+ return;
46
+ }
47
+ try {
48
+ const hostname = new URL(url).hostname;
49
+ for (const [key, domains] of Object.entries(SOCIAL_MEDIA)) {
50
+ const hostnameFormatted = hostname.replace("www.", "");
51
+ const match = domains.some(
52
+ (domain) => new RegExp(`\\b${domain}\\b`, "i").test(hostnameFormatted)
53
+ );
54
+ if (match) {
55
+ return key;
56
+ }
57
+ }
58
+ } catch {
59
+ return;
60
+ }
61
+ };
62
+
27
63
  exports.borderRadius = tailwindConfig.borderRadius;
28
64
  exports.boxShadows = tailwindConfig.boxShadows;
29
65
  exports.colorPalette = tailwindConfig.colorPalette;
@@ -42,4 +78,5 @@ exports.assets = assets_index.assets;
42
78
  exports.cn = cn.cn;
43
79
  exports.fonts = assets_fonts_index.fonts;
44
80
  exports.images = assets_images_index.images;
81
+ exports.detectSocialMedia = detectSocialMedia;
45
82
  exports.sliceAddress = sliceAddress;
package/tools/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export * from './hsl-color-map';
4
4
  export * from './slice-address';
5
5
  export * from '../assets';
6
6
  export * from './cn';
7
+ export * from './detect-social-media';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/tools/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,MAAM,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/tools/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,MAAM,CAAA;AACpB,cAAc,uBAAuB,CAAA"}
package/tools/index.js CHANGED
@@ -8,16 +8,52 @@ import 'fs';
8
8
  import 'path';
9
9
 
10
10
  const sliceAddress = (address, startSliceBy = 6, endSliceBy) => {
11
- if (!address) {
11
+ if (!address || typeof address !== "string") {
12
12
  return "";
13
13
  }
14
14
  let sliceAddress2 = "";
15
- endSliceBy = endSliceBy || startSliceBy;
16
- if (address.length < startSliceBy + endSliceBy) {
15
+ const effectiveEndSliceBy = endSliceBy || startSliceBy;
16
+ if (address.length < startSliceBy + effectiveEndSliceBy) {
17
17
  return address;
18
18
  }
19
- sliceAddress2 = address.length > startSliceBy + 2 ? `${address.slice(0, startSliceBy + 2)}...${address.slice(-endSliceBy)}` : address;
19
+ sliceAddress2 = address.length > startSliceBy + 2 ? `${address.slice(0, startSliceBy + 2)}...${address.slice(
20
+ -effectiveEndSliceBy
21
+ )}` : address;
20
22
  return sliceAddress2;
21
23
  };
22
24
 
23
- export { sliceAddress };
25
+ const SOCIAL_MEDIA = {
26
+ facebook: ["facebook.com", "messenger.com", "fb.com", "fb.me"],
27
+ x: ["x.com", "twitter.com", "t.co"],
28
+ instagram: ["instagram.com"],
29
+ medium: ["medium.com"],
30
+ discord: ["discord.com", "discordapp.com", "discord.gg"],
31
+ snapchat: ["snapchat.com"],
32
+ whatsapp: ["whatsapp.com", "wa.me"],
33
+ telegram: ["telegram.com", "t.me", "telegram.org"],
34
+ linkedin: ["linkedin.com"],
35
+ github: ["github.com"],
36
+ "universal-page": ["universal.page"],
37
+ youtube: ["youtube.com", "youtu.be"]
38
+ };
39
+ const detectSocialMedia = (url) => {
40
+ if (!url) {
41
+ return;
42
+ }
43
+ try {
44
+ const hostname = new URL(url).hostname;
45
+ for (const [key, domains] of Object.entries(SOCIAL_MEDIA)) {
46
+ const hostnameFormatted = hostname.replace("www.", "");
47
+ const match = domains.some(
48
+ (domain) => new RegExp(`\\b${domain}\\b`, "i").test(hostnameFormatted)
49
+ );
50
+ if (match) {
51
+ return key;
52
+ }
53
+ }
54
+ } catch {
55
+ return;
56
+ }
57
+ };
58
+
59
+ export { detectSocialMedia, sliceAddress };
@@ -1 +1 @@
1
- {"version":3,"file":"slice-address.d.ts","sourceRoot":"","sources":["../../src/shared/tools/slice-address.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,aACb,MAAM,sCAEH,MAAM,KAClB,MAkBF,CAAA"}
1
+ {"version":3,"file":"slice-address.d.ts","sourceRoot":"","sources":["../../src/shared/tools/slice-address.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,aACb,MAAM,sCAEH,MAAM,KAClB,MAoBF,CAAA"}