@faasjs/ant-design 0.0.4-beta.9 → 0.0.5-beta.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.
package/dist/index.js CHANGED
@@ -55,57 +55,28 @@ function useDrawer(init) {
55
55
  }
56
56
  };
57
57
  }
58
- var AppContext = react$1.createContext({
59
- message: {},
60
- notification: {},
61
- setModalProps: () => void 0,
62
- setDrawerProps: () => void 0
63
- });
64
- function RoutesApp(props) {
65
- const location = reactRouterDom.useLocation();
66
- const { setDrawerProps, setModalProps } = useApp();
67
- react$1.useEffect(() => {
68
- console.debug("location", location);
69
- setDrawerProps({ open: false });
70
- setModalProps({ open: false });
71
- }, [location]);
72
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.children });
73
- }
74
- function App(props) {
75
- const [messageApi, messageContextHolder] = antd.message.useMessage();
76
- const [notificationApi, notificationContextHolder] = antd.notification.useNotification();
77
- const { modal, setModalProps } = useModal();
78
- const { drawer, setDrawerProps } = useDrawer();
79
- const memoizedContextValue = react$1.useMemo(
80
- () => ({
81
- message: messageApi,
82
- notification: notificationApi,
83
- setModalProps,
84
- setDrawerProps
85
- }),
86
- [messageApi, notificationApi, setModalProps, setDrawerProps]
87
- );
58
+ function ErrorChildren(props) {
88
59
  return /* @__PURE__ */ jsxRuntime.jsx(
89
- cssinjs.StyleProvider,
60
+ antd.Alert,
90
61
  {
91
- ...Object.assign(props.styleProviderProps || {}, {
92
- hashPriority: "high",
93
- transformers: [cssinjs.legacyLogicalPropertiesTransformer]
94
- }),
95
- children: /* @__PURE__ */ jsxRuntime.jsx(antd.ConfigProvider, { ...props.configProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(AppContext.Provider, { value: memoizedContextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.BrowserRouter, { ...props.browserRouterProps, children: [
96
- messageContextHolder,
97
- notificationContextHolder,
98
- modal,
99
- drawer,
100
- /* @__PURE__ */ jsxRuntime.jsx(RoutesApp, { children: props.children })
101
- ] }) }) })
62
+ type: "error",
63
+ message: props.errorMessage,
64
+ description: /* @__PURE__ */ jsxRuntime.jsx(
65
+ "pre",
66
+ {
67
+ style: {
68
+ fontSize: "0.9em",
69
+ overflowX: "auto"
70
+ },
71
+ children: props.errorDescription
72
+ }
73
+ )
102
74
  }
103
75
  );
104
76
  }
