UNPKG

react-antd-admin-panel

Version:

Modern TypeScript-first React admin panel builder with Ant Design 6

196 lines (195 loc) 5.87 kB
"use strict"; var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const list_index = require("./list/index.cjs"); const Switch = require("./Switch-COFRAt2B.cjs"); const Section = require("./Section-QsEya_jl.cjs"); const Loader = require("./Loader-md4nGsvL.cjs"); const Post = require("./Post-CeaBs_p4.cjs"); const ProtectedRoute = require("./ProtectedRoute-bxRuhSKp.cjs"); const MainContext = require("./MainContext-DBk-_ISe.cjs"); const useForm = require("./useForm-BOEfP6V1.cjs"); const useAccess = require("./useAccess-Bu6PpWEB.cjs"); const Protected = require("./Protected-Cf9XjIbv.cjs"); const formula_index = require("./formula/index.cjs"); const ActionButton = require("./ActionButton-DWH3-bPK.cjs"); const BaseBuilder = require("./BaseBuilder-ByZeEu3_.cjs"); const jsxRuntime = require("react/jsx-runtime"); const React = require("react"); class Condition extends BaseBuilder.BaseBuilder { constructor() { super(...arguments); __publicField(this, "_items", []); __publicField(this, "_default"); __publicField(this, "_data"); } /** * Add a conditional item */ add(key, condition, content) { this._items.push({ key, condition, content }); return this; } /** * Add a condition with content (fluent API) */ when(condition, content) { this._items.push({ condition, content }); return this; } /** * Set default content when no conditions match */ default(content) { this._default = content; return this; } /** * Alias for default() */ otherwise(content) { return this.default(content); } /** * Set data to evaluate conditions against */ data(value) { this._data = value; return this; } /** * Check which condition matches and return its content */ _resolveContent() { for (const item of this._items) { if (item.condition(this._data)) { return typeof item.content === "function" ? item.content() : item.content; } } if (this._default) { return typeof this._default === "function" ? this._default() : this._default; } return null; } /** * Clear all conditions */ clear() { this._items = []; this._default = void 0; return this; } /** * Get count of conditions */ count() { return this._items.length; } /** * Render the matching content */ render() { if (this._config.hidden) { return null; } return this._resolveContent(); } } class ConditionGroup extends BaseBuilder.BaseBuilder { constructor() { super(...arguments); __publicField(this, "_conditions", /* @__PURE__ */ new Map()); __publicField(this, "_activeKeys", []); } /** * Add a named condition */ add(key, condition, content) { this._conditions.set(key, { key, condition, content }); return this; } /** * Check conditions and update active items */ checkCondition(data) { this._activeKeys = []; for (const [key, item] of this._conditions.entries()) { if (item.condition(data)) { this._activeKeys.push(key); } } return this; } /** * Get currently active condition keys */ getActiveKeys() { return [...this._activeKeys]; } /** * Clear all conditions */ clear() { this._conditions.clear(); this._activeKeys = []; return this; } /** * Render all matching conditions */ render() { if (this._config.hidden) { return null; } return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: this._activeKeys.map((key, index) => { const item = this._conditions.get(key); if (!item) return null; const content = typeof item.content === "function" ? item.content() : item.content; return /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: content }, key || index); }) }); } } exports.List = list_index.List; exports.Checkbox = Switch.Checkbox; exports.CheckboxGroup = Switch.CheckboxGroup; exports.DatePicker = Switch.DatePicker; exports.FormFieldBuilder = Switch.FormFieldBuilder; exports.Input = Switch.Input; exports.Radio = Switch.RadioGroup; exports.RadioGroup = Switch.RadioGroup; exports.RangePicker = Switch.RangePicker; exports.Select = Switch.Select; exports.Switch = Switch.Switch; exports.TextArea = Switch.TextArea; exports.Section = Section.Section; exports.Loader = Loader.Loader; exports.Get = Post.Get; exports.Post = Post.Post; exports.AppLayout = ProtectedRoute.AppLayout; exports.Main = ProtectedRoute.Main; exports.ProfileMenu = ProtectedRoute.ProfileMenu; exports.Protected = ProtectedRoute.Protected; exports.ProtectedRoute = ProtectedRoute.ProtectedRoute; exports.GlobalStore = MainContext.GlobalStore; exports.MainContext = MainContext.MainContext; exports.MainProvider = MainContext.MainProvider; exports.UserState = MainContext.UserState; exports.useMain = MainContext.useMain; exports.useStore = MainContext.useStore; exports.useStoreActions = MainContext.useStoreActions; exports.useUser = MainContext.useUser; exports.useForm = useForm.useForm; exports.useGet = useForm.useGet; exports.useList = useForm.useList; exports.usePost = useForm.usePost; exports.useAccess = useAccess.useAccess; exports.AccessGuard = Protected.AccessGuard; exports.Formula = formula_index.Formula; exports.Action = ActionButton.Action; exports.ActionButton = ActionButton.ActionButton; exports.BaseBuilder = BaseBuilder.BaseBuilder; exports.Condition = Condition; exports.ConditionGroup = ConditionGroup; //# sourceMappingURL=index.cjs.map