@teamco/ischeduler-core 2.0.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.
Files changed (36) hide show
  1. package/dist/handlers/day.handler.d.ts +3 -0
  2. package/dist/handlers/day.handler.d.ts.map +1 -0
  3. package/dist/handlers/month.handler.d.ts +3 -0
  4. package/dist/handlers/month.handler.d.ts.map +1 -0
  5. package/dist/handlers/week.handler.d.ts +3 -0
  6. package/dist/handlers/week.handler.d.ts.map +1 -0
  7. package/dist/handlers/year.handler.d.ts +3 -0
  8. package/dist/handlers/year.handler.d.ts.map +1 -0
  9. package/dist/handlers.d.ts +35 -0
  10. package/dist/handlers.d.ts.map +1 -0
  11. package/dist/hooks/useColumnsToggle.d.ts +23 -0
  12. package/dist/hooks/useColumnsToggle.d.ts.map +1 -0
  13. package/dist/i18n/index.d.ts +5 -0
  14. package/dist/i18n/index.d.ts.map +1 -0
  15. package/dist/i18n/locales/en-US.d.ts +4 -0
  16. package/dist/i18n/locales/en-US.d.ts.map +1 -0
  17. package/dist/index.cjs.js +1 -0
  18. package/dist/index.d.ts +11 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.es.js +353 -0
  21. package/dist/provider/SchedulerContext.d.ts +37 -0
  22. package/dist/provider/SchedulerContext.d.ts.map +1 -0
  23. package/dist/provider/SchedulerProvider.d.ts +31 -0
  24. package/dist/provider/SchedulerProvider.d.ts.map +1 -0
  25. package/dist/types/index.d.ts +162 -0
  26. package/dist/types/index.d.ts.map +1 -0
  27. package/dist/types/less.d.ts +9 -0
  28. package/dist/utils/colors.util.d.ts +25 -0
  29. package/dist/utils/colors.util.d.ts.map +1 -0
  30. package/dist/utils/form.util.d.ts +39 -0
  31. package/dist/utils/form.util.d.ts.map +1 -0
  32. package/dist/utils/format.util.d.ts +16 -0
  33. package/dist/utils/format.util.d.ts.map +1 -0
  34. package/dist/utils/index.d.ts +4 -0
  35. package/dist/utils/index.d.ts.map +1 -0
  36. package/package.json +63 -0