105
- function useApp() {
106
- return react$1.useContext(AppContext);
77
+ function ErrorBoundary(props) {
78
+ return /* @__PURE__ */ jsxRuntime.jsx(react.ErrorBoundary, { errorChildren: /* @__PURE__ */ jsxRuntime.jsx(ErrorChildren, {}), ...props });
107
79
  }
108
- App.useApp = useApp;
109
80
  var isZH = /^zh/i.test(navigator.language);
110
81
  var zh = {
111
82
  lang: "zh",
@@ -132,8 +103,7 @@ var en = {
132
103
  reset: "Reset"
133
104
  };
134
105
  var common = isZH ? zh : en;
135
- var baseConfig = {
136
- antd: {},
106
+ var baseTheme = {
137
107
  lang: "en",
138
108
  common,
139
109
  Blank: { text: common.blank },
@@ -144,37 +114,92 @@ var baseConfig = {
144
114
  },
145
115
  Link: { style: {} }
146
116
  };
147
- var ConfigContext = react$1.createContext(baseConfig);
148
- function ConfigProvider2({
149
- config,
150
- children
151
- }) {
152
- const [values, setValues] = react$1.useState(baseConfig);
117
+ var ConfigContext = react$1.createContext({
118
+ theme: baseTheme
119
+ });
120
+ function ConfigProvider(props) {
121
+ const [theme, setTheme] = react$1.useState();
153
122
  react$1.useEffect(() => {
154
- if (config.lang === "zh") {
155
- setValues(
123
+ var _a;
124
+ if (((_a = props.theme) == null ? void 0 : _a.lang) === "zh") {
125
+ setTheme(
156
126
  lodashEs.defaultsDeep(
157
- config,
127
+ props.theme,
158
128
  {
159
129
  lang: "zh",
160
130
  common: zh,
161
131
  Blank: { text: zh.blank },
162
132
  Form: { submit: { text: zh.submit } }
163
133
  },
164
- baseConfig
134
+ baseTheme
165
135
  )
166
136
  );
167
137
  } else
168
- setValues(lodashEs.defaultsDeep(config, values));
169
- }, []);
170
- return /* @__PURE__ */ jsxRuntime.jsx(ConfigContext.Provider, { value: values, children });
138
+ setTheme(lodashEs.defaultsDeep(props.theme, baseTheme));
139
+ if (props.faasClientOptions)
140
+ react.FaasReactClient(props.faasClientOptions);
141
+ }, [JSON.stringify(props.theme)]);
142
+ if (!theme)
143
+ return null;
144
+ return /* @__PURE__ */ jsxRuntime.jsx(ConfigContext.Provider, { value: { theme }, children: props.children });
171
145
  }
172
146
  function useConfigContext() {
173
147
  return react$1.useContext(ConfigContext);
174
148
  }
149
+ var AppContext = react$1.createContext({
150
+ message: {},
151
+ notification: {},
152
+ setModalProps: () => void 0,
153
+ setDrawerProps: () => void 0
154
+ });
155
+ function RoutesApp(props) {
156
+ const location = reactRouterDom.useLocation();
157
+ const { setDrawerProps, setModalProps } = useApp();
158
+ react$1.useEffect(() => {
159
+ console.debug("location", location);
160
+ setDrawerProps({ open: false });
161
+ setModalProps({ open: false });
162
+ }, [location]);
163
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.children });
164
+ }
165
+ function App(props) {
166
+ const [messageApi, messageContextHolder] = antd.message.useMessage();
167
+ const [notificationApi, notificationContextHolder] = antd.notification.useNotification();
168
+ const { modal, setModalProps } = useModal();
169
+ const { drawer, setDrawerProps } = useDrawer();
170
+ const memoizedContextValue = react$1.useMemo(
171
+ () => ({
172
+ message: messageApi,
173
+ notification: notificationApi,
174
+ setModalProps,
175
+ setDrawerProps
176
+ }),
177
+ [messageApi, notificationApi, setModalProps, setDrawerProps]
178
+ );
179
+ return /* @__PURE__ */ jsxRuntime.jsx(
180
+ cssinjs.StyleProvider,
181
+ {
182
+ ...Object.assign(props.styleProviderProps || {}, {
183
+ hashPriority: "high",
184
+ transformers: [cssinjs.legacyLogicalPropertiesTransformer]
185
+ }),
186
+ children: /* @__PURE__ */ jsxRuntime.jsx(antd.ConfigProvider, { ...props.configProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(AppContext.Provider, { value: memoizedContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(ConfigProvider, { ...props.faasConfigProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { ...props.errorBoundaryProps, children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.BrowserRouter, { ...props.browserRouterProps, children: [
187
+ messageContextHolder,
188
+ notificationContextHolder,
189
+ modal,
190
+ drawer,
191
+ /* @__PURE__ */ jsxRuntime.jsx(RoutesApp, { children: props.children })
192
+ ] }) }) }) }) })
193
+ }
194
+ );
195
+ }
196
+ function useApp() {
197
+ return react$1.useContext(AppContext);
198
+ }
199
+ App.useApp = useApp;
175
200
  function Blank(options) {
176
- const { Blank: Blank2 } = useConfigContext();
177
- return !options || lodashEs.isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { disabled: true, children: (options == null ? void 0 : options.text) || Blank2.text }) : options.value;
201
+ const { theme } = useConfigContext();
202
+ return !options || lodashEs.isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { disabled: true, children: (options == null ? void 0 : options.text) || theme.Blank.text }) : options.value;
178
203
  }
179
204
  function transferOptions(options) {
180
205
  if (!options)
@@ -256,7 +281,7 @@ function DescriptionItemContent(props) {
256
281
  }, [props]);
257
282
  if (!computedProps)
258
283
  return null;
259
- if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type])
284
+ if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type]) {
260
285
  if (computedProps.extendTypes[computedProps.item.type].children)
261
286
  return react$1.cloneElement(
262
287
  computedProps.extendTypes[computedProps.item.type].children,
@@ -266,15 +291,15 @@ function DescriptionItemContent(props) {
266
291
  values: computedProps.values
267
292
  }
268
293
  );
269
- else if (computedProps.extendTypes[computedProps.item.type].render)
294
+ if (computedProps.extendTypes[computedProps.item.type].render)
270
295
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: computedProps.extendTypes[computedProps.item.type].render(
271
296
  computedProps.value,
272
297
  computedProps.values,
273
298
  0,
274
299
  "description"
275
300
  ) });
276
- else
277
- throw Error(`${computedProps.item.type} requires children or render`);
301
+ throw Error(`${computedProps.item.type} requires children or render`);
302
+ }
278
303
  if (computedProps.item.descriptionChildren === null)
279
304
  return null;
280
305
  if (computedProps.item.descriptionChildren)
@@ -396,28 +421,6 @@ function Description(props) {
396
421
  }
397
422
  );
398
423
  }
