@kingteza/crud-component 1.35.0 → 1.36.1

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 +1 @@
1
- "use strict";const c=require("react/jsx-runtime"),w=require("antd"),o=require("react"),F=require("../appearance/Hider.cjs.js"),{Step:R}=w.Steps,y=o.forwardRef(({pages:d,onSubmit:u,initPosition:f=0,progressDot:v,type:b,labelPlacement:g,className:k,pageStyle:q},C)=>{const[s,i]=o.useState(0),[r,p]=o.useState([]);o.useEffect(()=>{i(f)},[f]),o.useImperativeHandle(C,()=>({gotTo:t=>i(t)}),[]);const m=o.useCallback((t,a=!1,l=!1)=>{const e=[...r];if(t!==void 0&&(e[s]=t,p(e)),l||i(s+1),a&&u){const n={};for(const x of e)for(const S in x)n[S]=x[S];u(e,n)}},[s,r,u]),h=o.useCallback(()=>{const t=[...r];t[s]=void 0,p(t),i(s-1)},[s,r]),j=o.useMemo(()=>{const t=[],a=[],l=d.filter(e=>!e.hidden);for(let e=0;e<l.length;e++){const n=l[e];a.push(c.jsx(F,{hide:s!==e,children:n.component({forward:m,backward:h},r,s===e)},`${n.title}${e}`)),t.push(c.jsx(R,{icon:n.icon,title:n.title},n.title))}return{_pages:a,steps:t}},[h,s,r,m,d]);return c.jsxs(c.Fragment,{children:[c.jsx(w.Steps,{labelPlacement:g,progressDot:v,className:[k,"pb-3"].join(" "),current:s,type:b,children:j.steps}),c.jsx("div",{style:q,children:j._pages})]})});module.exports=y;
1
+ "use strict";const c=require("react/jsx-runtime"),R=require("antd"),n=require("react"),y=require("../appearance/Hider.cjs.js"),H=n.forwardRef(({pages:d,onSubmit:u,initPosition:f=0,type:w,labelPlacement:p,className:x,pageStyle:C,showSteps:k=!0,freeNavigation:S},q)=>{const[t,i]=n.useState(0),[r,m]=n.useState([]);n.useEffect(()=>{i(f)},[f]),n.useImperativeHandle(q,()=>({gotTo:s=>i(s)}),[]);const h=n.useCallback((s,a=!1,l=!1)=>{const e=[...r];if(s!==void 0&&(e[t]=s,m(e)),l||i(t+1),a&&u){let o={};for(const j of e)for(const v in j)o[v]=j[v];u(e,o)}},[t,r,u]),b=n.useCallback(()=>{const s=[...r];s[t]=void 0,m(s),i(t-1)},[t,r]),g=n.useMemo(()=>{let s=[],a=[];const l=d.filter(e=>!e.hidden);for(let e=0;e<l.length;e++){const o=l[e];a.push(c.jsx(y,{hide:t!==e,children:o.component({forward:h,backward:b},r,t===e)},`${o.title}${e}`)),s.push({icon:o.icon,title:o.title,disabled:o.disabled})}return{_pages:a,steps:s}},[b,t,r,h,d]),F=n.useCallback(s=>{i(s)},[]);return c.jsxs(c.Fragment,{children:[k&&c.jsx(R.Steps,{labelPlacement:p,titlePlacement:p,className:[x,"pb-3"].join(" "),current:t,type:w,items:g.steps,onChange:S?F:void 0}),c.jsx("div",{style:C,children:g._pages})]})});module.exports=H;
@@ -1,7 +1,9 @@
1
+ import { StepsProps } from 'antd/lib';
1
2
  import { default as React, ReactElement } from 'react';
