@pisell/materials 6.0.10 → 6.0.12
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/build/lowcode/assets-daily.json +11 -15
- package/build/lowcode/assets-dev.json +2 -6
- package/build/lowcode/assets-prod.json +11 -15
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +7 -7
- package/build/lowcode/preview.js +7 -7
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +22 -22
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +22 -22
- package/dist/umd/materials.min.css +1 -0
- package/dist/umd/materials.min.js +1 -0
- package/dist/umd/static/DotsSix.57d66266.svg +1 -0
- package/dist/umd/static/arrow-left.e542294f.svg +1 -0
- package/dist/umd/static/arrow-right.763f03e0.svg +1 -0
- package/dist/umd/static/filter-lines.04a54ae9.svg +1 -0
- package/dist/umd/static/help-circle.31c9be40.svg +1 -0
- package/dist/umd/static/switch-vertical-01.7ebe3ba8.svg +1 -0
- package/es/components/dataSourceComponents/dataSourceForm/BaseForm.js +94 -3
- package/es/components/dataSourceComponents/dataSourceForm/submitButton/index.js +7 -6
- package/es/components/dataSourceComponents/dataSourceForm/type.d.ts +8 -0
- package/es/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -0
- package/es/components/dataSourceComponents/dataSourceForm/utils.js +120 -38
- package/es/components/dataSourceComponents/dataSourceMenu/index.d.ts +2 -0
- package/es/components/dataSourceComponents/dataSourceMenu/index.js +19 -0
- package/es/components/dataSourceComponents/dataSourceTable/BaseTable.js +46 -8
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
- package/es/components/dataSourceComponents/fields/Input/index.d.ts +4 -0
- package/es/components/dataSourceComponents/fields/Input/index.js +5 -1
- package/es/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.d.ts +5 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.js +28 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.less +11 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.d.ts +10 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +212 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/index.d.ts +3 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/index.js +14 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/serve.d.ts +24 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/serve.js +59 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/type.d.ts +5 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/type.js +1 -0
- package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +2 -3
- package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.js +76 -19
- package/es/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.d.ts +5 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.js +13 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.less +11 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.d.ts +13 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +206 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +12 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.js +4 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/serve.d.ts +11 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/serve.js +63 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/type.d.ts +5 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/type.js +1 -0
- package/es/components/dataSourceComponents/fields/Translation/BaseTranslation.js +15 -4
- package/es/components/dataSourceComponents/fields/Translation/type.d.ts +1 -0
- package/es/components/dataSourceComponents/fields/Upload/BaseUpload.js +17 -13
- package/es/components/dataSourceComponents/fields/Upload/ReadPretty.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Upload/ReadPretty.js +4 -2
- package/es/components/dataSourceComponents/fields/Upload/WithMode.js +5 -4
- package/es/components/dataSourceComponents/fields/Upload/index.less +1 -1
- package/es/components/dataSourceComponents/fields/Upload/serve.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Upload/serve.js +5 -5
- package/es/components/dataSourceComponents/fields/Upload/type.d.ts +8 -0
- package/es/components/dataSourceComponents/fields/index.d.ts +25 -2
- package/es/components/dataSourceComponents/fields/index.js +1 -0
- package/es/components/dataSourceComponents/fields/type.d.ts +1 -0
- package/es/components/dataSourceComponents/fields/utils.js +1 -0
- package/es/components/dataSourceComponents/provider/actions/ActionsContext.d.ts +6 -1
- package/es/components/dataSourceComponents/provider/actions/ActionsProvider.d.ts +4 -1
- package/es/components/dataSourceComponents/provider/actions/ActionsProvider.js +0 -1
- package/es/components/form/index.js +12 -0
- package/es/components/iconfont/index.js +1 -1
- package/es/components/pisellDraggable/components/Action/Action.d.ts +10 -0
- package/es/components/pisellDraggable/components/Action/Action.js +31 -0
- package/es/components/pisellDraggable/components/Action/Action.less +50 -0
- package/es/components/pisellDraggable/components/Action/index.d.ts +2 -0
- package/es/components/pisellDraggable/components/Action/index.js +1 -0
- package/es/components/pisellDraggable/components/Handle/Handle.d.ts +3 -0
- package/es/components/pisellDraggable/components/Handle/Handle.js +15 -0
- package/es/components/pisellDraggable/components/Handle/index.d.ts +1 -0
- package/es/components/pisellDraggable/components/Handle/index.js +1 -0
- package/es/components/pisellDraggable/components/Remove/Remove.d.ts +3 -0
- package/es/components/pisellDraggable/components/Remove/Remove.js +17 -0
- package/es/components/pisellDraggable/components/Remove/index.d.ts +1 -0
- package/es/components/pisellDraggable/components/Remove/index.js +1 -0
- package/es/components/pisellDraggable/components/TreeItem/SortableTreeItem.d.ts +8 -0
- package/es/components/pisellDraggable/components/TreeItem/SortableTreeItem.js +51 -0
- package/es/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +21 -0
- package/es/components/pisellDraggable/components/TreeItem/TreeItem.js +57 -0
- package/es/components/pisellDraggable/components/TreeItem/TreeItem.less +128 -0
- package/es/components/pisellDraggable/components/TreeItem/index.d.ts +2 -0
- package/es/components/pisellDraggable/components/TreeItem/index.js +2 -0
- package/es/components/pisellDraggable/components/index.d.ts +4 -0
- package/es/components/pisellDraggable/components/index.js +4 -0
- package/es/components/pisellDraggable/index.d.ts +27 -0
- package/es/components/pisellDraggable/index.js +380 -0
- package/es/components/pisellDraggable/types.d.ts +17 -0
- package/es/components/pisellDraggable/types.js +1 -0
- package/es/components/pisellDraggable/utilities.d.ts +17 -0
- package/es/components/pisellDraggable/utilities.js +230 -0
- package/es/components/pisellLayout/content.d.ts +8 -0
- package/es/components/pisellLayout/content.js +29 -0
- package/es/components/pisellLayout/footer.d.ts +7 -0
- package/es/components/pisellLayout/footer.js +12 -0
- package/es/components/pisellLayout/header.d.ts +7 -0
- package/es/components/pisellLayout/header.js +12 -0
- package/es/components/pisellLayout/index.d.ts +14 -0
- package/es/components/pisellLayout/index.js +15 -0
- package/es/components/pisellLayout/sider.d.ts +7 -0
- package/es/components/pisellLayout/sider.js +12 -0
- package/es/components/pisellMenu/PisellMenu.d.ts +5 -0
- package/es/components/pisellMenu/PisellMenu.js +55 -0
- package/es/components/pisellMenu/PisellMenu.less +53 -0
- package/es/components/pisellMenu/index.d.ts +3 -0
- package/es/components/pisellMenu/index.js +2 -0
- package/es/components/pisellMenu/types.d.ts +30 -0
- package/es/components/pisellMenu/types.js +1 -0
- package/es/components/pisellModal/components/functions/index.less +3 -0
- package/es/components/table/Table/utils.d.ts +1 -1
- package/es/components/versionModal/index.d.ts +15 -0
- package/es/components/versionModal/index.js +192 -0
- package/es/components/versionModal/index.less +3 -0
- package/es/index.d.ts +92 -120
- package/es/index.js +92 -144
- package/es/locales/en-US.d.ts +22 -0
- package/es/locales/en-US.js +24 -1
- package/es/locales/zh-CN.d.ts +21 -0
- package/es/locales/zh-CN.js +24 -2
- package/es/locales/zh-TW.d.ts +20 -0
- package/es/locales/zh-TW.js +23 -2
- package/lib/components/dataSourceComponents/dataSourceForm/BaseForm.js +77 -4
- package/lib/components/dataSourceComponents/dataSourceForm/submitButton/index.js +1 -0
- package/lib/components/dataSourceComponents/dataSourceForm/type.d.ts +8 -0
- package/lib/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -0
- package/lib/components/dataSourceComponents/dataSourceForm/utils.js +138 -41
- package/lib/components/dataSourceComponents/dataSourceMenu/index.d.ts +2 -0
- package/lib/components/dataSourceComponents/dataSourceMenu/index.js +45 -0
- package/lib/components/dataSourceComponents/dataSourceTable/BaseTable.js +14 -2
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
- package/lib/components/dataSourceComponents/fields/Input/index.d.ts +4 -0
- package/lib/components/dataSourceComponents/fields/Input/index.js +4 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.d.ts +5 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.js +58 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.less +11 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.d.ts +10 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +171 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/index.d.ts +3 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/index.js +48 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/serve.d.ts +24 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/serve.js +55 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/type.d.ts +5 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/type.js +17 -0
- package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +2 -3
- package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +36 -17
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.d.ts +5 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.js +50 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.less +11 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.d.ts +13 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +167 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +12 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.js +38 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/serve.d.ts +11 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/serve.js +65 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/type.d.ts +5 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/type.js +17 -0
- package/lib/components/dataSourceComponents/fields/Translation/BaseTranslation.js +15 -4
- package/lib/components/dataSourceComponents/fields/Translation/type.d.ts +1 -0
- package/lib/components/dataSourceComponents/fields/Upload/BaseUpload.js +5 -3
- package/lib/components/dataSourceComponents/fields/Upload/ReadPretty.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Upload/ReadPretty.js +2 -2
- package/lib/components/dataSourceComponents/fields/Upload/WithMode.js +4 -4
- package/lib/components/dataSourceComponents/fields/Upload/index.less +1 -1
- package/lib/components/dataSourceComponents/fields/Upload/serve.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Upload/serve.js +5 -5
- package/lib/components/dataSourceComponents/fields/Upload/type.d.ts +8 -0
- package/lib/components/dataSourceComponents/fields/index.d.ts +25 -2
- package/lib/components/dataSourceComponents/fields/index.js +1 -0
- package/lib/components/dataSourceComponents/fields/type.d.ts +1 -0
- package/lib/components/dataSourceComponents/fields/utils.js +1 -0
- package/lib/components/dataSourceComponents/provider/actions/ActionsContext.d.ts +6 -1
- package/lib/components/dataSourceComponents/provider/actions/ActionsProvider.d.ts +4 -1
- package/lib/components/form/index.js +10 -1
- package/lib/components/iconfont/index.js +1 -1
- package/lib/components/pisellDraggable/components/Action/Action.d.ts +10 -0
- package/lib/components/pisellDraggable/components/Action/Action.js +60 -0
- package/lib/components/pisellDraggable/components/Action/Action.less +50 -0
- package/lib/components/pisellDraggable/components/Action/index.d.ts +2 -0
- package/lib/components/pisellDraggable/components/Action/index.js +29 -0
- package/lib/components/pisellDraggable/components/Handle/Handle.d.ts +3 -0
- package/lib/components/pisellDraggable/components/Handle/Handle.js +54 -0
- package/lib/components/pisellDraggable/components/Handle/index.d.ts +1 -0
- package/lib/components/pisellDraggable/components/Handle/index.js +29 -0
- package/lib/components/pisellDraggable/components/Remove/Remove.d.ts +3 -0
- package/lib/components/pisellDraggable/components/Remove/Remove.js +53 -0
- package/lib/components/pisellDraggable/components/Remove/index.d.ts +1 -0
- package/lib/components/pisellDraggable/components/Remove/index.js +29 -0
- package/lib/components/pisellDraggable/components/TreeItem/SortableTreeItem.d.ts +8 -0
- package/lib/components/pisellDraggable/components/TreeItem/SortableTreeItem.js +83 -0
- package/lib/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +21 -0
- package/lib/components/pisellDraggable/components/TreeItem/TreeItem.js +93 -0
- package/lib/components/pisellDraggable/components/TreeItem/TreeItem.less +128 -0
- package/lib/components/pisellDraggable/components/TreeItem/index.d.ts +2 -0
- package/lib/components/pisellDraggable/components/TreeItem/index.js +32 -0
- package/lib/components/pisellDraggable/components/index.d.ts +4 -0
- package/lib/components/pisellDraggable/components/index.js +40 -0
- package/lib/components/pisellDraggable/index.d.ts +27 -0
- package/lib/components/pisellDraggable/index.js +271 -0
- package/lib/components/pisellDraggable/types.d.ts +17 -0
- package/lib/components/pisellDraggable/types.js +17 -0
- package/lib/components/pisellDraggable/utilities.d.ts +17 -0
- package/lib/components/pisellDraggable/utilities.js +190 -0
- package/lib/components/pisellLayout/content.d.ts +8 -0
- package/lib/components/pisellLayout/content.js +50 -0
- package/lib/components/pisellLayout/footer.d.ts +7 -0
- package/lib/components/pisellLayout/footer.js +42 -0
- package/lib/components/pisellLayout/header.d.ts +7 -0
- package/lib/components/pisellLayout/header.js +42 -0
- package/lib/components/pisellLayout/index.d.ts +14 -0
- package/lib/components/pisellLayout/index.js +45 -0
- package/lib/components/pisellLayout/sider.d.ts +7 -0
- package/lib/components/pisellLayout/sider.js +42 -0
- package/lib/components/pisellMenu/PisellMenu.d.ts +5 -0
- package/lib/components/pisellMenu/PisellMenu.js +91 -0
- package/lib/components/pisellMenu/PisellMenu.less +53 -0
- package/lib/components/pisellMenu/index.d.ts +3 -0
- package/lib/components/pisellMenu/index.js +36 -0
- package/lib/components/pisellMenu/types.d.ts +30 -0
- package/lib/components/pisellMenu/types.js +17 -0
- package/lib/components/pisellModal/components/functions/index.less +3 -0
- package/lib/components/table/Table/utils.d.ts +1 -1
- package/lib/components/versionModal/index.d.ts +15 -0
- package/lib/components/versionModal/index.js +219 -0
- package/lib/components/versionModal/index.less +3 -0
- package/lib/index.d.ts +92 -120
- package/lib/index.js +146 -157
- package/lib/locales/en-US.d.ts +22 -0
- package/lib/locales/en-US.js +24 -1
- package/lib/locales/zh-CN.d.ts +21 -0
- package/lib/locales/zh-CN.js +24 -2
- package/lib/locales/zh-TW.d.ts +20 -0
- package/lib/locales/zh-TW.js +23 -2
- package/lowcode/_utils/defaultSchema.ts +23 -2
- package/lowcode/button/meta.ts +4 -20
- package/lowcode/data-source-form/constants.ts +4 -0
- package/lowcode/data-source-form/meta.ts +138 -1
- package/lowcode/data-source-form/snippets.ts +54 -0
- package/lowcode/data-source-form/utils.ts +5 -1
- package/lowcode/data-source-menu/meta.ts +122 -0
- package/lowcode/data-source-table/meta.ts +32 -27
- package/lowcode/data-source-table/utils.tsx +33 -1
- package/lowcode/data-source-wrapper/meta.ts +6 -2
- package/lowcode/form-group/meta.ts +5 -1
- package/lowcode/form-item-input.mobile/__screenshots__/mobile.png +0 -0
- package/lowcode/form-item-input.mobile/meta.ts +301 -0
- package/lowcode/form-item-input.mobile/snippets.ts +27 -0
- package/lowcode/form-item-input.phone/meta.ts +9 -43
- package/lowcode/form-item-input.phone/snippets.ts +8 -2
- package/lowcode/form-item-input.subdomain/__screenshots__/subdomain.png +0 -0
- package/lowcode/form-item-input.subdomain/meta.ts +318 -0
- package/lowcode/form-item-input.subdomain/snippets.ts +27 -0
- package/lowcode/form.item/meta.ts +48 -0
- package/lowcode/pisell-content/meta.ts +86 -0
- package/lowcode/pisell-draggable/meta.ts +190 -0
- package/lowcode/pisell-footer/meta.ts +81 -0
- package/lowcode/pisell-header/meta.ts +83 -0
- package/lowcode/pisell-layout/meta.ts +174 -0
- package/lowcode/pisell-menu/meta.ts +112 -0
- package/lowcode/pisell-sider/meta.ts +142 -0
- package/lowcode/pisell-text/meta.ts +9 -8080
- package/package.json +1 -1
|
@@ -36,6 +36,7 @@ __export(utils_exports, {
|
|
|
36
36
|
isValidDomain: () => isValidDomain,
|
|
37
37
|
renderValueWithMap: () => renderValueWithMap,
|
|
38
38
|
toArr: () => toArr,
|
|
39
|
+
transformFormObjToArrayWithUntouched: () => transformFormObjToArrayWithUntouched,
|
|
39
40
|
withDataSource: () => withDataSource,
|
|
40
41
|
withFormItem: () => withFormItem,
|
|
41
42
|
withMode: () => withMode,
|
|
@@ -125,6 +126,7 @@ var withFormItem = (WrappedComponent, overlayProps) => {
|
|
|
125
126
|
const field = fields == null ? void 0 : fields.find((item) => item.name === propsName);
|
|
126
127
|
const label = propsLabel || ((_a = field == null ? void 0 : field.uiSchema) == null ? void 0 : _a.title) || propsName;
|
|
127
128
|
const effectiveMode = propsRenderMode || globalRenderMode;
|
|
129
|
+
const name = (0, import_utils.isString)(propsName) && propsName.includes(".") ? [propsName] : propsName;
|
|
128
130
|
const renderComponent = (0, import_react.useMemo)(() => {
|
|
129
131
|
var _a2;
|
|
130
132
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
@@ -138,6 +140,7 @@ var withFormItem = (WrappedComponent, overlayProps) => {
|
|
|
138
140
|
...innerStyle || {},
|
|
139
141
|
...((_a2 = overlayProps == null ? void 0 : overlayProps.innerProps) == null ? void 0 : _a2.style) || {}
|
|
140
142
|
},
|
|
143
|
+
fieldKey: name,
|
|
141
144
|
isVerification: typeobj == null ? void 0 : typeobj.enabled,
|
|
142
145
|
size
|
|
143
146
|
}
|
|
@@ -149,11 +152,11 @@ var withFormItem = (WrappedComponent, overlayProps) => {
|
|
|
149
152
|
overlayProps == null ? void 0 : overlayProps.innerProps,
|
|
150
153
|
typeobj == null ? void 0 : typeobj.enabled,
|
|
151
154
|
size,
|
|
152
|
-
innerStyle
|
|
155
|
+
innerStyle,
|
|
156
|
+
name
|
|
153
157
|
]);
|
|
154
158
|
const isDesignMode = __designMode === "design";
|
|
155
159
|
const isHidden = effectiveMode === "hidden";
|
|
156
|
-
const name = (0, import_utils.isString)(propsName) && propsName.includes(".") ? [propsName] : propsName;
|
|
157
160
|
const concatName = name !== void 0 ? [...prefixPath, ...toArr(name)] : void 0;
|
|
158
161
|
const rules = [];
|
|
159
162
|
if (requiredobj && requiredobj.required) {
|
|
@@ -163,44 +166,131 @@ var withFormItem = (WrappedComponent, overlayProps) => {
|
|
|
163
166
|
});
|
|
164
167
|
}
|
|
165
168
|
if (typeobj && typeobj.enabled) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
)
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
169
|
+
switch (typeobj.type) {
|
|
170
|
+
case "email":
|
|
171
|
+
rules.push({
|
|
172
|
+
...typeobj,
|
|
173
|
+
message: typeobj.message || (0, import_locales.getText)("pisell-data-source-form-email-message")
|
|
174
|
+
});
|
|
175
|
+
break;
|
|
176
|
+
case "pattern":
|
|
177
|
+
rules.push({
|
|
178
|
+
...typeobj,
|
|
179
|
+
pattern: new RegExp(typeobj.pattern),
|
|
180
|
+
message: typeobj.message || (0, import_locales.getText)("pisell-data-source-form-pattern-message")
|
|
181
|
+
});
|
|
182
|
+
break;
|
|
183
|
+
case "phone":
|
|
184
|
+
rules.push({
|
|
185
|
+
...typeobj,
|
|
186
|
+
validator: (_, value) => {
|
|
187
|
+
if (!(value == null ? void 0 : value.trim())) {
|
|
188
|
+
return Promise.resolve();
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
const cleanedNumber2 = value.replace(/\s|\(|\)/g, "");
|
|
192
|
+
const parsedNumber = (0, import_libphonenumber_js.parsePhoneNumberFromString)(cleanedNumber2);
|
|
193
|
+
if (!(parsedNumber == null ? void 0 : parsedNumber.isValid())) {
|
|
194
|
+
return Promise.reject(
|
|
195
|
+
new Error(
|
|
196
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-phone-message")
|
|
197
|
+
)
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
return Promise.resolve();
|
|
201
|
+
} catch (error) {
|
|
202
|
+
return Promise.reject(
|
|
203
|
+
new Error(
|
|
204
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-phone-message")
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
break;
|
|
211
|
+
case "mobile":
|
|
212
|
+
rules.push({
|
|
213
|
+
...typeobj,
|
|
214
|
+
validator: (_, value) => {
|
|
215
|
+
if (!(value == null ? void 0 : value.trim())) {
|
|
216
|
+
return Promise.resolve();
|
|
217
|
+
}
|
|
218
|
+
try {
|
|
219
|
+
const cleanedNumber2 = value.replace(/\s|\(|\)/g, "");
|
|
220
|
+
if (cleanedNumber2.length > 15) {
|
|
221
|
+
return Promise.reject(
|
|
222
|
+
new Error(
|
|
223
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-mobile-message")
|
|
224
|
+
)
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
if (cleanedNumber2.startsWith("+61")) {
|
|
228
|
+
const numberWithoutPrefix = cleanedNumber2.slice(3);
|
|
229
|
+
if (!/^(?:04\d{8}|4\d{8})$/.test(numberWithoutPrefix)) {
|
|
230
|
+
return Promise.reject(
|
|
231
|
+
new Error(
|
|
232
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-mobile-message")
|
|
233
|
+
)
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
} else if (cleanedNumber2.startsWith("+86")) {
|
|
237
|
+
const numberWithoutPrefix = cleanedNumber2.slice(3);
|
|
238
|
+
if (!/^1[3-9]\d{9}$/.test(numberWithoutPrefix)) {
|
|
239
|
+
return Promise.reject(
|
|
240
|
+
new Error(
|
|
241
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-mobile-message")
|
|
242
|
+
)
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return Promise.resolve();
|
|
247
|
+
} catch (error) {
|
|
248
|
+
if (cleanedNumber.length > 15) {
|
|
249
|
+
return Promise.reject(
|
|
250
|
+
new Error(
|
|
251
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-mobile-message")
|
|
252
|
+
)
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
return Promise.resolve();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
break;
|
|
260
|
+
case "subdomain":
|
|
261
|
+
rules.push({
|
|
262
|
+
...typeobj,
|
|
263
|
+
validator: (_, value) => {
|
|
264
|
+
if (!value)
|
|
265
|
+
return Promise.resolve();
|
|
266
|
+
const subdomain = value.split(".")[0];
|
|
267
|
+
if (!subdomain) {
|
|
268
|
+
return Promise.resolve();
|
|
269
|
+
}
|
|
270
|
+
if (!/^[a-z0-9-]+$/.test(subdomain)) {
|
|
271
|
+
return Promise.reject(
|
|
272
|
+
new Error((0, import_locales.getText)("subdomain-error-pattern"))
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
if (/^\d+$/.test(subdomain)) {
|
|
276
|
+
return Promise.reject(
|
|
277
|
+
new Error((0, import_locales.getText)("subdomain-error-numbers-only"))
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
if (subdomain.startsWith("-") || subdomain.endsWith("-")) {
|
|
281
|
+
return Promise.reject(
|
|
282
|
+
new Error((0, import_locales.getText)("subdomain-error-hyphen-ends"))
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
if (subdomain.includes("--")) {
|
|
286
|
+
return Promise.reject(
|
|
287
|
+
new Error((0, import_locales.getText)("subdomain-error-consecutive-hyphens"))
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
return Promise.resolve();
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
break;
|
|
204
294
|
}
|
|
205
295
|
}
|
|
206
296
|
if (maxLengthobj && maxLengthobj.enabled) {
|
|
@@ -298,7 +388,7 @@ var withFormItem = (WrappedComponent, overlayProps) => {
|
|
|
298
388
|
rules,
|
|
299
389
|
normalize,
|
|
300
390
|
getValueProps,
|
|
301
|
-
validateTrigger,
|
|
391
|
+
validateTrigger: validateTrigger || ["onChange", "onBlur"],
|
|
302
392
|
labelCol,
|
|
303
393
|
initialValue: otherProps == null ? void 0 : otherProps.defaultValue,
|
|
304
394
|
className: (0, import_classnames.default)("pisell-data-source-form-item", {
|
|
@@ -394,6 +484,12 @@ var filterSystemFields = (params) => {
|
|
|
394
484
|
return acc;
|
|
395
485
|
}, {});
|
|
396
486
|
};
|
|
487
|
+
var transformFormObjToArrayWithUntouched = (obj) => {
|
|
488
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
489
|
+
acc.push({ name: key, value: obj[key], touched: false });
|
|
490
|
+
return acc;
|
|
491
|
+
}, []);
|
|
492
|
+
};
|
|
397
493
|
// Annotate the CommonJS export names for ESM import in node:
|
|
398
494
|
0 && (module.exports = {
|
|
399
495
|
filterSystemFields,
|
|
@@ -403,6 +499,7 @@ var filterSystemFields = (params) => {
|
|
|
403
499
|
isValidDomain,
|
|
404
500
|
renderValueWithMap,
|
|
405
501
|
toArr,
|
|
502
|
+
transformFormObjToArrayWithUntouched,
|
|
406
503
|
withDataSource,
|
|
407
504
|
withFormItem,
|
|
408
505
|
withMode,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/dataSourceComponents/dataSourceMenu/index.tsx
|
|
30
|
+
var dataSourceMenu_exports = {};
|
|
31
|
+
__export(dataSourceMenu_exports, {
|
|
32
|
+
default: () => dataSourceMenu_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(dataSourceMenu_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_pisellMenu = __toESM(require("../../pisellMenu"));
|
|
37
|
+
var import_useVariables = __toESM(require("../hooks/useVariables"));
|
|
38
|
+
var DataSourceMenu = (0, import_react.forwardRef)(
|
|
39
|
+
(props, ref) => {
|
|
40
|
+
const { dataSource } = props;
|
|
41
|
+
const { parseVariable } = (0, import_useVariables.default)();
|
|
42
|
+
return /* @__PURE__ */ import_react.default.createElement(import_pisellMenu.default, { ...props, dataSource: parseVariable == null ? void 0 : parseVariable(dataSource), ref });
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
var dataSourceMenu_default = DataSourceMenu;
|
|
@@ -58,6 +58,10 @@ var BaseTable = (props) => {
|
|
|
58
58
|
const { list } = (0, import_useDataSource.default)();
|
|
59
59
|
const { data } = list;
|
|
60
60
|
const { dataSourceKey, dataSourceKeyRef } = (0, import_useDataSourceKey.default)();
|
|
61
|
+
const beforeClose = (0, import_react.useRef)();
|
|
62
|
+
const setBeforeClose = (0, import_react.useCallback)((fn) => {
|
|
63
|
+
beforeClose.current = fn;
|
|
64
|
+
}, []);
|
|
61
65
|
const {
|
|
62
66
|
drawerVisible,
|
|
63
67
|
setDrawerVisible,
|
|
@@ -94,7 +98,13 @@ var BaseTable = (props) => {
|
|
|
94
98
|
currentDataSource: dataSource
|
|
95
99
|
});
|
|
96
100
|
}, [dataSource]);
|
|
97
|
-
const handleCloseDrawer = () => {
|
|
101
|
+
const handleCloseDrawer = async () => {
|
|
102
|
+
if (beforeClose.current) {
|
|
103
|
+
const canClose = await beforeClose.current();
|
|
104
|
+
if (!canClose) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
98
108
|
closeDrawer();
|
|
99
109
|
registerValueVariable == null ? void 0 : registerValueVariable(componentId, {
|
|
100
110
|
currentRecord: null
|
|
@@ -124,7 +134,9 @@ var BaseTable = (props) => {
|
|
|
124
134
|
{
|
|
125
135
|
visible: drawerVisible,
|
|
126
136
|
setVisible: setDrawerVisible,
|
|
127
|
-
refreshTableData: refreshData
|
|
137
|
+
refreshTableData: refreshData,
|
|
138
|
+
setBeforeClose,
|
|
139
|
+
beforeClose: beforeClose.current
|
|
128
140
|
},
|
|
129
141
|
/* @__PURE__ */ import_react.default.createElement(
|
|
130
142
|
Container,
|
|
@@ -17,7 +17,7 @@ interface UseTablePropsProps {
|
|
|
17
17
|
* @returns
|
|
18
18
|
*/
|
|
19
19
|
declare const useTableProps: (props: UseTablePropsProps) => {
|
|
20
|
-
title: number | boolean |
|
|
20
|
+
title: number | boolean | React.JSX.Element | Iterable<React.ReactNode> | (() => React.ReactNode) | null | undefined;
|
|
21
21
|
pagination: {
|
|
22
22
|
total: number;
|
|
23
23
|
current: number;
|
|
@@ -26,7 +26,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
|
|
|
26
26
|
showSizeChanger: boolean;
|
|
27
27
|
};
|
|
28
28
|
columns: import("./useColumns").Column[];
|
|
29
|
-
subTitle: number | boolean |
|
|
29
|
+
subTitle: number | boolean | React.JSX.Element | Iterable<React.ReactNode> | (() => React.ReactNode) | null | undefined;
|
|
30
30
|
buttons: any[] | null;
|
|
31
31
|
filter: React.JSX.Element | null;
|
|
32
32
|
onRow: (record: any) => any;
|
|
@@ -65,7 +65,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
|
|
|
65
65
|
useCustomAction: boolean;
|
|
66
66
|
actionType: string;
|
|
67
67
|
openMode: "modal" | "drawer";
|
|
68
|
-
openContentSize: "small" | "
|
|
68
|
+
openContentSize: "small" | "middle" | "large";
|
|
69
69
|
openTitle: string;
|
|
70
70
|
key: string;
|
|
71
71
|
} | undefined;
|
|
@@ -5,6 +5,8 @@ import TextArea from '../Input.TextArea';
|
|
|
5
5
|
import Url from '../Input.Url';
|
|
6
6
|
import Email from '../Input.Email';
|
|
7
7
|
import Phone from '../Input.Phone';
|
|
8
|
+
import Mobile from '../Input.Mobile';
|
|
9
|
+
import Subdomain from '../Input.Subdomain';
|
|
8
10
|
import { InputProps } from './type';
|
|
9
11
|
declare type InputComponent = React.FC<InputProps> & {
|
|
10
12
|
JSON: typeof JSON;
|
|
@@ -13,6 +15,8 @@ declare type InputComponent = React.FC<InputProps> & {
|
|
|
13
15
|
URL: typeof Url;
|
|
14
16
|
Email: typeof Email;
|
|
15
17
|
Phone: typeof Phone;
|
|
18
|
+
Mobile: typeof Mobile;
|
|
19
|
+
Subdomain: typeof Subdomain;
|
|
16
20
|
};
|
|
17
21
|
declare const Input: InputComponent;
|
|
18
22
|
export default Input;
|
|
@@ -38,6 +38,8 @@ var import_Input3 = __toESM(require("../Input.TextArea"));
|
|
|
38
38
|
var import_Input4 = __toESM(require("../Input.Url"));
|
|
39
39
|
var import_Input5 = __toESM(require("../Input.Email"));
|
|
40
40
|
var import_Input6 = __toESM(require("../Input.Phone"));
|
|
41
|
+
var import_Input7 = __toESM(require("../Input.Mobile"));
|
|
42
|
+
var import_Input8 = __toESM(require("../Input.Subdomain"));
|
|
41
43
|
var import_WithMode = __toESM(require("./WithMode"));
|
|
42
44
|
var import_utils = require("../../dataSourceForm/utils");
|
|
43
45
|
var Input = (0, import_utils.withFormItem)(import_WithMode.default);
|
|
@@ -47,4 +49,6 @@ Input.TextArea = import_Input3.default;
|
|
|
47
49
|
Input.URL = import_Input4.default;
|
|
48
50
|
Input.Email = import_Input5.default;
|
|
49
51
|
Input.Phone = import_Input6.default;
|
|
52
|
+
Input.Mobile = import_Input7.default;
|
|
53
|
+
Input.Subdomain = import_Input8.default;
|
|
50
54
|
var Input_default = Input;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.tsx
|
|
30
|
+
var ReadPretty_exports = {};
|
|
31
|
+
__export(ReadPretty_exports, {
|
|
32
|
+
default: () => ReadPretty_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(ReadPretty_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_libphonenumber_js = require("libphonenumber-js");
|
|
37
|
+
var import_classnames = __toESM(require("classnames"));
|
|
38
|
+
var import_ReadPretty = require("./ReadPretty.less");
|
|
39
|
+
var ReadPretty = ({
|
|
40
|
+
value,
|
|
41
|
+
renderMode
|
|
42
|
+
}) => {
|
|
43
|
+
if (!value)
|
|
44
|
+
return null;
|
|
45
|
+
const className = (0, import_classnames.default)("pisell-phone-read-pretty", {
|
|
46
|
+
"pisell-phone-read-pretty-table-view": renderMode === "tableView"
|
|
47
|
+
});
|
|
48
|
+
try {
|
|
49
|
+
const phoneNumber = (0, import_libphonenumber_js.parsePhoneNumberFromString)(value);
|
|
50
|
+
if (!phoneNumber)
|
|
51
|
+
return /* @__PURE__ */ import_react.default.createElement("span", { className }, value);
|
|
52
|
+
const formattedValue = `(${phoneNumber.formatInternational().split(" ")[0]}) ${phoneNumber.formatNational()}`;
|
|
53
|
+
return /* @__PURE__ */ import_react.default.createElement("span", { className }, formattedValue);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return /* @__PURE__ */ import_react.default.createElement("span", { className }, value);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var ReadPretty_default = ReadPretty;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputProps } from 'antd';
|
|
3
|
+
import { ModeType } from "../../dataSourceForm/type";
|
|
4
|
+
export interface PhoneInputProps extends Omit<InputProps, 'value' | 'onChange'> {
|
|
5
|
+
renderMode: ModeType;
|
|
6
|
+
value?: string;
|
|
7
|
+
onChange?: (value: string) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const MobileNumberInputWithMode: React.FC<PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps>;
|
|
10
|
+
export default MobileNumberInputWithMode;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/dataSourceComponents/fields/Input.Mobile/WithMode.tsx
|
|
30
|
+
var WithMode_exports = {};
|
|
31
|
+
__export(WithMode_exports, {
|
|
32
|
+
default: () => WithMode_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(WithMode_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_antd = require("antd");
|
|
37
|
+
var import_utils = require("@pisell/utils");
|
|
38
|
+
var import_select = __toESM(require("../../../select"));
|
|
39
|
+
var import_serve = require("./serve");
|
|
40
|
+
var import_ReadPretty = __toESM(require("./ReadPretty"));
|
|
41
|
+
var import_utils2 = require("../../dataSourceForm/utils");
|
|
42
|
+
var import_useTranslationOriginal = __toESM(require("../../../../hooks/useTranslationOriginal"));
|
|
43
|
+
var { Option } = import_select.default;
|
|
44
|
+
var MobileNumberInput = ({ value: propsValue, onChange, disabled, ...props }) => {
|
|
45
|
+
const { data: countries = [] } = (0, import_serve.useCountries)();
|
|
46
|
+
const translationOriginal = (0, import_useTranslationOriginal.default)();
|
|
47
|
+
const value = (0, import_react.useMemo)(() => {
|
|
48
|
+
if ((0, import_utils.isNumber)(propsValue)) {
|
|
49
|
+
return `${propsValue}`;
|
|
50
|
+
}
|
|
51
|
+
return propsValue;
|
|
52
|
+
}, [propsValue]);
|
|
53
|
+
const parseExternalValue = (val) => {
|
|
54
|
+
if (!val)
|
|
55
|
+
return { countryCode: "AU", phoneNumber: "" };
|
|
56
|
+
const matchedPrefix = countries.find(
|
|
57
|
+
(country) => val.startsWith(country.prefix)
|
|
58
|
+
);
|
|
59
|
+
if (matchedPrefix) {
|
|
60
|
+
return {
|
|
61
|
+
countryCode: matchedPrefix.code,
|
|
62
|
+
phoneNumber: val.slice(matchedPrefix.prefix.length)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
countryCode: "AU",
|
|
67
|
+
phoneNumber: val.replace(/\D/g, "")
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
const [countryCode, setCountryCode] = (0, import_react.useState)(
|
|
71
|
+
() => parseExternalValue(value).countryCode
|
|
72
|
+
);
|
|
73
|
+
const [phoneNumber, setPhoneNumber] = (0, import_react.useState)(
|
|
74
|
+
() => parseExternalValue(value).phoneNumber
|
|
75
|
+
);
|
|
76
|
+
(0, import_react.useEffect)(() => {
|
|
77
|
+
if (value) {
|
|
78
|
+
const { countryCode: newCountryCode, phoneNumber: newPhoneNumber } = parseExternalValue(value);
|
|
79
|
+
setCountryCode(newCountryCode);
|
|
80
|
+
setPhoneNumber(newPhoneNumber);
|
|
81
|
+
} else {
|
|
82
|
+
setPhoneNumber("");
|
|
83
|
+
}
|
|
84
|
+
}, [value, countries]);
|
|
85
|
+
const handleCountryChange = (value2) => {
|
|
86
|
+
setCountryCode(value2);
|
|
87
|
+
const selectedCountry = countries.find(
|
|
88
|
+
(c) => c.code === value2
|
|
89
|
+
);
|
|
90
|
+
const prefix = (selectedCountry == null ? void 0 : selectedCountry.prefix) || "";
|
|
91
|
+
const newValue = `${prefix}${phoneNumber}`;
|
|
92
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
93
|
+
setTimeout(() => {
|
|
94
|
+
const formInstance = props.form;
|
|
95
|
+
const fieldName = props.fieldKey;
|
|
96
|
+
if (formInstance && fieldName) {
|
|
97
|
+
formInstance.validateFields([fieldName]);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
const handlePhoneNumberChange = (e) => {
|
|
102
|
+
const cleanNumber = e.target.value.replace(/\D/g, "");
|
|
103
|
+
setPhoneNumber(cleanNumber);
|
|
104
|
+
const selectedCountry = countries.find(
|
|
105
|
+
(c) => c.code === countryCode
|
|
106
|
+
);
|
|
107
|
+
const prefix = (selectedCountry == null ? void 0 : selectedCountry.prefix) || "";
|
|
108
|
+
const newValue = cleanNumber ? `${prefix}${cleanNumber}` : "";
|
|
109
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
110
|
+
if (!cleanNumber) {
|
|
111
|
+
const formInstance = props.form;
|
|
112
|
+
const fieldName = props.fieldKey;
|
|
113
|
+
if (formInstance && fieldName) {
|
|
114
|
+
formInstance.setFields([
|
|
115
|
+
{
|
|
116
|
+
name: fieldName,
|
|
117
|
+
errors: [],
|
|
118
|
+
// 清除错误信息
|
|
119
|
+
validating: false
|
|
120
|
+
// 停止验证状态
|
|
121
|
+
}
|
|
122
|
+
]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const concatenatedNumber = (0, import_react.useMemo)(() => {
|
|
127
|
+
const selectedCountry = countries.find(
|
|
128
|
+
(c) => c.code === countryCode
|
|
129
|
+
);
|
|
130
|
+
if (phoneNumber.length === 0) {
|
|
131
|
+
return "";
|
|
132
|
+
}
|
|
133
|
+
const prefix = (selectedCountry == null ? void 0 : selectedCountry.prefix) || "";
|
|
134
|
+
return `${prefix}${phoneNumber}`;
|
|
135
|
+
}, [countryCode, phoneNumber, countries]);
|
|
136
|
+
const handleBlur = () => {
|
|
137
|
+
const finalValue = concatenatedNumber;
|
|
138
|
+
onChange == null ? void 0 : onChange(finalValue);
|
|
139
|
+
};
|
|
140
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd.Space.Compact, { block: true }, /* @__PURE__ */ import_react.default.createElement(
|
|
141
|
+
import_select.default,
|
|
142
|
+
{
|
|
143
|
+
disabled,
|
|
144
|
+
value: countryCode,
|
|
145
|
+
onChange: handleCountryChange,
|
|
146
|
+
style: { width: "90px" },
|
|
147
|
+
popupMatchSelectWidth: false,
|
|
148
|
+
optionLabelProp: "inputValue",
|
|
149
|
+
optionFilterProp: "label",
|
|
150
|
+
showSearch: true,
|
|
151
|
+
options: countries.map((country) => ({
|
|
152
|
+
value: country.code,
|
|
153
|
+
label: `${translationOriginal(country.name)} (${country.prefix})`,
|
|
154
|
+
inputValue: country.prefix
|
|
155
|
+
}))
|
|
156
|
+
}
|
|
157
|
+
), /* @__PURE__ */ import_react.default.createElement(
|
|
158
|
+
import_antd.Input,
|
|
159
|
+
{
|
|
160
|
+
...props,
|
|
161
|
+
disabled,
|
|
162
|
+
type: "tel",
|
|
163
|
+
value: phoneNumber,
|
|
164
|
+
onChange: handlePhoneNumberChange,
|
|
165
|
+
onBlur: handleBlur,
|
|
166
|
+
style: { flex: 1 }
|
|
167
|
+
}
|
|
168
|
+
));
|
|
169
|
+
};
|
|
170
|
+
var MobileNumberInputWithMode = (0, import_utils2.withMode)(MobileNumberInput, import_ReadPretty.default);
|
|
171
|
+
var WithMode_default = MobileNumberInputWithMode;
|