399
- function ErrorChildren(props) {
400
- return /* @__PURE__ */ jsxRuntime.jsx(
401
- antd.Alert,
402
- {
403
- type: "error",
404
- message: props.errorMessage,
405
- description: /* @__PURE__ */ jsxRuntime.jsx(
406
- "pre",
407
- {
408
- style: {
409
- fontSize: "0.9em",
410
- overflowX: "auto"
411
- },
412
- children: props.errorDescription
413
- }
414
- )
415
- }
416
- );
417
- }
418
- function ErrorBoundary(props) {
419
- return /* @__PURE__ */ jsxRuntime.jsx(react.ErrorBoundary, { errorChildren: /* @__PURE__ */ jsxRuntime.jsx(ErrorChildren, {}), ...props });
420
- }
421
424
  function processProps(propsCopy, config) {
422
425
  if (!propsCopy.title)
423
426
  propsCopy.title = lodashEs.upperFirst(propsCopy.id);
@@ -472,7 +475,7 @@ function FormItem(props) {
472
475
  var _a;
473
476
  const [computedProps, setComputedProps] = react$1.useState();
474
477
  const [extendTypes, setExtendTypes] = react$1.useState();
475
- const { common: common2 } = useConfigContext();
478
+ const { theme } = useConfigContext();
476
479
  const [hidden, setHidden] = react$1.useState(props.hidden || false);
477
480
  react$1.useEffect(() => {
478
481
  const propsCopy = { ...props };
@@ -493,7 +496,7 @@ function FormItem(props) {
493
496
  delete propsCopy.if;
494
497
  delete propsCopy.hidden;
495
498
  }
496
- setComputedProps(processProps(propsCopy, common2));
499
+ setComputedProps(processProps(propsCopy, theme.common));
497
500
  }, [props]);
498
501
  if (!computedProps)
499
502
  return null;
@@ -673,7 +676,7 @@ function FormItem(props) {
673
676
  danger: true,
674
677
  type: "link",
675
678
  onClick: () => remove(field.name),
676
- children: common2.delete
679
+ children: theme.common.delete
677
680
  }
678
681
  )
679
682
  ] }) }),
@@ -688,7 +691,7 @@ function FormItem(props) {
688
691
  onClick: () => add(),
689
692
  icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {}),
690
693
  children: [
691
- common2.add,
694
+ theme.common.add,
692
695
  " ",
693
696
  computedProps.label
694
697
  ]
@@ -829,7 +832,7 @@ function Form(props) {
829
832
  )
830
833
  ),
831
834
  computedProps.children,
832
- computedProps.submit !== false && /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { htmlType: "submit", type: "primary", loading, children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text }),
835
+ computedProps.submit !== false && /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { htmlType: "submit", type: "primary", loading, children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.theme.Form.submit.text }),
833
836
  computedProps.footer
834
837
  ] });
835
838
  }
@@ -841,11 +844,11 @@ Form.List = antd.Form.List;
841
844
  Form.ErrorList = antd.Form.ErrorList;
842
845
  Form.Provider = antd.Form.Provider;