2
3
  interface WizardViewFormProps {
3
4
  pages: {
4
5
  hidden?: boolean;
6
+ disabled?: boolean;
5
7
  icon?: React.ReactNode;
6
8
  title: string;
7
9
  component: (func: {
@@ -9,13 +11,14 @@ interface WizardViewFormProps {
9
11
  backward: () => void;
10
12
  }, formSubmissionData: any[], isActive: boolean) => ReactElement;
11
13
  }[];
12
- labelPlacement?: "vertical" | "horizontal";
14
+ labelPlacement?: 'vertical' | 'horizontal';
13
15
  initPosition?: number;
14
16
  onSubmit?: (val: (any | undefined)[], combinedValue: any) => void;
15
- type?: "default" | "navigation" | "inline";
17
+ type?: StepsProps['type'];
16
18
  className?: string;
17
- progressDot?: boolean;
18
19
  pageStyle?: React.CSSProperties;
20
+ showSteps?: boolean;
21
+ freeNavigation?: boolean;
19
22
  }
20
23
  export interface WizardViewFormRef {
21
24
  gotTo: (index: number) => void;
@@ -1,74 +1,81 @@
1
- import { jsx as f, jsxs as H, Fragment as _ } from "react/jsx-runtime";
2
- import { Steps as b } from "antd";
3
- import { forwardRef as $, useState as S, useEffect as z, useImperativeHandle as E, useCallback as g, useMemo as I } from "react";
4
- import M from "../appearance/Hider.es.js";
5
- const { Step: N } = b, q = $(
1
+ import { jsx as a, jsxs as _, Fragment as $ } from "react/jsx-runtime";
2
+ import { Steps as z } from "antd";
3
+ import { forwardRef as E, useState as C, useEffect as I, useImperativeHandle as M, useCallback as d, useMemo as N } from "react";
4
+ import R from "../appearance/Hider.es.js";
5
+ const A = E(
6
6
  ({
7
- pages: a,
7
+ pages: f,
8
8
  onSubmit: l,
9
- initPosition: d = 0,
10
- progressDot: j,
11
- type: k,
12
- labelPlacement: x,
13
- className: F,
14
- pageStyle: y
15
- }, C) => {
16
- const [t, n] = S(0), [r, m] = S(
17
- []
18
- );
19
- z(() => {
20
- n(d);
21
- }, [d]), E(
22
- C,
9
+ initPosition: m = 0,
10
+ type: S,
11
+ labelPlacement: p,
12
+ className: j,
13
+ pageStyle: k,
14
+ showSteps: x = !0,
15
+ freeNavigation: F
16
+ }, y) => {
17
+ const [s, n] = C(0), [r, u] = C([]);
18
+ I(() => {
19
+ n(m);
20
+ }, [m]), M(
21
+ y,
23
22
  () => ({
24
- gotTo: (s) => n(s)
23
+ gotTo: (t) => n(t)
25
24
  }),
26
25
  []
27
26
  );
28
- const p = g(
29
- (s, c = !1, i = !1) => {
27
+ const h = d(
28
+ (t, i = !1, c = !1) => {
30
29
  const e = [...r];
31
- if (s !== void 0 && (e[t] = s, m(e)), i || n(t + 1), c && l) {
32
- const o = {};
30
+ if (t !== void 0 && (e[s] = t, u(e)), c || n(s + 1), i && l) {
31
+ let o = {};
33
32
  for (const w of e)
34
- for (const v in w)
35
- o[v] = w[v];
33
+ for (const b in w)
34
+ o[b] = w[b];
36
35
  l(e, o);
37
36
  }
38
37
  },
39
- [t, r, l]
40
- ), u = g(() => {
41
- const s = [...r];
42
- s[t] = void 0, m(s), n(t - 1);
43
- }, [t, r]), h = I(() => {
44
- const s = [], c = [], i = a.filter((e) => !e.hidden);
45
- for (let e = 0; e < i.length; e++) {
46
- const o = i[e];
47
- c.push(
48
- /* @__PURE__ */ f(M, { hide: t !== e, children: o.component({ forward: p, backward: u }, r, t === e) }, `${o.title}${e}`)
49
- ), s.push(/* @__PURE__ */ f(N, { icon: o.icon, title: o.title }, o.title));
38
+ [s, r, l]
39
+ ), g = d(() => {
40
+ const t = [...r];
41
+ t[s] = void 0, u(t), n(s - 1);
42
+ }, [s, r]), v = N(() => {
43
+ let t = [], i = [];
44
+ const c = f.filter((e) => !e.hidden);
45
+ for (let e = 0; e < c.length; e++) {
46
+ const o = c[e];
47
+ i.push(
48
+ /* @__PURE__ */ a(R, { hide: s !== e, children: o.component({ forward: h, backward: g }, r, s === e) }, `${o.title}${e}`)
49
+ ), t.push({
50
+ icon: o.icon,
51
+ title: o.title,
52
+ disabled: o.disabled
53
+ });
50
54
  }
51
55
  return {
52
- _pages: c,
53
- steps: s
56
+ _pages: i,
57
+ steps: t
54
58
  };
55
- }, [u, t, r, p, a]);
56
- return /* @__PURE__ */ H(_, { children: [
57
- /* @__PURE__ */ f(
58
- b,
59
+ }, [g, s, r, h, f]), H = d((t) => {
60
+ n(t);
61
+ }, []);
62
+ return /* @__PURE__ */ _($, { children: [
63
+ x && /* @__PURE__ */ a(
64
+ z,
59
65
  {
60
- labelPlacement: x,
61
- progressDot: j,
62
- className: [F, "pb-3"].join(" "),
63
- current: t,
64
- type: k,
65
- children: h.steps
66
+ labelPlacement: p,
67
+ titlePlacement: p,
68
+ className: [j, "pb-3"].join(" "),
69
+ current: s,
70
+ type: S,
71
+ items: v.steps,
72
+ onChange: F ? H : void 0
66
73
  }
67
74
  ),
68
- /* @__PURE__ */ f("div", { style: y, children: h._pages })
75
+ /* @__PURE__ */ a("div", { style: k, children: v._pages })
69
76
  ] });
70
77
  }
71
78
  );
72
79
  export {
73
- q as default
80
+ A as default
74
81
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./hooks/translation-constants.cjs.js"),d=require("./translations/en.cjs.js"),r=require("i18next"),o=require("react-i18next"),c={en:{[a.TRANSLATION_NAMESPACE]:d}};exports.i18nInstance=r;const u=(t={})=>{const{translations:n=c,language:e="en",i18nInstance:i}=t,s=i||r;return exports.i18nInstance=s,s.isInitialized?Object.entries(n).forEach(([T,N])=>{Object.entries(N).forEach(([A,I])=>{s.addResourceBundle(T,A,I,!0,!0)})}):s.use(o.initReactI18next).init({resources:n,lng:e,fallbackLng:"en",ns:a.TRANSLATION_NAMESPACE,interpolation:{escapeValue:!1}}),s},S=(t,n,e)=>{(e||r).addResourceBundle(t,a.TRANSLATION_NAMESPACE,n,!0,!0)},E=t=>{const n=exports.i18nInstance||r;return n.isInitialized||u({}),o.useTranslation(a.TRANSLATION_NAMESPACE,{...t,i18n:n})},f=t=>{const n=exports.i18nInstance||r;return n.isInitialized||u({}),o.useTranslation(void 0,{...t,i18n:n})},l=(t,n)=>{var e;return(e=exports.i18nInstance)==null?void 0:e.t(t,{ns:a.TRANSLATION_NAMESPACE,...n})},L=(t,n,e)=>{var s;const i=l(t,n);return i&&t&&i!==t?i:e||((s=exports.i18nInstance)==null?void 0:s.t(t,{ns:void 0,...n}))};exports.defaultTranslations=c;exports.setupI18n=u;exports.t=l;exports.tWithOrWithoutNS=L;exports.updateTranslations=S;exports.useTranslationLib=E;exports.useTranslationLibNoNS=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./hooks/translation-constants.cjs.js"),A=require("./translations/en.cjs.js"),r=require("i18next"),u=require("react-i18next"),l={en:{[a.TRANSLATION_NAMESPACE]:A}};exports.i18nInstance=r;const c=(t={})=>{const{translations:n=l,language:e="en",i18nInstance:i}=t,s=i||r;return exports.i18nInstance=s,s.isInitialized?Object.entries(n).forEach(([o,T])=>{Object.entries(T).forEach(([I,N])=>{s.addResourceBundle(o,I,N,!0,!0)})}):s.use(u.initReactI18next).init({resources:n,lng:e,fallbackLng:"en",ns:a.TRANSLATION_NAMESPACE,interpolation:{escapeValue:!1}}),s},d=(t,n,e)=>{(e||r).addResourceBundle(t,a.TRANSLATION_NAMESPACE,n,!0,!0)},S=t=>{const n=exports.i18nInstance||r;return n.isInitialized||c({}),u.useTranslation(a.TRANSLATION_NAMESPACE,{...t,i18n:n})},E=t=>{const n=exports.i18nInstance||r;return n.isInitialized||c({}),u.useTranslation(void 0,{...t,i18n:n})},f=(t,n)=>{var e;return(e=exports.i18nInstance)==null?void 0:e.t(t,{ns:a.TRANSLATION_NAMESPACE,...n})},L=(t,n,e)=>{var s,o;const i=(s=exports.i18nInstance)==null?void 0:s.t(t,n);return i&&t&&i!==t?i:e||((o=exports.i18nInstance)==null?void 0:o.t(t,{ns:void 0,...n}))};exports.defaultTranslations=l;exports.setupI18n=c;exports.t=f;exports.tWithOrWithoutNS=L;exports.updateTranslations=d;exports.useTranslationLib=S;exports.useTranslationLibNoNS=E;
@@ -8,18 +8,18 @@ const N = {
8
8
  }
9
9
  };
10
10
  let e = a;
11
- const c = (t = {}) => {
11
+ const c = (n = {}) => {
12
12
  const {
13
- translations: n = N,
13
+ translations: t = N,
14
14
  language: i = "en",
15
15
  i18nInstance: s
16
- } = t, r = s || a;
17
- return e = r, r.isInitialized ? Object.entries(n).forEach(([l, d]) => {
16
+ } = n, r = s || a;
17
+ return e = r, r.isInitialized ? Object.entries(t).forEach(([l, d]) => {
18
18
  Object.entries(d).forEach(([f, T]) => {
19
19
  r.addResourceBundle(l, f, T, !0, !0);
20
20
  });
21
21
  }) : r.use(p).init({
22
- resources: n,
22
+ resources: t,
23
23
  lng: i,
24
24
  fallbackLng: "en",
25
25
  ns: o,
@@ -27,36 +27,36 @@ const c = (t = {}) => {
27
27
  escapeValue: !1
28
28
  }
29
29
  }), r;
30
- }, E = (t, n, i) => {
30
+ }, E = (n, t, i) => {
31
31
  (i || a).addResourceBundle(
32
- t,
33
- o,
34
32
  n,
33
+ o,
34
+ t,
35
35
  !0,
36
36
  !0
37
37
  );
38
- }, L = (t) => {
39
- const n = e || a;
40
- return n.isInitialized || c({}), u(o, { ...t, i18n: n });
41
- }, O = (t) => {
42
- const n = e || a;
43
- return n.isInitialized || c({}), u(void 0, { ...t, i18n: n });
44
- }, I = (t, n) => e == null ? void 0 : e.t(t, {
38
+ }, L = (n) => {
39
+ const t = e || a;
40
+ return t.isInitialized || c({}), u(o, { ...n, i18n: t });
41
+ }, O = (n) => {
42
+ const t = e || a;
43
+ return t.isInitialized || c({}), u(void 0, { ...n, i18n: t });
44
+ }, R = (n, t) => e == null ? void 0 : e.t(n, {
45
45
  ns: o,
46
- ...n
47
- }), R = (t, n, i) => {
48
- const s = I(t, n);
49
- return s && t && s !== t ? s : i || (e == null ? void 0 : e.t(t, {
46
+ ...t
47
+ }), S = (n, t, i) => {
48
+ const s = e == null ? void 0 : e.t(n, t);
49
+ return s && n && s !== n ? s : i || (e == null ? void 0 : e.t(n, {
50
50
  ns: void 0,
51
- ...n
51
+ ...t
52
52
  }));
53
53
  };
54
54
  export {
55
55
  N as defaultTranslations,
56
56
  e as i18nInstance,
57
57
  c as setupI18n,
58
- I as t,
59
- R as tWithOrWithoutNS,
58
+ R as t,
59
+ S as tWithOrWithoutNS,
60
60
  E as updateTranslations,
61
61
  L as useTranslationLib,
62
62
  O as useTranslationLibNoNS
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.35.0",
4
+ "version": "1.36.1",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",