alif-ui 1.15.1 → 1.15.3

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,7 @@
1
1
  /// <reference types="react" />
2
2
  export interface TimelineContext {
3
3
  horizontal: boolean;
4
- active: number;
4
+ active?: number | null;
5
5
  countChildren?: number;
6
6
  contentRatio?: {
7
7
  opposite?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"Timeline.context.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Timeline/Timeline.context.ts"],"names":[],"mappings":";AAEA,MAAM,WAAW,eAAe;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACF;AAED,eAAO,MAAO,uBAAuB;;;+CAAE,kBAAkB,uBAGvD,CAAC"}
1
+ {"version":3,"file":"Timeline.context.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Timeline/Timeline.context.ts"],"names":[],"mappings":";AAEA,MAAM,WAAW,eAAe;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACF;AAED,eAAO,MAAO,uBAAuB;;;+CAAE,kBAAkB,uBAGvD,CAAC"}
@@ -10,7 +10,7 @@ const x = "_root_18cyb_1", y = "_horizontal_18cyb_36", m = {
10
10
  horizontal: y
11
11
  }, o = ({
12
12
  horizontal: t = !1,
13
- active: l = 0,
13
+ active: l,
14
14
  children: n,
15
15
  contentRatio: s = { opposite: 1, main: 1 }
16
16
  }) => {
@@ -10,8 +10,10 @@ export interface TimelineProps {
10
10
  children?: ReactNode;
11
11
  /**
12
12
  * Indicates the currently active timeline step.
13
+ * Pass `null` (or any negative number) when no step is active yet —
14
+ * every item is then rendered as `inactive`.
13
15
  **/
14
- active?: number;
16
+ active?: number | null;
15
17
  /**
16
18
  * Adjusts the flex grow ratio between opposite content and content.
17
19
  * **Important**: This prop only has an effect when the timeline is vertical (horizontal = false).
@@ -1 +1 @@
1
- {"version":3,"file":"Timeline.types.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Timeline/Timeline.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,WAAW,aAAa;IAC7B;;QAEI;IACJ,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;QAEI;IACJ,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,YAAY,CAAC,EAAE;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACF;AAED,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;AACzD,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"Timeline.types.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Timeline/Timeline.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,WAAW,aAAa;IAC7B;;QAEI;IACJ,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;;;QAII;IACJ,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvB;;;OAGG;IACH,YAAY,CAAC,EAAE;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACF;AAED,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;AACzD,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC"}
@@ -2,28 +2,28 @@ import { jsxs as a, jsx as i } from "react/jsx-runtime";
2
2
  import { Children as v } from "react";
3
3
  import { classNames as o } from "../../../utils/class-names.js";
4
4
  import { s as t, T as N } from "../../../TimelineBullet-CpAQu1IW.js";
5
- import { findChildByType as c, getTimelineItemStyles as x } from "./TimelineItem.utils.js";
6
- import { useTimelineContext as g } from "../Timeline.context.js";
5
+ import { findChildByType as c, getTimelineItemStyles as g } from "./TimelineItem.utils.js";
6
+ import { useTimelineContext as x } from "../Timeline.context.js";
7
7
  import { getStatus as j, getOrder as z } from "../Timeline.utils.js";
8
8
  import { TimelineOppositeContent as A } from "../TimelineOppositeContent/TimelineOppositeContent.js";
9
9
  import { TimelineContent as B } from "../TimelineContent/TimelineContent.js";
10
- const E = ({
10
+ const F = ({
11
11
  children: p,
12
12
  bullet: d,
13
13
  tabIndex: n = 0
14
14
  }) => {
15
- const { horizontal: s, active: f, countChildren: r } = g(), h = Math.max(0, f), C = o(
15
+ const { horizontal: s, active: f, countChildren: r } = x(), C = f ?? -1, h = o(
16
16
  t.root,
17
17
  s && t.horizontal
18
18
  ), l = v.toArray(p), T = c(
19
19
  l,
20
20
  A
21
- ), y = c(l, B), e = j(h, n), m = z(n, r), u = m === "last" || r === 1;
21
+ ), y = c(l, B), e = j(C, n), m = z(n, r), u = m === "last" || r === 1;
22
22
  return /* @__PURE__ */ a(
23
23
  "li",
24
24
  {
25
- style: x(s, m),
26
- className: C,
25
+ style: g(s, m),
26
+ className: h,
27
27
  children: [
28
28
  T,
29
29
  /* @__PURE__ */ a("div", { className: t.lineContainer, children: [
@@ -49,5 +49,5 @@ const E = ({
49
49
  );
50
50
  };
51
51
  export {
52
- E as TimelineItem
52
+ F as TimelineItem
53
53
  };
@@ -6,7 +6,8 @@ declare class Localization {
6
6
  constructor();
7
7
  init(): Promise<void>;
8
8
  load(locale: string): Promise<void>;
9
- t(key: string): string;
9
+ t(key: string, params?: Record<string, string | number>): string;
10
+ private interpolate;
10
11
  }
11
12
  export declare const localization: Localization;
12
13
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"localization.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/Localization/localization.ts"],"names":[],"mappings":"AAGA,cAAM,YAAY;IAEjB,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,MAAM,CAA0B;IAExC,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,KAAK,CAAS;;IAShB,IAAI;IAMJ,IAAI,CAAC,MAAM,EAAE,MAAM;IA6BzB,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAetB;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC"}
1
+ {"version":3,"file":"localization.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/Localization/localization.ts"],"names":[],"mappings":"AAGA,cAAM,YAAY;IAEjB,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,MAAM,CAA0B;IAExC,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,KAAK,CAAS;;IAShB,IAAI;IAMJ,IAAI,CAAC,MAAM,EAAE,MAAM;IA6BzB,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM;IAkBhE,OAAO,CAAC,WAAW;CAQnB;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC"}
@@ -1,18 +1,18 @@
1
- var e = Object.defineProperty;
2
- var r = (o, t, s) => t in o ? e(o, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : o[t] = s;
3
- var i = (o, t, s) => r(o, typeof t != "symbol" ? t + "" : t, s);
4
- import { getDefaultLocale as c } from "../AlifProvider/AlifProvider.utils.js";
5
- const l = c();
6
- class h {
1
+ var a = Object.defineProperty;
2
+ var c = (e, t, s) => t in e ? a(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var o = (e, t, s) => c(e, typeof t != "symbol" ? t + "" : t, s);
4
+ import { getDefaultLocale as l } from "../AlifProvider/AlifProvider.utils.js";
5
+ const h = l();
6
+ class f {
7
7
  constructor() {
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- i(this, "translations", {});
10
- i(this, "locale", l);
9
+ o(this, "translations", {});
10
+ o(this, "locale", h);
11
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
- i(this, "cache", {});
13
- i(this, "ready", !1);
12
+ o(this, "cache", {});
13
+ o(this, "ready", !1);
14
14
  if (typeof window < "u") {
15
- const t = localStorage.getItem("alif-locale");
15
+ const t = localStorage.getItem("locale");
16
16
  t && (this.locale = t);
17
17
  }
18
18
  }
@@ -31,25 +31,28 @@ class h {
31
31
  console.error(`Failed to fetch locale ${t}: ${s.status}`), this.translations = {};
32
32
  return;
33
33
  }
34
- const a = await s.json();
35
- this.cache[t] = a, this.translations = a, this.locale = t;
34
+ const n = await s.json();
35
+ this.cache[t] = n, this.translations = n, this.locale = t;
36
36
  } catch (s) {
37
37
  console.error(`Failed to load ${t} translations`, s), this.translations = {};
38
38
  }
39
39
  }
40
40
  }
41
- t(t) {
42
- const s = t.split(".");
43
- let a = this.translations;
44
- for (const n of s)
45
- if (a && typeof a == "object" && n in a)
46
- a = a[n];
41
+ t(t, s) {
42
+ const n = t.split(".");
43
+ let i = this.translations;
44
+ for (const r of n)
45
+ if (i && typeof i == "object" && r in i)
46
+ i = i[r];
47
47
  else
48
48
  return t;
49
- return typeof a == "string" ? a : t;
49
+ return typeof i != "string" ? t : s ? this.interpolate(i, s) : i;
50
+ }
51
+ interpolate(t, s) {
52
+ return t.replace(/\{\{\s*(\w+)\s*\}\}/g, (n, i) => i in s ? String(s[i]) : n);
50
53
  }
51
54
  }
52
- const u = new h();
55
+ const p = new f();
53
56
  export {
54
- u as localization
57
+ p as localization
55
58
  };
@@ -1,6 +1,6 @@
1
1
  import { Locale } from '../../AlifProvider/AlifProvider.types';
2
2
  export declare const useTranslation: () => {
3
- t: (key: string) => string;
3
+ t: (key: string, params?: Record<string, string | number>) => string;
4
4
  language: Locale;
5
5
  changeLanguage: (nextLocale: Locale | ((prev: Locale) => Locale)) => Promise<void>;
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useTranslation.d.ts","sourceRoot":"","sources":["../../../../src/lib/providers/Localization/useTranslation/useTranslation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,eAAO,MAAM,cAAc;aAaV,MAAM;;kDATQ,MAAM,KAAK,MAAM;CAW/C,CAAC"}
1
+ {"version":3,"file":"useTranslation.d.ts","sourceRoot":"","sources":["../../../../src/lib/providers/Localization/useTranslation/useTranslation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,eAAO,MAAM,cAAc;aAaV,MAAM,WAAW,OAAO,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;;kDATlC,MAAM,KAAK,MAAM;CAY/C,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { useAlifProviderContext as c } from "../../AlifProvider/AlifProvider.context.js";
2
2
  import { localization as n } from "../localization.js";
3
3
  const g = () => {
4
- const { locale: t, setLocale: e } = c();
5
- return { t: (o) => n.t(o), language: t, changeLanguage: async (o) => {
6
- const a = typeof o == "function" ? o(t) : o;
7
- await n.load(a), e(a);
4
+ const { locale: a, setLocale: e } = c();
5
+ return { t: (o, t) => n.t(o, t), language: a, changeLanguage: async (o) => {
6
+ const t = typeof o == "function" ? o(a) : o;
7
+ await n.load(t), e(t);
8
8
  } };
9
9
  };
10
10
  export {
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "license": "ISC",
23
23
  "private": false,
24
- "version": "1.15.1",
24
+ "version": "1.15.3",
25
25
  "type": "module",
26
26
  "files": [
27
27
  "dist"
@@ -49,7 +49,6 @@
49
49
  "stylelint": "stylelint \"**/*.css\" --fix",
50
50
  "eslint": "eslint --ext .ts,.tsx --fix",
51
51
  "format": "prettier --no-error-on-unmatched-pattern --write **/*.{jsx,ts,tsx}",
52
- "prepare": "husky",
53
52
  "test": "jest --config config/jest/jestconfig.json",
54
53
  "storybook": "storybook dev -p 6006",
55
54
  "build-storybook": "storybook build"