@@ -0,0 +1,3 @@
1
+ import type { Dispatch, SetStateAction } from 'react';
2
+ export declare const dayHandler: (durationValue: number, extender: string, setOccurs: Dispatch<SetStateAction<string>>, t: TFn) => void;
3
+ //# sourceMappingURL=day.handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"day.handler.d.ts","sourceRoot":"","sources":["day.handler.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAItD,eAAO,MAAM,UAAU,kBACN,MAAM,YACX,MAAM,aACL,SAAS,eAAe,MAAM,CAAC,CAAC,iBAQ5C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Dispatch, SetStateAction } from 'react';
2
+ export declare const monthHandler: (durationValue: number, scheduler: IScheduler, setOccurs: Dispatch<SetStateAction<string>>, t: TFn) => void;
3
+ //# sourceMappingURL=month.handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"month.handler.d.ts","sourceRoot":"","sources":["month.handler.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAKtD,eAAO,MAAM,YAAY,kBACR,MAAM,oCAEV,SAAS,eAAe,MAAM,CAAC,CAAC,iBAuB5C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Dispatch, SetStateAction } from 'react';
2
+ export declare const weekHandler: (durationValue: number, scheduler: IScheduler, setOccurs: Dispatch<SetStateAction<string>>, t: TFn) => void;
3
+ //# sourceMappingURL=week.handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"week.handler.d.ts","sourceRoot":"","sources":["week.handler.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAKtD,eAAO,MAAM,WAAW,kBACP,MAAM,oCAEV,SAAS,eAAe,MAAM,CAAC,CAAC,iBAmB5C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Dispatch, SetStateAction } from 'react';
2
+ export declare const yearHandler: (durationValue: number, scheduler: IScheduler, setOccurs: Dispatch<SetStateAction<string>>, t: TFn) => void;
3
+ //# sourceMappingURL=year.handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"year.handler.d.ts","sourceRoot":"","sources":["year.handler.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAKtD,eAAO,MAAM,WAAW,kBACP,MAAM,oCAEV,SAAS,eAAe,MAAM,CAAC,CAAC,iBA4B5C,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { Dispatch, SetStateAction } from 'react';
2
+ import { type IScheduler } from './types';
3
+ import type { TFn } from './i18n';
4
+ import type { IFormInstance } from './utils/form.util';
5
+ export declare const handleMsg: (singular: string, plural: string, value: number, t: TFn) => string;
6
+ export declare const handleDurationValueChange: (duration: TSchedulerDuration, scheduler: IScheduler, setOccurs: Dispatch<SetStateAction<string>>, t: TFn, extender?: string) => void;
7
+ export declare const handleChangeStartDate: (value: Dayjs, setStartAt: Dispatch<SetStateAction<string | null>>) => void;
8
+ export declare const handleSelectWeeklyDay: (durationValue: number, scheduler: IScheduler, setOccurs: Dispatch<SetStateAction<string>>, t: TFn, extra?: {
9
+ msg?: string | undefined;
10
+ } | undefined) => void;
11
+ export declare const handleMultipleDurations: (values: string[] | undefined, t: TFn) => string;
12
+ export declare type THandleSchedulerForm = {
13
+ disabled: boolean;
14
+ formRef: IFormInstance;
15
+ entity: IScheduler;
16
+ handlers: {
17
+ onSave: () => void;
18
+ setLoading: (loading: boolean) => void;
19
+ setOpenDrawer: (open: boolean) => void;
20
+ setConfigDrawer: (config: Record<string, unknown>) => void;
21
+ setOnRefreshDrawer: (fn: () => void) => void;
22
+ };
23
+ options: {
24
+ title?: string;
25
+ loading: boolean;
26
+ schedulerType: IScheduler['type'];
27
+ isEdit: boolean;
28
+ isDirty: boolean;
29
+ prefix?: string[];
30
+ readOnlyFields?: string[];
31
+ t: TFn;
32
+ };
33
+ };
34
+ export declare const handleSchedulerForm: ({ disabled, formRef, entity, handlers: { onSave, setLoading, setOpenDrawer, setConfigDrawer, setOnRefreshDrawer }, options: { title, loading, schedulerType, isEdit, isDirty, prefix, readOnlyFields, t }, }: THandleSchedulerForm) => void;
35
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["handlers.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAMtD,OAAO,EAAiC,KAAK,UAAU,EAA2B,MAAM,SAAS,CAAC;AAClG,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,eAAO,MAAM,SAAS,aAAc,MAAM,UAAU,MAAM,SAAS,MAAM,mBAMxE,CAAC;AAEF,eAAO,MAAM,yBAAyB,mEAGzB,SAAS,eAAe,MAAM,CAAC,CAAC,qBAEjC,MAAM,SAYjB,CAAC;AAEF,eAAO,MAAM,qBAAqB,6BAEpB,SAAS,eAAe,MAAM,GAAG,IAAI,CAAC,CAAC,SAUpD,CAAC;AAEF,eAAO,MAAM,qBAAqB,kBACjB,MAAM,oCAEV,SAAS,eAAe,MAAM,CAAC,CAAC;;sBAoB5C,CAAC;AAEF,eAAO,MAAM,uBAAuB,kDAUnC,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,IAAI,CAAC;QACnB,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;QACvC,aAAa,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;QACvC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QAC3D,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;KAC9C,CAAC;IACF,OAAO,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,aAAa,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;QAClC,MAAM,EAAE,OAAO,CAAC;QAChB,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,CAAC,EAAE,GAAG,CAAC;KACR,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,mBAAmB,iNAM7B,oBAAoB,SAmCtB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type React from 'react';
2
+ import type { ICommonDataType } from '../types';
3
+ export interface ISelectItemProps {
4
+ label: string;
5
+ value: string;
6
+ disabled?: boolean;
7
+ }
8
+ declare type TColumn = ICommonDataType & {
9
+ concealable?: boolean;
10
+ title?: React.ReactNode;
11
+ label?: React.ReactNode;
12
+ dataIndex?: string;
13
+ hidden?: boolean;
14
+ };
15
+ export declare const filterOutColumns: (columns: TColumn[], selectedColumns: string[]) => TColumn[];
16
+ export declare const useColumnsToggle: (columns: TColumn[], hiddenByDefault?: string[]) => {
17
+ columnsList: ISelectItemProps[];
18
+ selectedColumns: string[];
19
+ setSelectedColumns: React.Dispatch<React.SetStateAction<string[]>>;
20
+ filteredColumns: TColumn[];
21
+ };
22
+ export {};
23
+ //# sourceMappingURL=useColumnsToggle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useColumnsToggle.d.ts","sourceRoot":"","sources":["useColumnsToggle.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,aAAK,OAAO,GAAG,eAAe,GAAG;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAeF,eAAO,MAAM,gBAAgB,YAAa,OAAO,EAAE,mBAAmB,MAAM,EAAE,KAAG,OAAO,EAInF,CAAC;AAEN,eAAO,MAAM,gBAAgB,YAClB,OAAO,EAAE,oBACD,MAAM,EAAE;iBAEZ,gBAAgB,EAAE;qBACd,MAAM,EAAE;wBACL,MAAM,QAAQ,CAAC,MAAM,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC;qBACjD,OAAO,EAAE;CAqC3B,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare type SchedulerTranslations = Record<string, string>;
2
+ export declare type TFn = (key: string, params?: Record<string, string | number>) => string;
3
+ export declare const defaultTranslations: SchedulerTranslations;
4
+ export declare const createTranslationFn: (translations: SchedulerTranslations) => TFn;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAEA,oBAAY,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE3D,oBAAY,GAAG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,MAAM,CAAC;AAEpF,eAAO,MAAM,mBAAmB,EAAE,qBAA4B,CAAC;AAE/D,eAAO,MAAM,mBAAmB,iBAAkB,qBAAqB,KAAG,GAMzE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { SchedulerTranslations } from '../index';
2
+ declare const enUS: SchedulerTranslations;
3
+ export default enUS;
4
+ //# sourceMappingURL=en-US.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-US.d.ts","sourceRoot":"","sources":["en-US.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD,QAAA,MAAM,IAAI,EAAE,qBA0FX,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`dayjs`);c=s(c);let l=require(`react`);l=s(l);let u=require(`react/jsx-runtime`);var d=(e,t)=>Object.keys(e).find(n=>e[n]===t),f=function(e){return e.ACTIVE=`ACTIVE`,e.DEACTIVATED=`DEACTIVATED`,e.DELETED=`DELETED`,e.PROCESSING=`PROCESSING`,e.PENDING=`PENDING`,e.APPROVED=`APPROVED`,e.PUBLISHED=`PUBLISHED`,e}({}),p=function(e){return e.HOUR=`Hour`,e.DAY=`Day`,e.WEEK=`Week`,e.MONTH=`Month`,e.YEAR=`Year`,e.FOREVER=`Forever`,e}({}),m=`price`,h=`duration`,g=`discount`,_=`trialPeriod`,v=function(e){return e.USD=`USD`,e.EUR=`EUR`,e}({}),y=function(e){return e.PERCENT=`Percent`,e.FIXED=`Fixed`,e}({}),b={PERCENT:`%`,FIXED:v},x=function(e){return e.DATE=`Date`,e.NUMBER=`Number`,e.FOREVER=`Forever`,e}({}),S=function(e){return e.SUNDAY=`Sunday`,e.MONDAY=`Monday`,e.TUESDAY=`Tuesday`,e.WEDNESDAY=`Wednesday`,e.THURSDAY=`Thursday`,e.FRIDAY=`Friday`,e.SATURDAY=`Saturday`,e}({}),ee=function(e){return e.JANUARY=`January`,e.FEBRUARY=`February`,e.MARCH=`March`,e.APRIL=`April`,e.MAY=`May`,e.JUNE=`June`,e.JULY=`July`,e.AUGUST=`AUGUST`,e.SEPTEMBER=`September`,e.OCTOBER=`October`,e.NOVEMBER=`November`,e.DECEMBER=`December`,e}({}),C=function(e){return e.FIRST=`First`,e.SECOND=`Second`,e.THIRD=`Third`,e.FOURTH=`Fourth`,e.LAST=`Last`,e}({}),w=function(e){return e.SALE=`sale`,e.DISCOUNT=`discount`,e.TRIAL_DISCOUNT=`trialDiscount`,e}({}),te=function(e){return e.MONTH=`monthly`,e.YEAR=`yearly`,e.WEEK=`weekly`,e.DAY=`daily`,e}({}),ne=`scheduler`,T=[x.DATE,x.NUMBER,x.FOREVER],re=1,ie=5,E={duration:{type:`MONTH`,period:7},repeat:{weekly:{days:[d(S,Object.values(S)[1])]},monthly:{weekDay:`SECOND`,monthDay:2,type:`PERIOD`},yearly:{months:[`JANUARY`]}},range:{startedAt:(0,c.default)(new Date),endReason:{type:T[2],expiredAt:null}},status:f.PROCESSING},D={...E,type:w.SALE,[g]:null},O={...E,type:w.DISCOUNT,[g]:{type:`PERCENT`,value:1}},k={scheduler:`Scheduler`,"scheduler.info":`Scheduler Info`,"scheduler.header.title":`{{entity}} Scheduler ({{count}})`,"scheduler.result":`Occurs <strong>{{occurs}}</strong>, starting {{startAt}}.`,"scheduler.startedAt":`Started at`,"scheduler.updatedAt":`Updated at`,"scheduler.status":`Status`,"scheduler.duration":`Repeat Every`,"scheduler.occurrences":`Occurrences`,"scheduler.weekdays.sunday":`Sunday`,"scheduler.weekdays.monday":`Monday`,"scheduler.weekdays.tuesday":`Tuesday`,"scheduler.weekdays.wednesday":`Wednesday`,"scheduler.weekdays.thursday":`Thursday`,"scheduler.weekdays.friday":`Friday`,"scheduler.weekdays.saturday":`Saturday`,"scheduler.weekdays.short.sunday":`Sun`,"scheduler.weekdays.short.monday":`Mon`,"scheduler.weekdays.short.tuesday":`Tue`,"scheduler.weekdays.short.wednesday":`Wed`,"scheduler.weekdays.short.thursday":`Thu`,"scheduler.weekdays.short.friday":`Fri`,"scheduler.weekdays.short.saturday":`Sat`,"scheduler.duration.end":`End Reason`,"scheduler.duration.endDate":`End Date`,"scheduler.duration.end.day":`On this day`,"scheduler.duration.end.after":`After`,"scheduler.duration.end.no":`No end day`,"scheduler.separator.and":` and`,"scheduler.separator.on":`on`,"scheduler.separator.day":`day`,"scheduler.separator.every":`every`,"scheduler.separator.of":`of`,"scheduler.separator.the":`the`,"scheduler.day.first":`First`,"scheduler.day.second":`Second`,"scheduler.day.third":`Third`,"scheduler.day.fourth":`Fourth`,"scheduler.day.last":`Last`,"scheduler.weekday":`Weekday`,"scheduler.weekend":`Weekend Day`,"scheduler.day":`Day`,"scheduler.days":`Days`,"scheduler.week":`Week`,"scheduler.weeks":`Weeks`,"scheduler.year":`Year`,"scheduler.years":`Years`,"scheduler.monthDay":`Month Day`,"scheduler.month":`Month`,"scheduler.months":`Months`,"scheduler.months.january":`January`,"scheduler.months.february":`February`,"scheduler.months.march":`March`,"scheduler.months.april":`April`,"scheduler.months.may":`May`,"scheduler.months.june":`June`,"scheduler.months.july":`July`,"scheduler.months.august":`August`,"scheduler.months.september":`September`,"scheduler.months.october":`October`,"scheduler.months.november":`November`,"scheduler.months.december":`December`,"scheduler.months.short.january":`Jan`,"scheduler.months.short.february":`Feb`,"scheduler.months.short.march":`Mar`,"scheduler.months.short.april":`Apr`,"scheduler.months.short.may":`May`,"scheduler.months.short.june":`Jun`,"scheduler.months.short.july":`Jul`,"scheduler.months.short.august":`Aug`,"scheduler.months.short.september":`Sep`,"scheduler.months.short.october":`Oct`,"scheduler.months.short.november":`Nov`,"scheduler.months.short.december":`Dec`,"scheduler.actions.manage":`Manage Scheduler`,"scheduler.meta.assignedTo":`Assigned To`,"scheduler.meta.duration":`Duration`,"scheduler.meta.period":`Period`,"scheduler.limited":`The Scheduler is limited to: {{limit}}`,"scheduler.info.helper":`Set the scheduler to set a sale period.`,"table.actions":`Actions`,"actions.edit":`Edit`,"actions.delete":`Delete`,"actions.save":`Save`,"actions.update":`Update`,"actions.cancel":`Cancel`,"actions.confirm.delete":`Are you sure you want to delete this scheduler?`,"table.hideColumns":`Hide Columns`,"toolbar.refresh":`Refresh`},A=e=>(t,n)=>{let r=e[t]??k[t]??t;return n?r.replace(/\{\{(\w+)}}/g,(e,t)=>String(n[t]??``)):r},ae=(e,...t)=>[...e&&e.length>0?[...e]:[],...t],oe=(e,t=!0)=>({required:t,message:`${e} is required`}),se=(e,t=`input`)=>t===`select`?`Select ${e}`:`Enter ${e}`,j=(e,t)=>t.includes(e),M=(e,t,n)=>{let r=Array.isArray(t)?t:[t],i=e.getFieldsValue(!0),a=i;for(let e=0;e<r.length-1;e++){let t=r[e];(a[t]===void 0||a[t]===null||typeof a[t]!=`object`)&&(a[t]={}),a=a[t]}a[r[r.length-1]]=n,e.setFieldsValue(i)},N=(e,t)=>{let n=Array.isArray(t)?t:t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return;r=r[e]}return r},P=`YYYY-MM-DD HH:mm`,F=`YYYY-MM-DD`,I=`—`,L=(e,t)=>{try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch{return`${e} ${t}`}},R=e=>(isNaN(new Date(e).getDate())&&(e=parseInt(e?.toString(),10)),new Date(e)),z=e=>e?R(e).toLocaleDateString():`—`,B=e=>e?R(e).toLocaleTimeString():`—`,V=e=>{let t;return e==null||(t=c.default.isDayjs(e)||e?.seconds&&e?.nanoseconds?e.toDate():e),t?`${z(t)} ${B(t)}`:`—`},H=(e,t)=>{let n=t||(0,c.default)().startOf(`day`);return e.isBefore(n,`day`)},U={danger:`#ff4d4f`,disabled:`#d9d9d9`,warning:`#FFBF00`,success:`#52c41a`,tags:{magenta:`magenta`,red:`red`,volcano:`volcano`,orange:`orange`,gold:`gold`,lime:`lime`,green:`green`,cyan:`cyan`,blue:`blue`,geekblue:`geekblue`,purple:`purple`,processing:`processing`,success:`success`,error:`error`,warning:`warning`,default:`default`}},W=(e,t,n,r)=>{n(`${t}${`${r(`scheduler.separator.every`)} ${K(`scheduler.day`,`scheduler.days`,e,r)}`}`)},G=(e,t,n,r)=>{let i=t.repeat?.weekly?.days,a=K(`scheduler.month`,`scheduler.months`,e,r),o=t.repeat?.monthly;if(o?.type===`DAY`)Y(t.duration.period,t,n,r,{msg:a});else if(o?.type===`PERIOD`){let e=r(`scheduler.separator.the`),t=r(`scheduler.separator.of`),s=r(`scheduler.separator.every`),c=o.weekDay;n(`${e} ${c} ${X(i,r)} ${t} ${s} ${a}`)}},ce=(e,t,n,r)=>{let i=t.repeat?.weekly?.days||[],a=K(`scheduler.week`,`scheduler.weeks`,e,r),o=r(`scheduler.separator.day`),s=r(`scheduler.separator.on`),c=r(`scheduler.separator.every`),l=i?.length===7?o:X(i,r);n(e===1?`${c} ${l}`:`${c} ${a} ${s} ${l}`)},le=(e,t,n,r)=>{let i=K(`scheduler.year`,`scheduler.years`,e,r),{months:a}=t.repeat.yearly;if(a){let e=r(`scheduler.separator.every`),o=r(`scheduler.separator.the`),s=r(`scheduler.separator.of`),c=X(a,r),l=X(t.repeat?.weekly?.days,r),u=t.duration?.period>1?` ${s} ${e} ${i}`:``;u=t.repeat?.monthly?.type===`PERIOD`?`${o} ${t.repeat?.monthly?.weekDay} ${l} ${s} ${e} ${c}`+u:`${e} ${c} ${t.repeat?.monthly?.monthDay}`+u,n(u)}},K=(e,t,n,r)=>{let i=`${n} ${r(t)}`;return n===1&&(i=r(e)),i},q=(e,t,n,r,i=``)=>{switch(e.type){case`DAY`:return W(e.period,i,n,r);case`WEEK`:return ce(e.period,t,n,r);case`MONTH`:return G(e.period,t,n,r);case`YEAR`:return le(e.period,t,n,r)}},J=(e,t)=>{let n=(0,c.default)(e);t([n.format(`dddd`),`${n.date()} ${n.format(`MMMM`)} ${n.format(`YYYY`)}`,`at ${n.hour()}:${n.minute()}`].join(`, `))},Y=(e,t,n,r,i)=>{let a=r(`scheduler.separator.day`),o=r(`scheduler.separator.of`),s=r(`scheduler.separator.every`),c=`${a} ${t?.repeat?.monthly?.monthDay} ${o} ${s} `;i?.msg?n(`${c} ${i?.msg}`):q({type:t.duration.type,period:e},t,n,r,c)},X=(e=[],t)=>{let n=t(`scheduler.separator.and`),r=e.join(`, `),i=r.lastIndexOf(`,`);return i===-1?r:r.slice(0,i)+n+r.slice(i+1)},ue=({disabled:e,formRef:t,entity:n,handlers:{onSave:r,setLoading:i,setOpenDrawer:a,setConfigDrawer:o,setOnRefreshDrawer:s},options:{title:c,loading:l,schedulerType:u,isEdit:d,isDirty:f,prefix:m=[],readOnlyFields:h=[],t:g}})=>{if(e)return;let _=Object.keys(p),v=Object.keys(y);i(!0),a(!0);let b=()=>{i(!0),o({size:600,schedulerType:u,durationTypes:_,discountTypes:v,readOnlyFields:h,prefix:m,entity:n,formRef:t,title:c,isEdit:d,isDirty:f,loading:l,onSave:r,disabled:e,t:g}),i(!1)};s(b),b()},Z=(0,l.createContext)(null),de=()=>{let e=(0,l.useContext)(Z);if(!e)throw Error(`useSchedulerContext must be used within a SchedulerProvider`);return e},fe=e=>{let{schedulers:t,loading:n=!1,disabled:r=!1,locale:i,onCreate:a,onUpdate:o,onDelete:s,permissions:c,translations:d,children:f}=e,[p,m]=(0,l.useState)(!1),[h,g]=(0,l.useState)({}),_=(0,l.useMemo)(()=>({...k,...d??{}}),[d]),v=(0,l.useMemo)(()=>A(_),[_]),y=(0,l.useMemo)(()=>({schedulers:t,loading:n,disabled:r,locale:i,t:v,permissions:{canCreate:c?.canCreate??!0,canUpdate:c?.canUpdate??!0,canDelete:c?.canDelete??!0},onCreate:a,onUpdate:o,onDelete:s,drawerOpen:p,setDrawerOpen:m,drawerConfig:h,setDrawerConfig:g}),[t,n,r,i,v,c,a,o,s,p,h]);return(0,u.jsx)(Z.Provider,{value:y,children:f})},Q=e=>{let t=e.key,n=e.dataIndex;return String(t||n)},pe=e=>{let t=e.title??e.label,n=Q(e);return typeof t==`string`||typeof t==`number`?String(t):n},$=(e,t)=>e.map(e=>({...e,hidden:e.concealable&&!t.includes(Q(e))})),me=(e,t=[])=>{let[n,r]=(0,l.useState)([]),i=(0,l.useRef)(!1),a=(0,l.useMemo)(()=>e.filter(e=>e.concealable).map(e=>({label:pe(e),value:Q(e)})),[e]);return(0,l.useEffect)(()=>{if(!i.current&&a.length>0){let e=new Set(t.map(String));r(a.map(e=>e.value).filter(t=>!e.has(t))),i.current=!0}},[a,t]),{columnsList:a,selectedColumns:n,setSelectedColumns:r,filteredColumns:(0,l.useMemo)(()=>$(e,n),[e,n])}};exports.CDiscountTypeValues=b,exports.CEndReasonTypes=T,exports.CFirstDayIdx=re,exports.CNsDiscount=g,exports.CNsDuration=h,exports.CNsPrice=m,exports.CNsTrial=_,exports.COLORS=U,exports.CScheduler=ne,exports.DEFAULT_DATE_FORMAT=F,exports.DEFAULT_DATE_TIME_FORMAT=P,exports.DEFAULT_DISCOUNT_SCHEDULER=O,exports.DEFAULT_SALE_SCHEDULER=D,exports.DEFAULT_SCHEDULERS_LIMIT=ie,exports.ECurrency=v,exports.EDays=S,exports.EDiscountType=y,exports.EDurationTypes=p,exports.EEndReasonType=x,exports.EMonths=ee,exports.ESchedulerPrefix=w,exports.ESchedulerTypeTransform=te,exports.EStatus=f,exports.EWeekDays=C,exports.NADate=I,exports.SchedulerContext=Z,exports.SchedulerProvider=fe,exports.createTranslationFn=A,exports.defaultTranslations=k,exports.filterOutColumns=$,exports.findFieldValue=N,exports.getDisabledDate=H,exports.getKeyFromEnum=d,exports.handleChangeStartDate=J,exports.handleDurationValueChange=q,exports.handleMsg=K,exports.handleMultipleDurations=X,exports.handleSchedulerForm=ue,exports.handleSelectWeeklyDay=Y,exports.isReadOnlyField=j,exports.mergeNames=ae,exports.numberToCurrency=L,exports.placeholderField=se,exports.requiredField=oe,exports.setNestedDynamicFields=M,exports.tsToDate=z,exports.tsToLocaleDateTime=V,exports.tsToTime=B,exports.useColumnsToggle=me,exports.useSchedulerContext=de;
@@ -0,0 +1,11 @@
1
+ export * from './types';
2
+ export * from './i18n';
3
+ export * from './utils';
4
+ export * from './handlers';
5
+ export { SchedulerProvider } from './provider/SchedulerProvider';
6
+ export type { SchedulerProviderProps } from './provider/SchedulerProvider';
7
+ export { SchedulerContext, useSchedulerContext } from './provider/SchedulerContext';
8
+ export type { SchedulerContextValue } from './provider/SchedulerContext';
9
+ export { useColumnsToggle, filterOutColumns } from './hooks/useColumnsToggle';
10
+ export type { ISelectItemProps } from './hooks/useColumnsToggle';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AAGxB,cAAc,QAAQ,CAAC;AAGvB,cAAc,SAAS,CAAC;AAGxB,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,YAAY,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACpF,YAAY,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC9E,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,353 @@
1
+ import e from "dayjs";
2
+ import { createContext as t, useContext as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
3
+ import { jsx as s } from "react/jsx-runtime";
4
+ //#region src/types/index.ts
5
+ var c = (e, t) => Object.keys(e).find((n) => e[n] === t), l = /* @__PURE__ */ function(e) {
6
+ return e.ACTIVE = "ACTIVE", e.DEACTIVATED = "DEACTIVATED", e.DELETED = "DELETED", e.PROCESSING = "PROCESSING", e.PENDING = "PENDING", e.APPROVED = "APPROVED", e.PUBLISHED = "PUBLISHED", e;
7
+ }({}), u = /* @__PURE__ */ function(e) {
8
+ return e.HOUR = "Hour", e.DAY = "Day", e.WEEK = "Week", e.MONTH = "Month", e.YEAR = "Year", e.FOREVER = "Forever", e;
9
+ }({}), d = "price", f = "duration", p = "discount", m = "trialPeriod", h = /* @__PURE__ */ function(e) {
10
+ return e.USD = "USD", e.EUR = "EUR", e;
11
+ }({}), g = /* @__PURE__ */ function(e) {
12
+ return e.PERCENT = "Percent", e.FIXED = "Fixed", e;
13
+ }({}), _ = {
14
+ PERCENT: "%",
15
+ FIXED: h
16
+ }, v = /* @__PURE__ */ function(e) {
17
+ return e.DATE = "Date", e.NUMBER = "Number", e.FOREVER = "Forever", e;
18
+ }({}), y = /* @__PURE__ */ function(e) {
19
+ return e.SUNDAY = "Sunday", e.MONDAY = "Monday", e.TUESDAY = "Tuesday", e.WEDNESDAY = "Wednesday", e.THURSDAY = "Thursday", e.FRIDAY = "Friday", e.SATURDAY = "Saturday", e;
20
+ }({}), b = /* @__PURE__ */ function(e) {
21
+ return e.JANUARY = "January", e.FEBRUARY = "February", e.MARCH = "March", e.APRIL = "April", e.MAY = "May", e.JUNE = "June", e.JULY = "July", e.AUGUST = "AUGUST", e.SEPTEMBER = "September", e.OCTOBER = "October", e.NOVEMBER = "November", e.DECEMBER = "December", e;
22
+ }({}), ee = /* @__PURE__ */ function(e) {
23
+ return e.FIRST = "First", e.SECOND = "Second", e.THIRD = "Third", e.FOURTH = "Fourth", e.LAST = "Last", e;
24
+ }({}), x = /* @__PURE__ */ function(e) {
25
+ return e.SALE = "sale", e.DISCOUNT = "discount", e.TRIAL_DISCOUNT = "trialDiscount", e;
26
+ }({}), S = /* @__PURE__ */ function(e) {
27
+ return e.MONTH = "monthly", e.YEAR = "yearly", e.WEEK = "weekly", e.DAY = "daily", e;
28
+ }({}), te = "scheduler", C = [
29
+ v.DATE,
30
+ v.NUMBER,
31
+ v.FOREVER
32
+ ], w = 1, T = 5, E = {
33
+ duration: {
34
+ type: "MONTH",
35
+ period: 7
36
+ },
37
+ repeat: {
38
+ weekly: { days: [c(y, Object.values(y)[1])] },
39
+ monthly: {
40
+ weekDay: "SECOND",
41
+ monthDay: 2,
42
+ type: "PERIOD"
43
+ },
44
+ yearly: { months: ["JANUARY"] }
45
+ },
46
+ range: {
47
+ startedAt: e(/* @__PURE__ */ new Date()),
48
+ endReason: {
49
+ type: C[2],
50
+ expiredAt: null
51
+ }
52
+ },
53
+ status: l.PROCESSING
54
+ }, D = {
55
+ ...E,
56
+ type: x.SALE,
57
+ [p]: null
58
+ }, ne = {
59
+ ...E,
60
+ type: x.DISCOUNT,
61
+ [p]: {
62
+ type: "PERCENT",
63
+ value: 1
64
+ }
65
+ }, O = {
66
+ scheduler: "Scheduler",
67
+ "scheduler.info": "Scheduler Info",
68
+ "scheduler.header.title": "{{entity}} Scheduler ({{count}})",
69
+ "scheduler.result": "Occurs <strong>{{occurs}}</strong>, starting {{startAt}}.",
70
+ "scheduler.startedAt": "Started at",
71
+ "scheduler.updatedAt": "Updated at",
72
+ "scheduler.status": "Status",
73
+ "scheduler.duration": "Repeat Every",
74
+ "scheduler.occurrences": "Occurrences",
75
+ "scheduler.weekdays.sunday": "Sunday",
76
+ "scheduler.weekdays.monday": "Monday",
77
+ "scheduler.weekdays.tuesday": "Tuesday",
78
+ "scheduler.weekdays.wednesday": "Wednesday",
79
+ "scheduler.weekdays.thursday": "Thursday",
80
+ "scheduler.weekdays.friday": "Friday",
81
+ "scheduler.weekdays.saturday": "Saturday",
82
+ "scheduler.weekdays.short.sunday": "Sun",
83
+ "scheduler.weekdays.short.monday": "Mon",
84
+ "scheduler.weekdays.short.tuesday": "Tue",
85
+ "scheduler.weekdays.short.wednesday": "Wed",
86
+ "scheduler.weekdays.short.thursday": "Thu",
87
+ "scheduler.weekdays.short.friday": "Fri",
88
+ "scheduler.weekdays.short.saturday": "Sat",
89
+ "scheduler.duration.end": "End Reason",
90
+ "scheduler.duration.endDate": "End Date",
91
+ "scheduler.duration.end.day": "On this day",
92
+ "scheduler.duration.end.after": "After",
93
+ "scheduler.duration.end.no": "No end day",
94
+ "scheduler.separator.and": " and",
95
+ "scheduler.separator.on": "on",
96
+ "scheduler.separator.day": "day",
97
+ "scheduler.separator.every": "every",
98
+ "scheduler.separator.of": "of",
99
+ "scheduler.separator.the": "the",
100
+ "scheduler.day.first": "First",
101
+ "scheduler.day.second": "Second",
102
+ "scheduler.day.third": "Third",
103
+ "scheduler.day.fourth": "Fourth",
104
+ "scheduler.day.last": "Last",
105
+ "scheduler.weekday": "Weekday",
106
+ "scheduler.weekend": "Weekend Day",
107
+ "scheduler.day": "Day",
108
+ "scheduler.days": "Days",
109
+ "scheduler.week": "Week",
110
+ "scheduler.weeks": "Weeks",
111
+ "scheduler.year": "Year",
112
+ "scheduler.years": "Years",
113
+ "scheduler.monthDay": "Month Day",
114
+ "scheduler.month": "Month",
115
+ "scheduler.months": "Months",
116
+ "scheduler.months.january": "January",
117
+ "scheduler.months.february": "February",
118
+ "scheduler.months.march": "March",
119
+ "scheduler.months.april": "April",
120
+ "scheduler.months.may": "May",
121
+ "scheduler.months.june": "June",
122
+ "scheduler.months.july": "July",
123
+ "scheduler.months.august": "August",
124
+ "scheduler.months.september": "September",
125
+ "scheduler.months.october": "October",
126
+ "scheduler.months.november": "November",
127
+ "scheduler.months.december": "December",
128
+ "scheduler.months.short.january": "Jan",
129
+ "scheduler.months.short.february": "Feb",
130
+ "scheduler.months.short.march": "Mar",
131
+ "scheduler.months.short.april": "Apr",
132
+ "scheduler.months.short.may": "May",
133
+ "scheduler.months.short.june": "Jun",
134
+ "scheduler.months.short.july": "Jul",
135
+ "scheduler.months.short.august": "Aug",
136
+ "scheduler.months.short.september": "Sep",
137
+ "scheduler.months.short.october": "Oct",
138
+ "scheduler.months.short.november": "Nov",
139
+ "scheduler.months.short.december": "Dec",
140
+ "scheduler.actions.manage": "Manage Scheduler",
141
+ "scheduler.meta.assignedTo": "Assigned To",
142
+ "scheduler.meta.duration": "Duration",
143
+ "scheduler.meta.period": "Period",
144
+ "scheduler.limited": "The Scheduler is limited to: {{limit}}",
145
+ "scheduler.info.helper": "Set the scheduler to set a sale period.",
146
+ "table.actions": "Actions",
147
+ "actions.edit": "Edit",
148
+ "actions.delete": "Delete",
149
+ "actions.save": "Save",
150
+ "actions.update": "Update",
151
+ "actions.cancel": "Cancel",
152
+ "actions.confirm.delete": "Are you sure you want to delete this scheduler?",
153
+ "table.hideColumns": "Hide Columns",
154
+ "toolbar.refresh": "Refresh"
155
+ }, k = (e) => (t, n) => {
156
+ let r = e[t] ?? O[t] ?? t;
157
+ return n ? r.replace(/\{\{(\w+)}}/g, (e, t) => String(n[t] ?? "")) : r;
158
+ }, re = (e, ...t) => [...e && e.length > 0 ? [...e] : [], ...t], ie = (e, t = !0) => ({
159
+ required: t,
160
+ message: `${e} is required`
161
+ }), ae = (e, t = "input") => t === "select" ? `Select ${e}` : `Enter ${e}`, oe = (e, t) => t.includes(e), A = (e, t, n) => {
162
+ let r = Array.isArray(t) ? t : [t], i = e.getFieldsValue(!0), a = i;
163
+ for (let e = 0; e < r.length - 1; e++) {
164
+ let t = r[e];
165
+ (a[t] === void 0 || a[t] === null || typeof a[t] != "object") && (a[t] = {}), a = a[t];
166
+ }
167
+ a[r[r.length - 1]] = n, e.setFieldsValue(i);
168
+ }, j = (e, t) => {
169
+ let n = Array.isArray(t) ? t : t.split("."), r = e;
170
+ for (let e of n) {
171
+ if (typeof r != "object" || !r) return;
172
+ r = r[e];
173
+ }
174
+ return r;
175
+ }, M = "YYYY-MM-DD HH:mm", N = "YYYY-MM-DD", P = "—", F = (e, t) => {
176
+ try {
177
+ return new Intl.NumberFormat("en-US", {
178
+ style: "currency",
179
+ currency: t,
180
+ minimumFractionDigits: 0,
181
+ maximumFractionDigits: 2
182
+ }).format(e);
183
+ } catch {
184
+ return `${e} ${t}`;
185
+ }
186
+ }, I = (e) => (isNaN(new Date(e).getDate()) && (e = parseInt(e?.toString(), 10)), new Date(e)), L = (e) => e ? I(e).toLocaleDateString() : "—", R = (e) => e ? I(e).toLocaleTimeString() : "—", z = (t) => {
187
+ let n;
188
+ return t == null || (n = e.isDayjs(t) || t?.seconds && t?.nanoseconds ? t.toDate() : t), n ? `${L(n)} ${R(n)}` : "—";
189
+ }, B = (t, n) => {
190
+ let r = n || e().startOf("day");
191
+ return t.isBefore(r, "day");
192
+ }, V = {
193
+ danger: "#ff4d4f",
194
+ disabled: "#d9d9d9",
195
+ warning: "#FFBF00",
196
+ success: "#52c41a",
197
+ tags: {
198
+ magenta: "magenta",
199
+ red: "red",
200
+ volcano: "volcano",
201
+ orange: "orange",
202
+ gold: "gold",
203
+ lime: "lime",
204
+ green: "green",
205
+ cyan: "cyan",
206
+ blue: "blue",
207
+ geekblue: "geekblue",
208
+ purple: "purple",
209
+ processing: "processing",
210
+ success: "success",
211
+ error: "error",
212
+ warning: "warning",
213
+ default: "default"
214
+ }
215
+ }, H = (e, t, n, r) => {
216
+ n(`${t}${`${r("scheduler.separator.every")} ${K("scheduler.day", "scheduler.days", e, r)}`}`);
217
+ }, U = (e, t, n, r) => {
218
+ let i = t.repeat?.weekly?.days, a = K("scheduler.month", "scheduler.months", e, r), o = t.repeat?.monthly;
219
+ if (o?.type === "DAY") J(t.duration.period, t, n, r, { msg: a });
220
+ else if (o?.type === "PERIOD") {
221
+ let e = r("scheduler.separator.the"), t = r("scheduler.separator.of"), s = r("scheduler.separator.every"), c = o.weekDay;
222
+ n(`${e} ${c} ${Y(i, r)} ${t} ${s} ${a}`);
223
+ }
224
+ }, W = (e, t, n, r) => {
225
+ let i = t.repeat?.weekly?.days || [], a = K("scheduler.week", "scheduler.weeks", e, r), o = r("scheduler.separator.day"), s = r("scheduler.separator.on"), c = r("scheduler.separator.every"), l = i?.length === 7 ? o : Y(i, r);
226
+ n(e === 1 ? `${c} ${l}` : `${c} ${a} ${s} ${l}`);
227
+ }, G = (e, t, n, r) => {
228
+ let i = K("scheduler.year", "scheduler.years", e, r), { months: a } = t.repeat.yearly;
229
+ if (a) {
230
+ let e = r("scheduler.separator.every"), o = r("scheduler.separator.the"), s = r("scheduler.separator.of"), c = Y(a, r), l = Y(t.repeat?.weekly?.days, r), u = t.duration?.period > 1 ? ` ${s} ${e} ${i}` : "";
231
+ u = t.repeat?.monthly?.type === "PERIOD" ? `${o} ${t.repeat?.monthly?.weekDay} ${l} ${s} ${e} ${c}` + u : `${e} ${c} ${t.repeat?.monthly?.monthDay}` + u, n(u);
232
+ }
233
+ }, K = (e, t, n, r) => {
234
+ let i = `${n} ${r(t)}`;
235
+ return n === 1 && (i = r(e)), i;
236
+ }, q = (e, t, n, r, i = "") => {
237
+ switch (e.type) {
238
+ case "DAY": return H(e.period, i, n, r);
239
+ case "WEEK": return W(e.period, t, n, r);
240
+ case "MONTH": return U(e.period, t, n, r);
241
+ case "YEAR": return G(e.period, t, n, r);
242
+ }
243
+ }, se = (t, n) => {
244
+ let r = e(t);
245
+ n([
246
+ r.format("dddd"),
247
+ `${r.date()} ${r.format("MMMM")} ${r.format("YYYY")}`,
248
+ `at ${r.hour()}:${r.minute()}`
249
+ ].join(", "));
250
+ }, J = (e, t, n, r, i) => {
251
+ let a = r("scheduler.separator.day"), o = r("scheduler.separator.of"), s = r("scheduler.separator.every"), c = `${a} ${t?.repeat?.monthly?.monthDay} ${o} ${s} `;
252
+ i?.msg ? n(`${c} ${i?.msg}`) : q({
253
+ type: t.duration.type,
254
+ period: e
255
+ }, t, n, r, c);
256
+ }, Y = (e = [], t) => {
257
+ let n = t("scheduler.separator.and"), r = e.join(", "), i = r.lastIndexOf(",");
258
+ return i === -1 ? r : r.slice(0, i) + n + r.slice(i + 1);
259
+ }, ce = ({ disabled: e, formRef: t, entity: n, handlers: { onSave: r, setLoading: i, setOpenDrawer: a, setConfigDrawer: o, setOnRefreshDrawer: s }, options: { title: c, loading: l, schedulerType: d, isEdit: f, isDirty: p, prefix: m = [], readOnlyFields: h = [], t: _ } }) => {
260
+ if (e) return;
261
+ let v = Object.keys(u), y = Object.keys(g);
262
+ i(!0), a(!0);
263
+ let b = () => {
264
+ i(!0), o({
265
+ size: 600,
266
+ schedulerType: d,
267
+ durationTypes: v,
268
+ discountTypes: y,
269
+ readOnlyFields: h,
270
+ prefix: m,
271
+ entity: n,
272
+ formRef: t,
273
+ title: c,
274
+ isEdit: f,
275
+ isDirty: p,
276
+ loading: l,
277
+ onSave: r,
278
+ disabled: e,
279
+ t: _
280
+ }), i(!1);
281
+ };
282
+ s(b), b();
283
+ }, X = t(null), le = () => {
284
+ let e = n(X);
285
+ if (!e) throw Error("useSchedulerContext must be used within a SchedulerProvider");
286
+ return e;
287
+ }, ue = (e) => {
288
+ let { schedulers: t, loading: n = !1, disabled: r = !1, locale: a, onCreate: c, onUpdate: l, onDelete: u, permissions: d, translations: f, children: p } = e, [m, h] = o(!1), [g, _] = o({}), v = i(() => ({
289
+ ...O,
290
+ ...f ?? {}
291
+ }), [f]), y = i(() => k(v), [v]), b = i(() => ({
292
+ schedulers: t,
293
+ loading: n,
294
+ disabled: r,
295
+ locale: a,
296
+ t: y,
297
+ permissions: {
298
+ canCreate: d?.canCreate ?? !0,
299
+ canUpdate: d?.canUpdate ?? !0,
300
+ canDelete: d?.canDelete ?? !0
301
+ },
302
+ onCreate: c,
303
+ onUpdate: l,
304
+ onDelete: u,
305
+ drawerOpen: m,
306
+ setDrawerOpen: h,
307
+ drawerConfig: g,
308
+ setDrawerConfig: _
309
+ }), [
310
+ t,
311
+ n,
312
+ r,
313
+ a,
314
+ y,
315
+ d,
316
+ c,
317
+ l,
318
+ u,
319
+ m,
320
+ g
321
+ ]);
322
+ return /* @__PURE__ */ s(X.Provider, {
323
+ value: b,
324
+ children: p
325
+ });
326
+ }, Z = (e) => {
327
+ let t = e.key, n = e.dataIndex;
328
+ return String(t || n);
329
+ }, Q = (e) => {
330
+ let t = e.title ?? e.label, n = Z(e);
331
+ return typeof t == "string" || typeof t == "number" ? String(t) : n;
332
+ }, $ = (e, t) => e.map((e) => ({
333
+ ...e,
334
+ hidden: e.concealable && !t.includes(Z(e))
335
+ })), de = (e, t = []) => {
336
+ let [n, s] = o([]), c = a(!1), l = i(() => e.filter((e) => e.concealable).map((e) => ({
337
+ label: Q(e),
338
+ value: Z(e)
339
+ })), [e]);
340
+ return r(() => {
341
+ if (!c.current && l.length > 0) {
342
+ let e = new Set(t.map(String));
343
+ s(l.map((e) => e.value).filter((t) => !e.has(t))), c.current = !0;
344
+ }
345
+ }, [l, t]), {
346
+ columnsList: l,
347
+ selectedColumns: n,
348
+ setSelectedColumns: s,
349
+ filteredColumns: i(() => $(e, n), [e, n])
350
+ };
351
+ };
352
+ //#endregion
353
+ export { _ as CDiscountTypeValues, C as CEndReasonTypes, w as CFirstDayIdx, p as CNsDiscount, f as CNsDuration, d as CNsPrice, m as CNsTrial, V as COLORS, te as CScheduler, N as DEFAULT_DATE_FORMAT, M as DEFAULT_DATE_TIME_FORMAT, ne as DEFAULT_DISCOUNT_SCHEDULER, D as DEFAULT_SALE_SCHEDULER, T as DEFAULT_SCHEDULERS_LIMIT, h as ECurrency, y as EDays, g as EDiscountType, u as EDurationTypes, v as EEndReasonType, b as EMonths, x as ESchedulerPrefix, S as ESchedulerTypeTransform, l as EStatus, ee as EWeekDays, P as NADate, X as SchedulerContext, ue as SchedulerProvider, k as createTranslationFn, O as defaultTranslations, $ as filterOutColumns, j as findFieldValue, B as getDisabledDate, c as getKeyFromEnum, se as handleChangeStartDate, q as handleDurationValueChange, K as handleMsg, Y as handleMultipleDurations, ce as handleSchedulerForm, J as handleSelectWeeklyDay, oe as isReadOnlyField, re as mergeNames, F as numberToCurrency, ae as placeholderField, ie as requiredField, A as setNestedDynamicFields, L as tsToDate, z as tsToLocaleDateTime, R as tsToTime, de as useColumnsToggle, le as useSchedulerContext };
@@ -0,0 +1,37 @@
1
+ import type { TFn } from '../i18n/index';
2
+ import type { ESchedulerPrefix, IScheduler } from '../types/index';
3
+ export interface SchedulerContextValue {
4
+ /** Scheduler data grouped by type */
5
+ schedulers: Record<ESchedulerPrefix, IScheduler[]>;
6
+ /** Global loading state */
7
+ loading: boolean;
8
+ /** Global disabled state */
9
+ disabled: boolean;
10
+ /** Permission flags for CRUD operations */
11
+ permissions: {
12
+ canCreate: boolean;
13
+ canUpdate: boolean;
14
+ canDelete: boolean;
15
+ };
16
+ /** Translation function — call as `t('key')` or `t('key', { var: value })` */
17
+ t: TFn;
18
+ /** Locale code (e.g. `"en-US"`) */
19
+ locale?: string;
20
+ /** Create a new scheduler */
21
+ onCreate?: (type: ESchedulerPrefix, scheduler: IScheduler) => Promise<void>;
22
+ /** Update an existing scheduler */
23
+ onUpdate?: (type: ESchedulerPrefix, scheduler: IScheduler) => Promise<void>;
24
+ /** Delete a scheduler by ID */
25
+ onDelete?: (type: ESchedulerPrefix, schedulerId: string) => Promise<void>;
26
+ /** Whether the create/edit drawer is currently open */
27
+ drawerOpen: boolean;
28
+ /** Toggle the drawer open/closed */
29
+ setDrawerOpen: (open: boolean) => void;
30
+ /** Arbitrary config passed to the drawer */
31
+ drawerConfig: Record<string, unknown>;
32
+ /** Update the drawer config */
33
+ setDrawerConfig: (config: Record<string, unknown>) => void;
34
+ }
35
+ export declare const SchedulerContext: import("react").Context<SchedulerContextValue | null>;
36
+ export declare const useSchedulerContext: () => SchedulerContextValue;
37
+ //# sourceMappingUR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OAAO,CAAC,CAAC;IACtC,+BAA+B;IAC/B,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CAC5D;AAED,eAAO,MAAM,gBAAgB,uDAAoD,CAAC;AAElF,eAAO,MAAM,mBAAmB,QAAO,qBAMtC,CAAC"}
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import type { SchedulerTranslations } from '../i18n';
3
+ import type { ESchedulerPrefix, IScheduler } from '../types';
4
+ export interface SchedulerProviderProps {
5
+ /** Scheduler data grouped by type (SALE, DISCOUNT, TRIAL_DISCOUNT) */
6
+ schedulers: Record<ESchedulerPrefix, IScheduler[]>;
7
+ /** Show a global loading state across all child components. @default false */
8
+ loading?: boolean;
9
+ /** Disable all interactions in child components. @default false */
10
+ disabled?: boolean;
11
+ /** Locale code passed to child components (e.g. `"en-US"`) */
12
+ locale?: string;
13
+ /** Called when a new scheduler is created via the drawer form */
14
+ onCreate?: (type: ESchedulerPrefix, scheduler: IScheduler) => Promise<void>;
15
+ /** Called when an existing scheduler is updated via the edit drawer */
16
+ onUpdate?: (type: ESchedulerPrefix, scheduler: IScheduler) => Promise<void>;
17
+ /** Called when a scheduler is deleted from the list */
18
+ onDelete?: (type: ESchedulerPrefix, schedulerId: string) => Promise<void>;
19
+ /** Permission flags controlling which CRUD actions are available. All default to `true`. */
20
+ permissions?: {
21
+ canCreate?: boolean;
22
+ canUpdate?: boolean;
23
+ canDelete?: boolean;
24
+ };
25
+ /** Override default English translations. Merged with built-in defaults. */
26
+ translations?: Partial<SchedulerTranslations>;
27
+ /** Child components that consume the scheduler context */
28
+ children: React.ReactNode;
29
+ }
30
+ export declare const SchedulerProvider: (props: SchedulerProviderProps) => import("react/jsx-runtime").JSX.Element;
31
+ //# sourceMappingURL=SchedulerProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchedulerProvider.d.ts","sourceRoot":"","sources":["SchedulerProvider.tsx"],"names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KeyFromEnum: <T extends object>(enumObj: T, value: T[keyof T]) => keyof T | undefined;
3
+ export declare enum EStatus {
4
+ ACTIVE = "ACTIVE",
5
+ DEACTIVATED = "DEACTIVATED",
6
+ DELETED = "DELETED",
7
+ PROCESSING = "PROCESSING",
8
+ PENDING = "PENDING",
9
+ APPROVED = "APPROVED",
10
+ PUBLISHED = "PUBLISHED"
11
+ }
12
+ export declare enum EDurationTypes {
13
+ HOUR = "Hour",
14
+ DAY = "Day",
15
+ WEEK = "Week",
16
+ MONTH = "Month",
17
+ YEAR = "Year",
18
+ FOREVER = "Forever"
19
+ }
20
+ export declare type TDuration = {
21
+ type: keyof typeof EDurationTypes;
22
+ period: number;
23
+ };
24
+ export declare const CNsPrice = "price";
25
+ export declare const CNsDuration = "duration";
26
+ export declare const CNsDiscount = "discount";
27
+ export declare const CNsTrial = "trialPeriod";
28
+ export declare enum ECurrency {
29
+ USD = "USD",
30
+ EUR = "EUR"
31
+ }
32
+ export declare enum EDiscountType {
33
+ PERCENT = "Percent",
34
+ FIXED = "Fixed"
35
+ }
36
+ export declare const CDiscountTypeValues: {
37
+ readonly PERCENT: "%";
38
+ readonly FIXED: typeof ECurrency;
39
+ };
40
+ export declare type TDiscountType = keyof typeof EDiscountType;
41
+ export declare type TDiscount = {
42
+ type: TDiscountType;
43
+ value: number;
44
+ };
45
+ export declare enum EEndReasonType {
46
+ DATE = "Date",
47
+ NUMBER = "Number",
48
+ FOREVER = "Forever"
49
+ }
50
+ export declare enum EDays {
51
+ SUNDAY = "Sunday",
52
+ MONDAY = "Monday",
53
+ TUESDAY = "Tuesday",
54
+ WEDNESDAY = "Wednesday",
55
+ THURSDAY = "Thursday",
56
+ FRIDAY = "Friday",
57
+ SATURDAY = "Saturday"
58
+ }
59
+ export declare enum EMonths {
60
+ JANUARY = "January",
61
+ FEBRUARY = "February",
62
+ MARCH = "March",
63
+ APRIL = "April",
64
+ MAY = "May",
65
+ JUNE = "June",
66
+ JULY = "July",
67
+ AUGUST = "AUGUST",
68
+ SEPTEMBER = "September",
69
+ OCTOBER = "October",
70
+ NOVEMBER = "November",
71
+ DECEMBER = "December"
72
+ }
73
+ export declare enum EWeekDays {
74
+ FIRST = "First",
75
+ SECOND = "Second",
76
+ THIRD = "Third",
77
+ FOURTH = "Fourth",
78
+ LAST = "Last"
79
+ }
80
+ export declare enum ESchedulerPrefix {
81
+ SALE = "sale",
82
+ DISCOUNT = "discount",
83
+ TRIAL_DISCOUNT = "trialDiscount"
84
+ }
85
+ export declare enum ESchedulerTypeTransform {
86
+ MONTH = "monthly",
87
+ YEAR = "yearly",
88
+ WEEK = "weekly",
89
+ DAY = "daily"
90
+ }
91
+ export declare const CScheduler = "scheduler";
92
+ export declare const CEndReasonTypes: EEndReasonType[];
93
+ export declare const CFirstDayIdx = 1;
94
+ export declare const DEFAULT_SCHEDULERS_LIMIT = 5;
95
+ export declare type TSchedulerDuration = {
96
+ type: keyof typeof EDurationTypes;
97
+ period: number;
98
+ };
99
+ export declare type TSchedulerRange = {
100
+ startedAt: dayjs.Dayjs | string;
101
+ endReason: {
102
+ type: EEndReasonType;
103
+ expiredAt: dayjs.Dayjs | string | null;
104
+ occurrences?: number;
105
+ };
106
+ };
107
+ export declare type TSchedulerRepeat = {
108
+ weekly: {
109
+ days: (keyof typeof EDays)[];
110
+ };
111
+ monthly: {
112
+ weekDay?: keyof typeof EWeekDays;
113
+ monthDay?: number;
114
+ type: 'DAY' | 'PERIOD';
115
+ };
116
+ yearly: {
117
+ months?: (keyof typeof EMonths)[];
118
+ };
119
+ };
120
+ export interface ISchedulerMetadata {
121
+ createdAt?: string | dayjs.Dayjs;
122
+ updatedAt?: string | dayjs.Dayjs;
123
+ createdBy?: string;
124
+ updatedBy?: string;
125
+ }
126
+ export interface IScheduler {
127
+ id?: string;
128
+ type: ESchedulerPrefix;
129
+ duration: TSchedulerDuration;
130
+ repeat: TSchedulerRepeat;
131
+ range: TSchedulerRange;
132
+ discount?: TDiscount | null;
133
+ status?: EStatus;
134
+ metadata?: ISchedulerMetadata;
135
+ }
136
+ declare type TConditionalDiscount<P extends ESchedulerPrefix> = P extends ESchedulerPrefix.SALE ? {
137
+ [CNsDiscount]?: null;
138
+ } : {
139
+ [CNsDiscount]?: TDiscount;
140
+ };
141
+ export declare type TScheduler<P extends ESchedulerPrefix> = IScheduler & TConditionalDiscount<P>;
142
+ export declare type RequiredSchedulers = {
143
+ [K in Exclude<ESchedulerPrefix, ESchedulerPrefix.TRIAL_DISCOUNT>]: TScheduler<K>[];
144
+ };
145
+ export declare type OptionalSchedulers = {
146
+ [ESchedulerPrefix.TRIAL_DISCOUNT]?: TScheduler<ESchedulerPrefix.TRIAL_DISCOUNT>[];
147
+ };
148
+ export declare type TSchedulers = {
149
+ [CScheduler]: RequiredSchedulers & OptionalSchedulers;
150
+ };
151
+ export interface IObjectId {
152
+ id?: string;
153
+ uid?: string;
154
+ }
155
+ export interface ICommonDataType extends IObjectId {
156
+ key: string;
157
+ [key: string]: unknown;
158
+ }
159
+ export declare const DEFAULT_SALE_SCHEDULER: Partial<TScheduler<ESchedulerPrefix.SALE>>;
160
+ export declare const DEFAULT_DISCOUNT_SCHEDULER: Partial<TScheduler<ESchedulerPrefix.DISCOUNT>>;
161
+ export {};
162
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,eAAO,MAAM,cAAc,0EAIqD,CAAC;AAMjF,oBAAY,OAAO;IACjB,MAAM,WAAW;IACjB,WAAW,gBAAgB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,SAAS,cAAc;CACxB;AAED,oBAAY,cAAc;IACxB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,KAAK,UAAU;IACf,IAAI,SAAS;IACb,OAAO,YAAY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AAiCD,eAAO,MAAM,sBAAsB,EAAE,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAI7E,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAOrF,CAAC"}
@@ -0,0 +1,9 @@
1
+ declare module '*.module.less' {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
5
+
6
+ declare module '*.less' {
7
+ const content: string;
8
+ export default content;
9
+ }
@@ -0,0 +1,25 @@
1
+ export declare const COLORS: {
2
+ danger: string;
3
+ disabled: string;
4
+ warning: string;
5
+ success: string;
6
+ tags: {
7
+ magenta: string;
8
+ red: string;
9
+ volcano: string;
10
+ orange: string;
11
+ gold: string;
12
+ lime: string;
13
+ green: string;
14
+ cyan: string;
15
+ blue: string;
16
+ geekblue: string;
17
+ purple: string;
18
+ processing: string;
19
+ success: string;
20
+ error: string;
21
+ warning: string;
22
+ default: string;
23
+ };
24
+ };
25
+ //# sourceMappingURL=colors.util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.util.d.ts","sourceRoot":"","sources":["colors.util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;CAuBlB,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Generic form instance interface — adapter-agnostic abstraction over antd FormInstance,
3
+ * react-hook-form, MUI form refs, etc.
4
+ */
5
+ export interface IFormInstance<T extends Record<string, unknown> = Record<string, unknown>> {
6
+ getFieldValue: (name: string | string[]) => unknown;
7
+ getFieldsValue: (allValues?: boolean) => T;
8
+ setFieldsValue: (values: Partial<T>) => void;
9
+ resetFields: (fields?: string[]) => void;
10
+ }
11
+ /**
12
+ * Merge form field name prefix with additional names.
13
+ */
14
+ export declare const mergeNames: (prefix: string[] | null, ...names: string[]) => string[];
15
+ /**
16
+ * Return a validation rule descriptor for required fields.
17
+ */
18
+ export declare const requiredField: (field: string, required?: boolean) => {
19
+ required: boolean;
20
+ message: string;
21
+ };
22
+ /**
23
+ * Return a placeholder string for a form field.
24
+ */
25
+ export declare const placeholderField: (field: string, fieldType?: 'input' | 'select') => string;
26
+ /**
27
+ * Check if a field is in the read-only list.
28
+ */
29
+ export declare const isReadOnlyField: (field: string, readOnlyFields: string[]) => boolean;
30
+ /**
31
+ * Set nested dynamic fields on a form instance.
32
+ * Replaces lodash _.set() usage.
33
+ */
34
+ export declare const setNestedDynamicFields: (formRef: IFormInstance, names: string | string[], value: unknown) => void;
35
+ /**
36
+ * Find a value in a nested object by path.
37
+ */
38
+ export declare const findFieldValue: (data: object, nested: string | string[]) => unknown;
39
+ //# sourceMappingURL=form.util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.util.d.ts","sourceRoot":"","sources":["form.util.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxF,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC;IACpD,cAAc,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC;IAC3C,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC7C,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,WAAY,MAAM,EAAE,GAAG,IAAI,YAAY,MAAM,EAAE,KAAG,MAAM,EAG9E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,UAAW,MAAM;;;CAGzC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,cAAa,OAAO,GAAG,QAAQ,WACd,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,kBAAkB,MAAM,EAAE,KAAG,OAC1C,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,sBAAsB,YACxB,aAAa,SACf,MAAM,GAAG,MAAM,EAAE,SACjB,OAAO,KACb,IAaF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,SAAU,MAAM,UAAU,MAAM,GAAG,MAAM,EAAE,KAAG,OAUxE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import dayjs from 'dayjs';
2
+ export declare const DEFAULT_DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm";
3
+ export declare const DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
4
+ export declare const NADate = "\u2014";
5
+ /**
6
+ * Format a number as a currency string.
7
+ */
8
+ export declare const numberToCurrency: (value: number, currency: string) => string;
9
+ export declare const tsToDate: (ts: Date | string | number | undefined) => string;
10
+ export declare const tsToTime: (ts: Date | string | number | undefined) => string;
11
+ export declare const tsToLocaleDateTime: (ts: Date | string | number | dayjs.Dayjs | undefined) => string;
12
+ /**
13
+ * Return true if the given date should be disabled (before today or before min).
14
+ */
15
+ export declare const getDisabledDate: (current: dayjs.Dayjs, min?: any) => boolean;
16
+ //# sourceMappingURL=format.util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.util.d.ts","sourceRoot":"","sources":["format.util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,wBAAwB,qBAAqB,CAAC;AAC3D,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAChD,eAAO,MAAM,MAAM,WAAM,CAAC;AAG1B;;GAEG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,YAAY,MAAM,KAAG,MAWlE,CAAC;AAcF,eAAO,MAAM,QAAQ,OAAQ,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,KAAG,MACnB,CAAC;AAChD,eAAO,MAAM,QAAQ,OAAQ,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,KAAG,MACnB,CAAC;AAChD,eAAO,MAAM,kBAAkB,OACzB,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,KAAK,GAAG,SAAS,KACnD,MAYF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,uCAA8C,OAGzE,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './form.util';
2
+ export * from './format.util';
3
+ export * from './colors.util';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@teamco/ischeduler-core",
3
+ "version": "2.0.1",
4
+ "description": "Headless core for iScheduler — types, utils, handlers, i18n, provider",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/teamco/ischeduler.git"
9
+ },
10
+ "author": "Vladimir Tkach",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "keywords": [
15
+ "react",
16
+ "scheduler",
17
+ "recurring events",
18
+ "headless",
19
+ "core"
20
+ ],
21
+ "type": "module",
22
+ "main": "dist/index.cjs.js",
23
+ "module": "dist/index.es.js",
24
+ "types": "dist/index.d.ts",
25
+ "source": "src/index.ts",
26
+ "exports": {
27
+ ".": {
28
+ "development": "./src/index.ts",
29
+ "import": "./dist/index.es.js",
30
+ "require": "./dist/index.cjs.js",
31
+ "types": "./dist/index.d.ts"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "scripts": {
38
+ "build": "tsc -p tsconfig.build.json --noEmit && vite build",
39
+ "test": "vitest run",
40
+ "test:watch": "vitest",
41
+ "lint": "eslint src/",
42
+ "format": "prettier --write \"src/**/*.{ts,tsx}\""
43
+ },
44
+ "peerDependencies": {
45
+ "dayjs": "^1.11.20",
46
+ "react": "^19.2.4",
47
+ "react-dom": "^19.2.4"
48
+ },
49
+ "dependencies": {
50
+ "classnames": "^2.5.1"
51
+ },
52
+ "devDependencies": {
53
+ "@testing-library/dom": "^10.4.1",
54
+ "@testing-library/jest-dom": "^6.9.1",
55
+ "@testing-library/react": "^16.3.2",
56
+ "dayjs": "^1.11.20",
57
+ "jsdom": "^29.0.0",
58
+ "less": "^4.6.4",
59
+ "vite": "^8.0.3",
60
+ "vite-plugin-dts": "^1.0.5",
61
+ "vitest": "^4.1.0"
62
+ }
63
+ }