x-ui-design 0.3.66 → 0.3.68
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.esm.js +15 -51
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -50
- package/dist/index.js.map +1 -1
- package/lib/components/Form/Form.tsx +2 -1
- package/lib/components/Form/Item/Item.tsx +7 -4
- package/lib/helpers/flatten.ts +3 -71
- package/package.json +1 -1
- package/src/app/page.tsx +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import require$$1 from 'react/jsx-runtime';
|
|
2
|
-
import React$1, { useRef, useState, Children, isValidElement, Fragment, Suspense,
|
|
2
|
+
import React$1, { useRef, useState, Children, isValidElement, Fragment, Suspense, useContext, useMemo, useEffect, cloneElement, createContext, forwardRef, useImperativeHandle, useCallback } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import ReactDOMServer from 'react-dom/server';
|
|
5
5
|
|
|
@@ -887,54 +887,16 @@ function flattenChildren(children) {
|
|
|
887
887
|
const result = [];
|
|
888
888
|
Children.forEach(children, child => {
|
|
889
889
|
if (! /*#__PURE__*/isValidElement(child)) return;
|
|
890
|
-
const childProps = child.props;
|
|
891
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
892
|
-
// @ts-expect-error
|
|
893
|
-
const childType = child.type;
|
|
894
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
895
|
-
// @ts-expect-error
|
|
896
|
-
const childKey = child.key;
|
|
897
890
|
if (child.type === Fragment || child.type === Suspense) {
|
|
898
|
-
|
|
891
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
892
|
+
// @ts-expect-error
|
|
893
|
+
result.push(...flattenChildren(child.props.children));
|
|
899
894
|
} else {
|
|
900
|
-
if ('dangerouslySetInnerHTML' in childProps) {
|
|
901
|
-
const isWrapper = typeof child.type === 'string' && ['div', 'span', 'label'].includes(childType);
|
|
902
|
-
if (isWrapper) {
|
|
903
|
-
const divElement = document.createElement(childType);
|
|
904
|
-
if (childProps?.dangerouslySetInnerHTML?.__html) {
|
|
905
|
-
divElement.insertAdjacentHTML("beforeend", childProps?.dangerouslySetInnerHTML?.__html);
|
|
906
|
-
}
|
|
907
|
-
const node = convertDomNodeToReact(divElement, childKey);
|
|
908
|
-
if (node) {
|
|
909
|
-
result.push(node);
|
|
910
|
-
}
|
|
911
|
-
return;
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
895
|
result.push(child);
|
|
915
896
|
}
|
|
916
897
|
});
|
|
917
898
|
return result;
|
|
918
899
|
}
|
|
919
|
-
function convertDomNodeToReact(node, key) {
|
|
920
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
921
|
-
return node.textContent;
|
|
922
|
-
}
|
|
923
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
924
|
-
const el = node;
|
|
925
|
-
const tag = el.tagName.toLowerCase();
|
|
926
|
-
const props = {};
|
|
927
|
-
for (const attr of el.attributes) {
|
|
928
|
-
props[attr.name === 'class' ? 'className' : attr.name] = attr.value;
|
|
929
|
-
}
|
|
930
|
-
if (key !== undefined) {
|
|
931
|
-
props.key = key;
|
|
932
|
-
}
|
|
933
|
-
const children = Array.from(el.childNodes).map((childNode, index) => convertDomNodeToReact(childNode, `${key ?? 'node'}-${index}`));
|
|
934
|
-
return /*#__PURE__*/createElement(tag, props, ...children);
|
|
935
|
-
}
|
|
936
|
-
return null;
|
|
937
|
-
}
|
|
938
900
|
|
|
939
901
|
var css_248z$k = ".xUi-form-item{display:flex;margin-bottom:10px;position:relative}.xUi-form-item.noStyle{display:inline-flex;margin-bottom:0}.xUi-form-item-label{align-items:center;color:var(--xui-text-color);display:flex;font-size:var(--xui-font-size-md);font-weight:500;line-height:20px;margin-bottom:4px}.xUi-form-item-error{bottom:-6px;color:var(--xui-error-color);font-size:var(--xui-font-size-xs);line-height:16px;position:absolute;right:0;user-select:none}.xUi-form-item-required{color:var(--xui-error-color);display:inline-block;font-size:var(--xui-font-size-md);line-height:1;margin-left:4px;margin-right:4px}.xUi-form-item.horizontal{align-items:center;flex-direction:row;gap:4px}.xUi-form-item.vertical{align-self:flex-start;flex-direction:column}.xUi-form-item .xUi-input-container{margin-bottom:12px!important;width:-webkit-fill-available}.xUi-form-item .xUi-datepicker-container{margin-bottom:10px}.xUi-form-item .xUi-select{margin-bottom:15px}";
|
|
940
902
|
styleInject(css_248z$k);
|
|
@@ -1087,7 +1049,7 @@ const FormItemChildComponent = ({
|
|
|
1087
1049
|
return child;
|
|
1088
1050
|
}
|
|
1089
1051
|
const childProps = child.props;
|
|
1090
|
-
const isWrapper = typeof child.type === 'string' && ['div', 'span', 'label'].includes(child.type);
|
|
1052
|
+
const isWrapper = typeof child.type === 'string' && !('dangerouslySetInnerHTML' in childProps) && ['div', 'span', 'label'].includes(child.type);
|
|
1091
1053
|
if (isWrapper) {
|
|
1092
1054
|
return /*#__PURE__*/cloneElement(child, {
|
|
1093
1055
|
...childProps,
|
|
@@ -1101,16 +1063,18 @@ const FormItemChildComponent = ({
|
|
|
1101
1063
|
}
|
|
1102
1064
|
return /*#__PURE__*/cloneElement(child, {
|
|
1103
1065
|
...props,
|
|
1066
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1067
|
+
// @ts-expect-error
|
|
1104
1068
|
name,
|
|
1105
1069
|
onChange: handleChange,
|
|
1106
1070
|
key: `${name}_${wasNormalize}`,
|
|
1107
1071
|
value: fieldValue ?? props.value,
|
|
1108
|
-
...(
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1072
|
+
...('dangerouslySetInnerHTML' in childProps ? {} : {
|
|
1073
|
+
__injected: true,
|
|
1074
|
+
...(error ? {
|
|
1075
|
+
error
|
|
1076
|
+
} : {})
|
|
1077
|
+
})
|
|
1114
1078
|
});
|
|
1115
1079
|
};
|
|
1116
1080
|
return injectPropsIntoFinalLeaf(child);
|
|
@@ -1166,7 +1130,7 @@ const Form$1 = ({
|
|
|
1166
1130
|
return child;
|
|
1167
1131
|
}
|
|
1168
1132
|
const childProps = child.props;
|
|
1169
|
-
const isWrapper = typeof child.type === 'string' && ['div', 'span', 'label'].includes(child.type);
|
|
1133
|
+
const isWrapper = typeof child.type === 'string' && !('dangerouslySetInnerHTML' in childProps) && ['div', 'span', 'label'].includes(child.type);
|
|
1170
1134
|
if (isWrapper) {
|
|
1171
1135
|
return /*#__PURE__*/cloneElement(child, {
|
|
1172
1136
|
...childProps,
|
|
@@ -1193,7 +1157,7 @@ const Form$1 = ({
|
|
|
1193
1157
|
ref: formRef,
|
|
1194
1158
|
onSubmit: handleSubmit,
|
|
1195
1159
|
className: `${prefixCls} ${className}`
|
|
1196
|
-
}, Children.map(
|
|
1160
|
+
}, Children.map(childrenList, child => injectPropsIntoFinalLeaf(child))));
|
|
1197
1161
|
};
|
|
1198
1162
|
Form$1.Item = FormItem$1;
|
|
1199
1163
|
|