843
846
  function Link(props) {
844
- var _a, _b;
845
- const { Link: Config } = useConfigContext();
847
+ var _a, _b, _c, _d, _e, _f, _g;
848
+ const { theme } = useConfigContext();
846
849
  const navigate = reactRouterDom.useNavigate();
847
850
  let computedStyle = {
848
- ...Config.style || {},
851
+ ...theme.Link.style || {},
849
852
  cursor: "pointer",
850
853
  ...props.style
851
854
  };
@@ -863,11 +866,11 @@ function Link(props) {
863
866
  antd.Button,
864
867
  {
865
868
  ...props.button,
866
- target: props.target || (Config == null ? void 0 : Config.target) || "_blank",
869
+ target: props.target || ((_a = theme.Link) == null ? void 0 : _a.target) || "_blank",
867
870
  style: computedStyle,
868
871
  href: props.href,
869
872
  onClick: props.onClick,
870
- children: (_a = props.text) != null ? _a : props.children
873
+ children: (_b = props.text) != null ? _b : props.children
871
874
  }
872
875
  );
873
876
  if (props.children)
@@ -877,7 +880,7 @@ function Link(props) {
877
880
  "a",
878
881
  {
879
882
  href: props.href,
880
- target: props.target || (Config == null ? void 0 : Config.target),
883
+ target: props.target || ((_c = theme.Link) == null ? void 0 : _c.target),
881
884
  style: computedStyle,
882
885
  onClick: props.onClick,
883
886
  children: props.children
@@ -888,7 +891,7 @@ function Link(props) {
888
891
  antd.Typography.Link,
889
892
  {
890
893
  href: props.href,
891
- target: props.target || (Config == null ? void 0 : Config.target) || "_blank",
894
+ target: props.target || ((_d = theme.Link) == null ? void 0 : _d.target) || "_blank",
892
895
  style: computedStyle,
893
896
  copyable: props.copyable,
894
897
  onClick: props.onClick,
@@ -902,8 +905,11 @@ function Link(props) {
902
905
  {
903
906
  ...props.button,
904
907
  style: computedStyle,
905
- onClick: (e) => props.onClick ? props.onClick(e) : (props.target || (Config == null ? void 0 : Config.target)) === "_blank" ? window.open(props.href) : navigate(props.href),
906
- children: (_b = props.text) != null ? _b : props.children
908
+ onClick: (e) => {
909
+ var _a2;
910
+ return props.onClick ? props.onClick(e) : (props.target || ((_a2 = theme.Link) == null ? void 0 : _a2.target)) === "_blank" ? window.open(props.href) : navigate(props.href);
911
+ },
912
+ children: (_e = props.text) != null ? _e : props.children
907
913
  }
908
914
  );
909
915
  if (props.children)
@@ -911,7 +917,7 @@ function Link(props) {
911
917
  reactRouterDom.Link,
912
918
  {
913
919
  to: props.href,
914
- target: props.target || (Config == null ? void 0 : Config.target),
920
+ target: props.target || ((_f = theme.Link) == null ? void 0 : _f.target),
915
921
  style: computedStyle,
916
922
  onClick: props.onClick,
917
923
  children: props.children
@@ -921,15 +927,16 @@ function Link(props) {
921
927
  antd.Typography.Link,
922
928
  {
923
929
  href: props.href,
924
- target: props.target || (Config == null ? void 0 : Config.target),
930
+ target: props.target || ((_g = theme.Link) == null ? void 0 : _g.target),
925
931
  style: computedStyle,
926
932
  copyable: props.copyable,
927
933
  onClick: (e) => {
934
+ var _a2;
928
935
  if (props.onClick) {
929
936
  props.onClick(e);
930
937
  return;
931
938
  }
932
- if ((props.target || (Config == null ? void 0 : Config.target)) !== "_blank") {
939
+ if ((props.target || ((_a2 = theme.Link) == null ? void 0 : _a2.target)) !== "_blank") {
933
940
  e.preventDefault();
934
941
  navigate(props.href);
935
942
  }
@@ -939,8 +946,8 @@ function Link(props) {
939
946
  );
940
947
  }
941
948
  function PageNotFound() {
942
- const config = useConfigContext();
943
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Result, { status: "404", title: config.common.pageNotFound });
949
+ const { theme } = useConfigContext();
950
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Result, { status: "404", title: theme.common.pageNotFound });
944
951
  }
945
952
  function Routes(props) {
946
953
  return /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
@@ -987,9 +994,9 @@ function processValue(item, value) {
987
994
  }
988
995
  function Table(props) {
989
996
  const [columns, setColumns] = react$1.useState();
990
- const { common: common2 } = useConfigContext();
997
+ const { theme } = useConfigContext();
991
998
  const generateFilterDropdown = (item) => {
992
- if (typeof item.filterDropdown !== "undefined")
999
+ if (item.filterDropdown && item.filterDropdown !== true)
993
1000
  return;
994
1001
  if (item.options.length < 11) {
995
1002
  if (!item.filters)
@@ -1014,7 +1021,7 @@ function Table(props) {
1014
1021
  allowClear: true,
1015
1022
  showSearch: true,
1016
1023
  style: { width: "100%" },
1017
- placeholder: `${common2.search} ${item.title}`,
1024
+ placeholder: `${theme.common.search} ${item.title}`,
1018
1025
  value: selectedKeys,
1019
1026
  onChange: (v) => {
1020
1027
  setSelectedKeys((v == null ? void 0 : v.length) ? v : []);
@@ -1088,146 +1095,146 @@ function Table(props) {
1088
1095
  case "string":
1089
1096
  if (!item.render)
1090
1097
  item.render = (value) => processValue(item, value);
1091
- if (!item.onFilter)
1092
- item.onFilter = (value, row) => {
1093
- if (!value || lodashEs.isNil(value))
1094
- return true;
1095
- if (lodashEs.isNil(row[item.id]))
1096
- return false;
1097
- return row[item.id].trim().toLowerCase().includes(value.trim().toLowerCase());
1098
- };
1099
- if (item.filterDropdown === false || item.filterDropdown)
1100
- break;
1101
- if (!item.filters && item.optionsType !== "auto")
1102
- item.filterDropdown = ({
1103
- setSelectedKeys,
1104
- confirm,
1105
- clearFilters
1106
- }) => /* @__PURE__ */ jsxRuntime.jsx(
1107
- antd.Input.Search,
1108
- {
1109
- placeholder: `${common2.search} ${item.title}`,
1110
- allowClear: true,
1111
- onSearch: (v) => {
1112
- if (v) {
1113
- setSelectedKeys([v]);
1114
- } else {
1115
- setSelectedKeys([]);
1116
- clearFilters();
1098
+ if (item.filterDropdown !== false) {
1099
+ if (!item.onFilter)
1100
+ item.onFilter = (value, row) => {
1101
+ if (!value || lodashEs.isNil(value))
1102
+ return true;
1103
+ if (lodashEs.isNil(row[item.id]))
1104
+ return false;
1105
+ return row[item.id].trim().toLowerCase().includes(value.trim().toLowerCase());
1106
+ };
1107
+ if (typeof item.filterDropdown === "undefined" && !item.filters && item.optionsType !== "auto")
1108
+ item.filterDropdown = ({
1109
+ setSelectedKeys,
1110
+ confirm,
1111
+ clearFilters
1112
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1113
+ antd.Input.Search,
1114
+ {
1115
+ placeholder: `${theme.common.search} ${item.title}`,
1116
+ allowClear: true,
1117
+ onSearch: (v) => {
1118
+ if (v) {
1119
+ setSelectedKeys([v]);
1120
+ } else {
1121
+ setSelectedKeys([]);
1122
+ clearFilters();
1123
+ }
1124
+ confirm();
1117
1125
  }
1118
- confirm();
1119
1126
  }
1120
- }
1121
- );
1127
+ );
1128
+ }
1122
1129
  break;
1123
1130
  case "string[]":
1124
1131
  if (!item.render)
1125
1132
  item.render = (value) => processValue(item, value);
1126
- if (!item.onFilter)
1127
- item.onFilter = (value, row) => {
1128
- if (value === null && (!row[item.id] || !row[item.id].length))
1129
- return true;
1130
- if (!row[item.id] || !row[item.id].length || !value)
1131
- return false;
1132
- return row[item.id].some(
1133
- (v) => v.trim().toLowerCase().includes(value.trim().toLowerCase())
1134
- );
1135
- };
1136
- if (item.filterDropdown === false || item.filterDropdown)
1137
- break;
1138
- if (!item.filters && item.optionsType !== "auto")
1139
- item.filterDropdown = ({
1140
- setSelectedKeys,
1141
- confirm,
1142
- clearFilters
1143
- }) => /* @__PURE__ */ jsxRuntime.jsx(
1144
- antd.Input.Search,
1145
- {
1146
- placeholder: `${common2.search} ${item.title}`,
1147
- allowClear: true,
1148
- onSearch: (v) => {
1149
- if (v) {
1150
- setSelectedKeys([v]);
1151
- } else {
1152
- setSelectedKeys([]);
1153
- clearFilters();
1133
+ if (item.filterDropdown !== false) {
1134
+ if (!item.onFilter)
1135
+ item.onFilter = (value, row) => {
1136
+ if (value === null && (!row[item.id] || !row[item.id].length))
1137
+ return true;
1138
+ if (!row[item.id] || !row[item.id].length || !value)
1139
+ return false;
1140
+ return row[item.id].some(
1141
+ (v) => v.trim().toLowerCase().includes(value.trim().toLowerCase())
1142
+ );
1143
+ };
1144
+ if (typeof item.filterDropdown === "undefined" && !item.filters && item.optionsType !== "auto")
1145
+ item.filterDropdown = ({
1146
+ setSelectedKeys,
1147
+ confirm,
1148
+ clearFilters
1149
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1150
+ antd.Input.Search,
1151
+ {
1152
+ placeholder: `${theme.common.search} ${item.title}`,
1153
+ allowClear: true,
1154
+ onSearch: (v) => {
1155
+ if (v) {
1156
+ setSelectedKeys([v]);
1157
+ } else {
1158
+ setSelectedKeys([]);
1159
+ clearFilters();
1160
+ }
1161
+ confirm();
1154
1162
  }
1155
- confirm();
1156
1163
  }
1157
- }
1158
- );
1164
+ );
1165
+ }
1159
1166
  break;
1160
1167
  case "number":
1161
1168
  if (!item.render)
1162
1169
  item.render = (value) => processValue(item, value);
1163
- if (!item.sorter)
1170
+ if (typeof item.sorter === "undefined")
1164
1171
  item.sorter = (a, b) => a[item.id] - b[item.id];
1165
- if (!item.onFilter)
1166
- item.onFilter = (value, row) => {
1167
- if (value === null)
1168
- return true;
1169
- if (lodashEs.isNil(row[item.id]))
1170
- return false;
1171
- return value == row[item.id];
1172
- };
1173
- if (item.filterDropdown === false || item.filterDropdown)
1174
- break;
1175
- if (!item.filters)
1176
- item.filterDropdown = ({
1177
- setSelectedKeys,
1178
- confirm,
1179
- clearFilters
1180
- }) => /* @__PURE__ */ jsxRuntime.jsx(
1181
- antd.Input.Search,
1182
- {
1183
- placeholder: `${common2.search} ${item.title}`,
1184
- allowClear: true,
1185
- onSearch: (v) => {
1186
- if (v) {
1187
- setSelectedKeys([Number(v)]);
1188
- } else {
1189
- setSelectedKeys([]);
1190
- clearFilters();
1172
+ if (item.filterDropdown !== false) {
1173
+ if (!item.onFilter)
1174
+ item.onFilter = (value, row) => {
1175
+ if (value === null)
1176
+ return true;
1177
+ if (lodashEs.isNil(row[item.id]))
1178
+ return false;
1179
+ return value == row[item.id];
1180
+ };
1181
+ if (typeof item.filterDropdown === "undefined" && !item.filters)
1182
+ item.filterDropdown = ({
1183
+ setSelectedKeys,
1184
+ confirm,
1185
+ clearFilters
1186
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1187
+ antd.Input.Search,
1188
+ {
1189
+ placeholder: `${theme.common.search} ${item.title}`,
1190
+ allowClear: true,
1191
+ onSearch: (v) => {
1192
+ if (v) {
1193
+ setSelectedKeys([Number(v)]);
1194
+ } else {
1195
+ setSelectedKeys([]);
1196
+ clearFilters();
1197
+ }
1198
+ confirm();
1191
1199
  }
1192
- confirm();
1193
1200
  }
1194
- }
1195
- );
1201
+ );
1202
+ }
1196
1203
  break;
1197
1204
  case "number[]":
1198
1205
  if (!item.render)
1199
1206
  item.render = (value) => processValue(item, value).join(", ");
1200
- if (!item.onFilter)
1201
- item.onFilter = (value, row) => {
1202
- if (value === null && (!row[item.id] || !row[item.id].length))
1203
- return true;
1204
- if (!row[item.id] || !row[item.id].length)
1205
- return false;
1206
- return row[item.id].includes(Number(value));
1207
- };
1208
- if (item.filterDropdown === false || item.filterDropdown)
1209
- break;
1210
- if (!item.filters)
1211
- item.filterDropdown = ({
1212
- setSelectedKeys,
1213
- confirm,
1214
- clearFilters
1215
- }) => /* @__PURE__ */ jsxRuntime.jsx(
1216
- antd.Input.Search,
1217
- {
1218
- placeholder: `${common2.search} ${item.title}`,
1219
- allowClear: true,
1220
- onSearch: (v) => {
1221
- if (v) {
1222
- setSelectedKeys([Number(v)]);
1223
- } else {
1224
- setSelectedKeys([]);
1225
- clearFilters();
1207
+ if (item.filterDropdown !== false) {
1208
+ if (!item.onFilter)
1209
+ item.onFilter = (value, row) => {
1210
+ if (value === null && (!row[item.id] || !row[item.id].length))
1211
+ return true;
1212
+ if (!row[item.id] || !row[item.id].length)
1213
+ return false;
1214
+ return row[item.id].includes(Number(value));
1215
+ };
1216
+ if (typeof item.filterDropdown === "undefined" && !item.filters)
1217
+ item.filterDropdown = ({
1218
+ setSelectedKeys,
1219
+ confirm,
1220
+ clearFilters
1221
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1222
+ antd.Input.Search,
1223
+ {
1224
+ placeholder: `${theme.common.search} ${item.title}`,
1225
+ allowClear: true,
1226
+ onSearch: (v) => {
1227
+ if (v) {
1228
+ setSelectedKeys([Number(v)]);
1229
+ } else {
1230
+ setSelectedKeys([]);
1231
+ clearFilters();
1232
+ }
1233
+ confirm();
1226
1234
  }
1227
- confirm();
1228
1235
  }
1229
- }
1230
- );
1236
+ );
1237
+ }
1231
1238
  break;
1232
1239
  case "boolean":
1233
1240
  if (!item.render)
@@ -1248,68 +1255,70 @@ function Table(props) {
1248
1255
  }
1249
1256
  }
1250
1257
  );
1251
- if (item.filterDropdown !== false)
1252
- item.filterDropdown = ({
1253
- setSelectedKeys,
1254
- selectedKeys,
1255
- confirm
1256
- }) => /* @__PURE__ */ jsxRuntime.jsxs(
1257
- antd.Radio.Group,
1258
- {
1259
- style: { padding: 8 },
1260
- buttonStyle: "solid",
1261
- value: JSON.stringify(selectedKeys[0]),
1262
- onChange: (e) => {
1263
- const Values = {
1264
- true: true,
1265
- false: false,
1266
- null: null
1267
- };
1268
- setSelectedKeys(
1269
- e.target.value ? [Values[e.target.value]] : []
1270
- );
1271
- confirm();
1272
- },
1273
- children: [
1274
- /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { children: common2.all }),
1275
- /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "true", children: /* @__PURE__ */ jsxRuntime.jsx(
1276
- icons.CheckOutlined,
1277
- {
1278
- style: {
1279
- color: "#52c41a",
1280
- verticalAlign: "middle"
1258
+ if (item.filterDropdown !== false) {
1259
+ if (typeof item.filterDropdown === "undefined")
1260
+ item.filterDropdown = ({
1261
+ setSelectedKeys,
1262
+ selectedKeys,
1263
+ confirm
1264
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(
1265
+ antd.Radio.Group,
1266
+ {
1267
+ style: { padding: 8 },
1268
+ buttonStyle: "solid",
1269
+ value: JSON.stringify(selectedKeys[0]),
1270
+ onChange: (e) => {
1271
+ const Values = {
1272
+ true: true,
1273
+ false: false,
1274
+ null: null
1275
+ };
1276
+ setSelectedKeys(
1277
+ e.target.value ? [Values[e.target.value]] : []
1278
+ );
1279
+ confirm();
1280
+ },
1281
+ children: [
1282
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { children: theme.common.all }),
1283
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "true", children: /* @__PURE__ */ jsxRuntime.jsx(
1284
+ icons.CheckOutlined,
1285
+ {
1286
+ style: {
1287
+ color: "#52c41a",
1288
+ verticalAlign: "middle"
1289
+ }
1281
1290
  }
1282
- }
1283
- ) }),
1284
- /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "false", children: /* @__PURE__ */ jsxRuntime.jsx(
1285
- icons.CloseOutlined,
1286
- {
1287
- style: {
1288
- verticalAlign: "middle",
1289
- color: "#ff4d4f"
1291
+ ) }),
1292
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "false", children: /* @__PURE__ */ jsxRuntime.jsx(
1293
+ icons.CloseOutlined,
1294
+ {
1295
+ style: {
1296
+ verticalAlign: "middle",
1297
+ color: "#ff4d4f"
1298
+ }
1290
1299
  }
1291
- }
1292
- ) }),
1293
- /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "null", children: common2.blank })
1294
- ]
1295
- }
1296
- );
1297
- if (!item.onFilter)
1298
- item.onFilter = (value, row) => {
1299
- switch (value) {
1300
- case true:
1301
- return !lodashEs.isNil(row[item.id]) && row[item.id] !== false;
1302
- case false:
1303
- return !lodashEs.isNil(row[item.id]) && !row[item.id];
1304
- default:
1305
- return lodashEs.isNil(row[item.id]);
1306
- }
1307
- };
1300
+ ) }),
1301
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "null", children: theme.common.blank })
1302
+ ]
1303
+ }
1304
+ );
1305
+ if (!item.onFilter)
1306
+ item.onFilter = (value, row) => {
1307
+ switch (value) {
1308
+ case true:
1309
+ return !lodashEs.isNil(row[item.id]) && row[item.id] !== false;
1310
+ case false:
1311
+ return !lodashEs.isNil(row[item.id]) && !row[item.id];
1312
+ default:
1313
+ return lodashEs.isNil(row[item.id]);
1314
+ }
1315
+ };
1316
+ }
1308
1317
  break;
1309
1318
  case "date":
1310
1319
  if (!item.render)
1311
1320
  item.render = (value) => processValue(item, value);
1312
- if (!item.sorter)
1321
+ if (typeof item.sorter === "undefined")
1313
1322
  item.sorter = (a, b, order) => {
1314
1323
  if (lodashEs.isNil(a[item.id]))
1315
1324
  return order === "ascend" ? 1 : -1;
@@ -1317,36 +1326,38 @@ function Table(props) {
1317
1326
  return order === "ascend" ? -1 : 1;
1318
1327
  return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
1319
1328
  };
1320
- if (!item.filterDropdown)
1321
- item.filterDropdown = ({ setSelectedKeys, confirm }) => /* @__PURE__ */ jsxRuntime.jsx(
1322
- antd.DatePicker.RangePicker,
1323
- {
1324
- onChange: (dates) => {
1325
- setSelectedKeys(
1326
- (dates == null ? void 0 : dates[0]) && dates[1] ? [
1327
- [
1328
- dates[0].startOf("day").toISOString(),
1329
- dates[1].endOf("day").toISOString()
1330
- ]
1331
- ] : []
1332
- );
1333
- confirm();
1329
+ if (item.filterDropdown !== false) {
1330
+ if (typeof item.filterDropdown === "undefined")
1331
+ item.filterDropdown = ({ setSelectedKeys, confirm }) => /* @__PURE__ */ jsxRuntime.jsx(
1332
+ antd.DatePicker.RangePicker,
1333
+ {
1334
+ onChange: (dates) => {
1335
+ setSelectedKeys(
1336
+ (dates == null ? void 0 : dates[0]) && dates[1] ? [
1337
+ [
1338
+ dates[0].startOf("day").toISOString(),
1339
+ dates[1].endOf("day").toISOString()
1340
+ ]
1341
+ ] : []
1342
+ );
1343
+ confirm();
1344
+ }
1334
1345
  }
1335
- }
1336
- );
1337
- if (!item.onFilter)
1338
- item.onFilter = (value, row) => {
1339
- if (lodashEs.isNil(value[0]))
1340
- return true;
1341
- if (lodashEs.isNil(row[item.id]))
1342
- return false;
1343
- return dayjs2__default.default(row[item.id]) >= dayjs2__default.default(value[0]) && dayjs2__default.default(row[item.id]) <= dayjs2__default.default(value[1]);
1344
- };
1346
+ );
1347
+ if (!item.onFilter)
1348
+ item.onFilter = (value, row) => {
1349
+ if (lodashEs.isNil(value[0]))
1350
+ return true;
1351
+ if (lodashEs.isNil(row[item.id]))
1352
+ return false;
1353
+ return dayjs2__default.default(row[item.id]) >= dayjs2__default.default(value[0]) && dayjs2__default.default(row[item.id]) <= dayjs2__default.default(value[1]);
1354
+ };
1355
+ }
1345
1356
  break;
1346
1357
  case "time":
1347
1358
  if (!item.render)
1348
1359
  item.render = (value) => processValue(item, value);
1349
- if (!item.sorter)
1360
+ if (typeof item.sorter === "undefined")
1350
1361
  item.sorter = (a, b, order) => {
1351
1362
  if (lodashEs.isNil(a[item.id]))
1352
1363
  return order === "ascend" ? 1 : -1;
@@ -1354,31 +1365,33 @@ function Table(props) {
1354
1365
  return order === "ascend" ? -1 : 1;
1355
1366
  return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
1356
1367
  };
1357
- if (!item.filterDropdown)
1358
- item.filterDropdown = ({ setSelectedKeys, confirm }) => /* @__PURE__ */ jsxRuntime.jsx(
1359
- antd.DatePicker.RangePicker,
1360
- {
1361
- onChange: (dates) => {
1362
- setSelectedKeys(
1363
- (dates == null ? void 0 : dates[0]) && dates[1] ? [
1364
- [
1365
- dates[0].startOf("day").toISOString(),
1366
- dates[1].endOf("day").toISOString()
1367
- ]
1368
- ] : []
1369
- );
1370
- confirm();
1368
+ if (item.filterDropdown !== false) {
1369
+ if (typeof item.filterDropdown === "undefined")
1370
+ item.filterDropdown = ({ setSelectedKeys, confirm }) => /* @__PURE__ */ jsxRuntime.jsx(
1371
+ antd.DatePicker.RangePicker,
1372
+ {
1373
+ onChange: (dates) => {
1374
+ setSelectedKeys(
1375
+ (dates == null ? void 0 : dates[0]) && dates[1] ? [
1376
+ [
1377
+ dates[0].startOf("day").toISOString(),
1378
+ dates[1].endOf("day").toISOString()
1379
+ ]
1380
+ ] : []
1381
+ );
1382
+ confirm();
1383
+ }
1371
1384
  }
1372
- }
1373
- );
1374
- if (!item.onFilter)
1375
- item.onFilter = (value, row) => {
1376
- if (lodashEs.isNil(value[0]))
1377
- return true;
1378
- if (lodashEs.isNil(row[item.id]))
1379
- return false;
1380
- return dayjs2__default.default(row[item.id]) >= dayjs2__default.default(value[0]) && dayjs2__default.default(row[item.id]) <= dayjs2__default.default(value[1]);
1381
- };
1385
+ );
1386
+ if (!item.onFilter)
1387
+ item.onFilter = (value, row) => {
1388
+ if (lodashEs.isNil(value[0]))
1389
+ return true;
1390
+ if (lodashEs.isNil(row[item.id]))
1391
+ return false;
1392
+ return dayjs2__default.default(row[item.id]) >= dayjs2__default.default(value[0]) && dayjs2__default.default(row[item.id]) <= dayjs2__default.default(value[1]);
1393
+ };
1394
+ }
1382
1395
  break;
1383
1396
  case "object":
1384
1397
  if (!item.render)
@@ -1406,7 +1419,7 @@ function Table(props) {
1406
1419
  default:
1407
1420
  if (!item.render)
1408
1421
  item.render = (value) => processValue(item, value);
1409
- if (!item.onFilter)
1422
+ if (item.filterDropdown !== false && !item.onFilter)
1410
1423
  item.onFilter = (value, row) => {
1411
1424
  if (value === null && lodashEs.isNil(row[item.id]))
1412
1425
  return true;
@@ -1467,8 +1480,8 @@ function FaasDataTable({
1467
1480
  const newColumns = [...prev];
1468
1481
  for (const column of newColumns) {
1469
1482
  if ((_a = data.options) == null ? void 0 : _a[column.id]) {
1470
- column.options = data.options[column.id];
1471
- column.filters = data.options[column.id].map((v) => ({
1483
+ column.options = transferOptions(data.options[column.id]);
1484
+ column.filters = column.options.map((v) => ({
1472
1485
  text: v.label,
1473
1486
  value: v.value
1474
1487
  })).concat({
@@ -1565,10 +1578,10 @@ function Tabs(props) {
1565
1578
  );
1566
1579
  }
1567
1580
  function Title(props) {
1568
- const { Title: Title2 } = useConfigContext();
1581
+ const { theme } = useConfigContext();
1569
1582
  react$1.useEffect(() => {
1570
1583
  const title = Array.isArray(props.title) ? props.title : [props.title];
1571
- document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
1584
+ document.title = title.concat(props.suffix || theme.Title.suffix).filter((t) => !!t).join(props.separator || theme.Title.separator);
1572
1585
  }, [props]);
1573
1586
  if (props.h1) {
1574
1587
  if (typeof props.h1 === "boolean")
@@ -1605,7 +1618,7 @@ Object.defineProperty(exports, 'lazy', {
1605
1618
  exports.App = App;
1606
1619
  exports.Blank = Blank;
1607
1620
  exports.ConfigContext = ConfigContext;
1608
- exports.ConfigProvider = ConfigProvider2;
1621
+ exports.ConfigProvider = ConfigProvider;
1609
1622
  exports.Description = Description;
1610
1623
  exports.ErrorBoundary = ErrorBoundary;
1611
1624
  exports.FaasDataWrapper = FaasDataWrapper;