@akanjs/ui 0.9.5 → 0.9.7
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/DraggableList.d.ts +3 -2
- package/Input.d.ts +1 -1
- package/Select.d.ts +7 -4
- package/cjs/DraggableList.js +30 -3
- package/cjs/Field.js +71 -65
- package/cjs/Input.js +2 -2
- package/cjs/Layout/Template.js +1 -1
- package/cjs/Link/CsrLink.js +6 -4
- package/cjs/Link/NextLink.js +8 -5
- package/cjs/Model/SureToRemove.js +73 -67
- package/cjs/Select.js +6 -4
- package/cjs/System/CSR.js +4 -6
- package/cjs/System/Client.js +3 -1
- package/esm/DraggableList.js +31 -4
- package/esm/Field.js +71 -65
- package/esm/Input.js +2 -2
- package/esm/Layout/Template.js +1 -1
- package/esm/Link/CsrLink.js +6 -4
- package/esm/Link/NextLink.js +8 -5
- package/esm/Model/SureToRemove.js +73 -67
- package/esm/Select.js +6 -4
- package/esm/System/CSR.js +4 -6
- package/esm/System/Client.js +3 -1
- package/package.json +1 -1
package/DraggableList.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface DragListProps<V> {
|
|
|
8
8
|
newIdx: number;
|
|
9
9
|
idxChanged: boolean;
|
|
10
10
|
}) => void;
|
|
11
|
+
onRemove: (value: V, idx: number) => void;
|
|
11
12
|
}
|
|
12
13
|
interface Cursor {
|
|
13
14
|
className?: string;
|
|
@@ -18,8 +19,8 @@ interface ItemProps {
|
|
|
18
19
|
children: ReactNode;
|
|
19
20
|
}
|
|
20
21
|
export declare const DraggableList: {
|
|
21
|
-
<V>({ className, mode, children, onChange }: DragListProps<V>): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
<V>({ className, mode, children, onChange, onRemove }: DragListProps<V>): import("react/jsx-runtime").JSX.Element;
|
|
22
23
|
Cursor({ className, children }: Cursor): import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
Item: ({ value, children }: ItemProps) =>
|
|
24
|
+
Item: ({ value, children }: ItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
25
|
};
|
|
25
26
|
export {};
|
package/Input.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "
|
|
|
10
10
|
inputClassName?: string;
|
|
11
11
|
inputWrapperClassName?: string;
|
|
12
12
|
onPressEnter?: (value: any, event: KeyboardEvent<HTMLInputElement>) => void;
|
|
13
|
-
validate
|
|
13
|
+
validate?: (value: string) => boolean | string;
|
|
14
14
|
onChange?: (value: string, e?: ChangeEvent<HTMLInputElement>) => void;
|
|
15
15
|
onPressEscape?: (e: KeyboardEvent<HTMLInputElement>) => void;
|
|
16
16
|
};
|
package/Select.d.ts
CHANGED
|
@@ -4,15 +4,18 @@ type Options<T> = T[] | {
|
|
|
4
4
|
label: string | boolean | number;
|
|
5
5
|
value: T;
|
|
6
6
|
}[] | Enum<T>;
|
|
7
|
-
interface SelectProps<T, Multiple extends boolean = false> {
|
|
7
|
+
interface SelectProps<T, Multiple extends boolean = false, Searchable extends boolean = false> {
|
|
8
8
|
label?: string;
|
|
9
9
|
desc?: string;
|
|
10
10
|
labelClassName?: string;
|
|
11
11
|
className?: string;
|
|
12
12
|
value: Multiple extends true ? T[] : T | null;
|
|
13
|
-
options: Options<T
|
|
13
|
+
options: Searchable extends true ? T extends string ? Options<T> : {
|
|
14
|
+
label: string | boolean | number;
|
|
15
|
+
value: T;
|
|
16
|
+
}[] : Options<T>;
|
|
14
17
|
multiple?: Multiple;
|
|
15
|
-
searchable?:
|
|
18
|
+
searchable?: Searchable;
|
|
16
19
|
placeholder?: string;
|
|
17
20
|
selectClassName?: string;
|
|
18
21
|
selectorClassName?: string;
|
|
@@ -25,5 +28,5 @@ interface SelectProps<T, Multiple extends boolean = false> {
|
|
|
25
28
|
renderOption?: (value: T) => ReactNode;
|
|
26
29
|
renderSelected?: (value: T) => ReactNode;
|
|
27
30
|
}
|
|
28
|
-
export declare const Select: <T, Multiple extends boolean = false>({ label, desc, labelClassName, className, value, options, nullable, disabled, multiple, searchable, placeholder, selectClassName, selectorClassName, selectedClassName, onOpen, onChange, onSearch, renderOption, renderSelected, }: SelectProps<T, Multiple>) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare const Select: <T, Multiple extends boolean = false, Searchable extends boolean = false>({ label, desc, labelClassName, className, value, options, nullable, disabled, multiple, searchable, placeholder, selectClassName, selectorClassName, selectedClassName, onOpen, onChange, onSearch, renderOption, renderSelected, }: SelectProps<T, Multiple, Searchable>) => import("react/jsx-runtime").JSX.Element;
|
|
29
32
|
export {};
|
package/cjs/DraggableList.js
CHANGED
|
@@ -38,9 +38,11 @@ var import_react = require("@use-gesture/react");
|
|
|
38
38
|
var import_lodash = __toESM(require("lodash.clamp"));
|
|
39
39
|
var import_lodash_move = __toESM(require("lodash-move"));
|
|
40
40
|
var import_react2 = require("react");
|
|
41
|
+
var import_bi = require("react-icons/bi");
|
|
42
|
+
var import_md = require("react-icons/md");
|
|
41
43
|
const dragListContext = (0, import_react2.createContext)({});
|
|
42
44
|
const useDragList = () => (0, import_react2.useContext)(dragListContext);
|
|
43
|
-
const DragList = ({ className, mode = "vertical", children, onChange }) => {
|
|
45
|
+
const DragList = ({ className, mode = "vertical", children, onChange, onRemove }) => {
|
|
44
46
|
const refs = (0, import_react2.useRef)([]);
|
|
45
47
|
const order = (0, import_react2.useRef)(children.map((_, index) => index));
|
|
46
48
|
const clientLengths = (0, import_react2.useRef)(children.map((_, index) => 0));
|
|
@@ -103,7 +105,18 @@ const DragList = ({ className, mode = "vertical", children, onChange }) => {
|
|
|
103
105
|
...mode === "vertical" ? { y: movement } : { x: movement }
|
|
104
106
|
// cursor: "grab",
|
|
105
107
|
},
|
|
106
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
108
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
109
|
+
dragListContext.Provider,
|
|
110
|
+
{
|
|
111
|
+
value: {
|
|
112
|
+
bind: () => bind(i),
|
|
113
|
+
onRemove: () => {
|
|
114
|
+
onRemove(children[i].props.value, i);
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
children: children[i]
|
|
118
|
+
}
|
|
119
|
+
)
|
|
107
120
|
},
|
|
108
121
|
i
|
|
109
122
|
)) });
|
|
@@ -120,7 +133,21 @@ DragList.Cursor = ({ className, children }) => {
|
|
|
120
133
|
);
|
|
121
134
|
};
|
|
122
135
|
const Item = ({ value, children }) => {
|
|
123
|
-
|
|
136
|
+
const { onRemove } = useDragList();
|
|
137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex w-full items-center gap-2", children: [
|
|
138
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DraggableList.Cursor, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_md.MdDragIndicator, { className: "text-xl" }) }),
|
|
139
|
+
children,
|
|
140
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
141
|
+
"button",
|
|
142
|
+
{
|
|
143
|
+
className: "btn btn-xs btn-error btn-square btn-outline",
|
|
144
|
+
onClick: () => {
|
|
145
|
+
onRemove(value);
|
|
146
|
+
},
|
|
147
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_bi.BiTrash, {})
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
] }) });
|
|
124
151
|
};
|
|
125
152
|
DragList.Item = Item;
|
|
126
153
|
const fn = (order, heights, newHeights, active = false, originalIndex = 0, movement = 0, finished = false) => (index) => {
|
package/cjs/Field.js
CHANGED
|
@@ -401,45 +401,55 @@ const TextList = ({
|
|
|
401
401
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_client.clsx)("flex flex-col", className), children: [
|
|
402
402
|
label ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { className: labelClassName, nullable: !minlength, label, desc }) : null,
|
|
403
403
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-5 h-full gap-2 rounded-md border border-gray-300 p-2", children: [
|
|
404
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
404
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
405
|
+
import_DraggableList.DraggableList,
|
|
406
|
+
{
|
|
407
|
+
className: "h-full gap-2",
|
|
408
|
+
onChange,
|
|
409
|
+
onRemove: (_, idx) => {
|
|
410
|
+
onChange(value.filter((_2, i) => i !== idx));
|
|
411
|
+
},
|
|
412
|
+
children: value.map((text, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DraggableList.DraggableList.Item, { value: text, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex w-full items-center", children: [
|
|
413
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DraggableList.DraggableList.Cursor, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_md.MdDragIndicator, { className: "text-xl" }) }),
|
|
414
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex w-full items-center justify-center gap-5", children: [
|
|
415
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
416
|
+
import_Input.Input,
|
|
417
|
+
{
|
|
418
|
+
value: text,
|
|
419
|
+
cacheKey: cache ? `${label}-${desc}-textList-[${idx}]` : void 0,
|
|
420
|
+
onChange: (text2) => {
|
|
421
|
+
const newValue = [...value];
|
|
422
|
+
newValue[idx] = transform(text2);
|
|
423
|
+
onChange(newValue);
|
|
424
|
+
},
|
|
425
|
+
validate: (text2) => {
|
|
426
|
+
if (text2.length < minlength)
|
|
427
|
+
return l("shared.textTooShortError", { minlength: minTextlength });
|
|
428
|
+
else if (text2.length > maxlength)
|
|
429
|
+
return l("shared.textTooLongError", { maxlength: maxTextlength });
|
|
430
|
+
else
|
|
431
|
+
return validate?.(text2) ?? true;
|
|
432
|
+
},
|
|
433
|
+
className: (0, import_client.clsx)("w-full", inputClassName),
|
|
434
|
+
inputClassName: "w-full input-sm",
|
|
435
|
+
placeholder,
|
|
436
|
+
disabled
|
|
437
|
+
}
|
|
438
|
+
),
|
|
439
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
440
|
+
"button",
|
|
441
|
+
{
|
|
442
|
+
className: "btn btn-xs btn-error btn-square btn-outline",
|
|
443
|
+
onClick: () => {
|
|
444
|
+
onChange(value.filter((_, i) => i !== idx));
|
|
445
|
+
},
|
|
446
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_bi.BiTrash, {})
|
|
447
|
+
}
|
|
448
|
+
)
|
|
449
|
+
] })
|
|
450
|
+
] }) }, idx))
|
|
451
|
+
}
|
|
452
|
+
),
|
|
443
453
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "bg-base-content/20 my-5 h-[0.5px]" }),
|
|
444
454
|
value.length <= maxTextlength ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
445
455
|
"button",
|
|
@@ -982,7 +992,10 @@ const Parent = ({
|
|
|
982
992
|
selectClassName,
|
|
983
993
|
value: value?.id,
|
|
984
994
|
searchable: true,
|
|
985
|
-
options: modelList.map((model) =>
|
|
995
|
+
options: modelList.map((model) => {
|
|
996
|
+
const render = renderOption(model);
|
|
997
|
+
return { label: typeof render === "string" ? render : model.id, value: model.id };
|
|
998
|
+
}),
|
|
986
999
|
renderOption: (modelId) => {
|
|
987
1000
|
const model = modelList.get(modelId);
|
|
988
1001
|
if (!model)
|
|
@@ -1002,11 +1015,7 @@ const Parent = ({
|
|
|
1002
1015
|
if (!disabled)
|
|
1003
1016
|
void storeDo[namesOfSlice.initModel](...initArgs ?? []);
|
|
1004
1017
|
},
|
|
1005
|
-
onSearch
|
|
1006
|
-
if (text) {
|
|
1007
|
-
onSearch?.(text);
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1018
|
+
onSearch
|
|
1010
1019
|
}
|
|
1011
1020
|
)
|
|
1012
1021
|
] });
|
|
@@ -1058,18 +1067,21 @@ const ParentId = ({
|
|
|
1058
1067
|
labelClassName,
|
|
1059
1068
|
selectClassName,
|
|
1060
1069
|
value,
|
|
1061
|
-
options: modelList.map((model) =>
|
|
1070
|
+
options: modelList.map((model) => {
|
|
1071
|
+
const label2 = renderOption?.(model) ?? model.id;
|
|
1072
|
+
return { label: typeof label2 === "string" ? label2 : model.id, value: model.id };
|
|
1073
|
+
}),
|
|
1062
1074
|
renderOption: (renderId) => {
|
|
1063
1075
|
const model = modelList.get(renderId);
|
|
1064
1076
|
if (!model)
|
|
1065
1077
|
return null;
|
|
1066
|
-
return renderOption?.(model);
|
|
1078
|
+
return renderOption?.(model) ?? null;
|
|
1067
1079
|
},
|
|
1068
1080
|
renderSelected: (renderId) => {
|
|
1069
1081
|
const model = modelList.get(renderId);
|
|
1070
1082
|
if (!model)
|
|
1071
1083
|
return null;
|
|
1072
|
-
return renderSelected?.(model);
|
|
1084
|
+
return renderSelected?.(model) ?? null;
|
|
1073
1085
|
},
|
|
1074
1086
|
onOpen: () => {
|
|
1075
1087
|
if (!disabled)
|
|
@@ -1078,11 +1090,7 @@ const ParentId = ({
|
|
|
1078
1090
|
onChange: (modelId) => {
|
|
1079
1091
|
onChange(modelId, modelList.get(modelId));
|
|
1080
1092
|
},
|
|
1081
|
-
onSearch
|
|
1082
|
-
if (text) {
|
|
1083
|
-
onSearch?.(text);
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1093
|
+
onSearch
|
|
1086
1094
|
}
|
|
1087
1095
|
)
|
|
1088
1096
|
] });
|
|
@@ -1139,7 +1147,10 @@ const Children = ({
|
|
|
1139
1147
|
selectClassName,
|
|
1140
1148
|
multiple: true,
|
|
1141
1149
|
value: value.map((model) => model.id),
|
|
1142
|
-
options: modelList.map((model) =>
|
|
1150
|
+
options: modelList.map((model) => {
|
|
1151
|
+
const label2 = renderOption(model);
|
|
1152
|
+
return { label: typeof label2 === "string" ? label2 : model.id, value: model.id };
|
|
1153
|
+
}),
|
|
1143
1154
|
renderOption: (modelId) => {
|
|
1144
1155
|
const model = modelList.get(modelId);
|
|
1145
1156
|
if (!model)
|
|
@@ -1155,11 +1166,7 @@ const Children = ({
|
|
|
1155
1166
|
onChange: (modelIds) => {
|
|
1156
1167
|
onChange(modelIds.map((id) => modelList.get(id)).filter((model) => model !== void 0));
|
|
1157
1168
|
},
|
|
1158
|
-
onSearch
|
|
1159
|
-
if (text) {
|
|
1160
|
-
onSearch?.(text);
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1169
|
+
onSearch
|
|
1163
1170
|
}
|
|
1164
1171
|
)
|
|
1165
1172
|
] });
|
|
@@ -1209,7 +1216,10 @@ const ChildrenId = ({
|
|
|
1209
1216
|
labelClassName,
|
|
1210
1217
|
multiple: true,
|
|
1211
1218
|
value,
|
|
1212
|
-
options: modelList.map((model) =>
|
|
1219
|
+
options: modelList.map((model) => {
|
|
1220
|
+
const label2 = renderOption(model);
|
|
1221
|
+
return { label: typeof label2 === "string" ? label2 : model.id, value: model.id };
|
|
1222
|
+
}),
|
|
1213
1223
|
renderOption: (renderId) => {
|
|
1214
1224
|
const model = modelList.get(renderId);
|
|
1215
1225
|
if (!model)
|
|
@@ -1219,11 +1229,7 @@ const ChildrenId = ({
|
|
|
1219
1229
|
onChange: (modelIds) => {
|
|
1220
1230
|
onChange(modelIds);
|
|
1221
1231
|
},
|
|
1222
|
-
onSearch
|
|
1223
|
-
if (text) {
|
|
1224
|
-
onSearch?.(text);
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1232
|
+
onSearch
|
|
1227
1233
|
}
|
|
1228
1234
|
)
|
|
1229
1235
|
] });
|
package/cjs/Input.js
CHANGED
|
@@ -46,7 +46,7 @@ const Input = ({
|
|
|
46
46
|
}) => {
|
|
47
47
|
const { l } = (0, import_next.usePage)();
|
|
48
48
|
const [firstFocus, setFirstFocus] = (0, import_react.useState)(true);
|
|
49
|
-
const validateResult = validate(value);
|
|
49
|
+
const validateResult = validate ? validate(value) : void 0;
|
|
50
50
|
const status = !nullable && !value ? null : !value.length ? "warning" : validateResult === true ? "success" : "error";
|
|
51
51
|
const invalidMessage = value && !value.length || validateResult === true || firstFocus ? null : validateResult === false ? l("util.invalidValueError") : validateResult;
|
|
52
52
|
const statusClass = inputStyleType === "bordered" ? status === "error" ? "input-error" : !firstFocus && status === "warning" ? "input-warning" : status === "success" ? "input-success" : "" : "";
|
|
@@ -407,7 +407,7 @@ const Number = ({
|
|
|
407
407
|
(0, import_react.useEffect)(() => {
|
|
408
408
|
setFormatValue(generateFormat());
|
|
409
409
|
}, [value]);
|
|
410
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_client.clsx)("relative isolate
|
|
410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_client.clsx)("relative isolate", className), children: [
|
|
411
411
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_client.clsx)("flex items-center", inputWrapperClassName), children: [
|
|
412
412
|
icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_client.clsx)("absolute inset-y-0 left-4 z-10 flex items-center justify-center", iconClassName), children: icon }) : null,
|
|
413
413
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
package/cjs/Layout/Template.js
CHANGED
|
@@ -23,5 +23,5 @@ module.exports = __toCommonJS(Template_exports);
|
|
|
23
23
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
24
24
|
var import_client = require("@akanjs/client");
|
|
25
25
|
const Template = ({ className, children }) => {
|
|
26
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_client.clsx)("flex w-full max-w-[100vw] flex-col gap-6 p-2
|
|
26
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_client.clsx)("flex w-full max-w-[100vw] flex-col gap-6 p-2", className), children });
|
|
27
27
|
};
|
package/cjs/Link/CsrLink.js
CHANGED
|
@@ -38,19 +38,21 @@ function CsrLink({
|
|
|
38
38
|
const prefix = import_store.st.use.prefix();
|
|
39
39
|
const currentPath = import_store.st.use.path();
|
|
40
40
|
const { lang } = (0, import_next.usePage)();
|
|
41
|
-
const
|
|
42
|
-
const { path } = (0, import_client.getPathInfo)(href, lang, prefix ?? "");
|
|
41
|
+
const { path, hash } = (0, import_client.getPathInfo)(href, lang, prefix ?? "");
|
|
43
42
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
44
43
|
"a",
|
|
45
44
|
{
|
|
46
45
|
className: (0, import_client.clsx)("cursor-pointer", className, { [activeClassName ?? ""]: currentPath === path }),
|
|
47
46
|
onClick: () => {
|
|
47
|
+
const isExternal = href.startsWith("http") || href.startsWith("mailto:") || href.startsWith("tel:");
|
|
48
|
+
const isHash = href.startsWith("#");
|
|
49
|
+
const url = isHash ? `${window.location.pathname}#${hash}` : href;
|
|
48
50
|
if (isExternal)
|
|
49
51
|
void import_browser.Browser.open({ url: href, presentationStyle: "popover" });
|
|
50
52
|
else if (replace)
|
|
51
|
-
import_client.router.replace(
|
|
53
|
+
import_client.router.replace(url, { scrollToTop });
|
|
52
54
|
else
|
|
53
|
-
import_client.router.push(
|
|
55
|
+
import_client.router.push(url, { scrollToTop });
|
|
54
56
|
},
|
|
55
57
|
children
|
|
56
58
|
}
|
package/cjs/Link/NextLink.js
CHANGED
|
@@ -49,19 +49,22 @@ function NextLink({
|
|
|
49
49
|
}) {
|
|
50
50
|
const prefix = import_store.st.use.prefix();
|
|
51
51
|
const { lang } = (0, import_next.usePage)();
|
|
52
|
-
const isExternal = href.startsWith("http") || href.startsWith("mailto:") || href.startsWith("tel:");
|
|
53
|
-
const { path, pathname } = (0, import_client.getPathInfo)(href, lang, prefix ?? "");
|
|
54
52
|
const currentPath = import_store.st.use.path();
|
|
53
|
+
const isExternal = href.startsWith("http") || href.startsWith("mailto:") || href.startsWith("tel:");
|
|
54
|
+
const { href: requestHref, path } = (0, import_client.getPathInfo)(href, lang, prefix ?? "");
|
|
55
|
+
if (href.startsWith("#")) {
|
|
56
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: (0, import_client.clsx)(className, { [activeClassName ?? ""]: currentPath === path }), href, children });
|
|
57
|
+
}
|
|
55
58
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
56
59
|
import_link.default,
|
|
57
60
|
{
|
|
58
61
|
className: (0, import_client.clsx)(className, { [activeClassName ?? ""]: currentPath === path }),
|
|
59
|
-
href: isExternal ? href :
|
|
62
|
+
href: isExternal ? href : href.startsWith("#") ? href : requestHref,
|
|
60
63
|
passHref: true,
|
|
61
64
|
replace,
|
|
62
65
|
onClick: () => {
|
|
63
|
-
import_common.Logger.log(`pathChange-start:${
|
|
64
|
-
window.parent.postMessage({ type: "pathChange",
|
|
66
|
+
import_common.Logger.log(`pathChange-start:${requestHref}`);
|
|
67
|
+
window.parent.postMessage({ type: "pathChange", href: requestHref }, "*");
|
|
65
68
|
if (scrollToTop)
|
|
66
69
|
window.scrollTo(0, 0);
|
|
67
70
|
},
|
|
@@ -50,76 +50,82 @@ function SureToRemove({
|
|
|
50
50
|
}),
|
|
51
51
|
[]
|
|
52
52
|
);
|
|
53
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
className: "inline size-full",
|
|
57
|
+
onClick: (e) => {
|
|
58
|
+
e.stopPropagation();
|
|
59
|
+
setModalOpen(true);
|
|
60
|
+
},
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
63
|
+
"div",
|
|
64
|
+
{
|
|
65
|
+
className: (0, import_client.clsx)(
|
|
66
|
+
"text-error flex size-full cursor-pointer flex-nowrap items-center justify-center gap-2 whitespace-nowrap",
|
|
67
|
+
className
|
|
68
|
+
),
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ai.AiOutlineDelete, {}),
|
|
71
|
+
" ",
|
|
72
|
+
l("shared.remove")
|
|
73
|
+
]
|
|
74
|
+
}
|
|
60
75
|
),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
setModalOpen(true);
|
|
64
|
-
},
|
|
65
|
-
children: [
|
|
66
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ai.AiOutlineDelete, {}),
|
|
67
|
-
" ",
|
|
68
|
-
l("shared.remove")
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
),
|
|
72
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
73
|
-
import_Modal.Modal,
|
|
74
|
-
{
|
|
75
|
-
open: modalOpen,
|
|
76
|
-
onCancel: () => {
|
|
77
|
-
setModalOpen(false);
|
|
78
|
-
},
|
|
79
|
-
title: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-error text-lg font-bold", children: l("shared.removeModel", { model: l(`${modelName}.modelName`) }) }),
|
|
80
|
-
bodyClassName: "border-error",
|
|
81
|
-
action: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
82
|
-
"button",
|
|
76
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
77
|
+
import_Modal.Modal,
|
|
83
78
|
{
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
onClick: async () => {
|
|
87
|
-
await storeDo[names.removeModel](modelId);
|
|
88
|
-
import_dictionary.msg.success("shared.removeSuccess", { data: { model: l(`${modelName}.modelName`) } });
|
|
79
|
+
open: modalOpen,
|
|
80
|
+
onCancel: () => {
|
|
89
81
|
setModalOpen(false);
|
|
90
|
-
if (!redirect)
|
|
91
|
-
return;
|
|
92
|
-
if (redirect === "back")
|
|
93
|
-
import_client.router.back();
|
|
94
|
-
else
|
|
95
|
-
import_client.router.push(redirect);
|
|
96
82
|
},
|
|
97
|
-
children: l("shared.removeModel", { model: l(`${modelName}.modelName`) })
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
onChange: (e) => {
|
|
117
|
-
setRepeatName(e.target.value);
|
|
83
|
+
title: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-error text-lg font-bold", children: l("shared.removeModel", { model: l(`${modelName}.modelName`) }) }),
|
|
84
|
+
bodyClassName: "border-error",
|
|
85
|
+
action: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
|
+
"button",
|
|
87
|
+
{
|
|
88
|
+
className: "btn btn-error w-full",
|
|
89
|
+
disabled: typeNameToRemove && repeatName !== name,
|
|
90
|
+
onClick: async () => {
|
|
91
|
+
await storeDo[names.removeModel](modelId);
|
|
92
|
+
import_dictionary.msg.success("shared.removeSuccess", { data: { model: l(`${modelName}.modelName`) } });
|
|
93
|
+
setModalOpen(false);
|
|
94
|
+
if (!redirect)
|
|
95
|
+
return;
|
|
96
|
+
if (redirect === "back")
|
|
97
|
+
import_client.router.back();
|
|
98
|
+
else
|
|
99
|
+
import_client.router.push(redirect);
|
|
100
|
+
},
|
|
101
|
+
children: l("shared.removeModel", { model: l(`${modelName}.modelName`) })
|
|
118
102
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
103
|
+
),
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "py-4", children: [
|
|
106
|
+
l("shared.sureToRemove", { model: l(`${modelName}.modelName`), name }),
|
|
107
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
108
|
+
l("shared.irreversibleOps"),
|
|
109
|
+
typeNameToRemove ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
110
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
111
|
+
l("shared.typeNameToRemove", { model: l(`${modelName}.modelName`), name })
|
|
112
|
+
] }) : null
|
|
113
|
+
] }),
|
|
114
|
+
typeNameToRemove ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
|
+
"input",
|
|
116
|
+
{
|
|
117
|
+
className: "input w-full text-center",
|
|
118
|
+
placeholder: `${l(`${modelName}.modelName`)} name`,
|
|
119
|
+
value: repeatName,
|
|
120
|
+
onChange: (e) => {
|
|
121
|
+
setRepeatName(e.target.value);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
) : null
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
);
|
|
125
131
|
}
|
package/cjs/Select.js
CHANGED
|
@@ -90,7 +90,8 @@ const Select = ({
|
|
|
90
90
|
};
|
|
91
91
|
const debouncedOnSearch = (0, import_next.useDebounce)(
|
|
92
92
|
(text) => {
|
|
93
|
-
|
|
93
|
+
if (text)
|
|
94
|
+
onSearch?.(text);
|
|
94
95
|
},
|
|
95
96
|
[searchText],
|
|
96
97
|
300
|
|
@@ -166,7 +167,7 @@ const Select = ({
|
|
|
166
167
|
return null;
|
|
167
168
|
return renderSelected ? renderSelected(optionValue.value) : optionValue.label;
|
|
168
169
|
})() }) : "" }),
|
|
169
|
-
searchable
|
|
170
|
+
searchable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
170
171
|
"input",
|
|
171
172
|
{
|
|
172
173
|
type: "text",
|
|
@@ -176,12 +177,13 @@ const Select = ({
|
|
|
176
177
|
onChange: (e) => {
|
|
177
178
|
if (!isOpen)
|
|
178
179
|
setIsOpen(true);
|
|
179
|
-
if (!onSearch)
|
|
180
|
+
if (!onSearch) {
|
|
180
181
|
setSearchOptions(
|
|
181
182
|
labeledOptions.filter(
|
|
182
183
|
(option) => option.label.toString().toLowerCase().includes(e.target.value.toLowerCase())
|
|
183
184
|
)
|
|
184
185
|
);
|
|
186
|
+
}
|
|
185
187
|
setSearchText(e.target.value);
|
|
186
188
|
debouncedOnSearch(e.target.value);
|
|
187
189
|
},
|
|
@@ -191,7 +193,7 @@ const Select = ({
|
|
|
191
193
|
setIsOpen(!isOpen);
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
|
-
)
|
|
196
|
+
) : null
|
|
195
197
|
] }),
|
|
196
198
|
multiple && selectedValues.length || !multiple && selectedValues[0] !== void 0 && selectedValues[0] !== null ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
197
199
|
import_ti.TiDelete,
|
package/cjs/System/CSR.js
CHANGED
|
@@ -64,7 +64,7 @@ const CSRProvider = ({
|
|
|
64
64
|
return { lang };
|
|
65
65
|
},
|
|
66
66
|
render: ({ lang }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
67
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Client.Client.Wrapper, { theme, children: /* @__PURE__ */ (0, import_jsx_runtime.
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Client.Client.Wrapper, { theme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
68
|
CSRWrapper,
|
|
69
69
|
{
|
|
70
70
|
className,
|
|
@@ -74,11 +74,7 @@ const CSRProvider = ({
|
|
|
74
74
|
fonts,
|
|
75
75
|
prefix,
|
|
76
76
|
layoutStyle,
|
|
77
|
-
children
|
|
78
|
-
children,
|
|
79
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Client.Client.Inner, {}),
|
|
80
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CSRInner, {})
|
|
81
|
-
]
|
|
77
|
+
children
|
|
82
78
|
}
|
|
83
79
|
) }),
|
|
84
80
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -90,6 +86,8 @@ const CSRProvider = ({
|
|
|
90
86
|
fetchMe,
|
|
91
87
|
fetchSelf,
|
|
92
88
|
render: ({ mePromise, selfPromise }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
89
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Client.Client.Inner, {}),
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CSRInner, {}),
|
|
93
91
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
94
92
|
import_Client.Client.Bridge,
|
|
95
93
|
{
|
package/cjs/System/Client.js
CHANGED
|
@@ -60,6 +60,8 @@ const ClientPathWrapper = ({
|
|
|
60
60
|
layoutStyle = "web",
|
|
61
61
|
...props
|
|
62
62
|
}) => {
|
|
63
|
+
const href = location?.href ?? (typeof window !== "undefined" ? window.location.href : "");
|
|
64
|
+
const hash = location?.hash ?? (typeof window !== "undefined" ? window.location.hash : "");
|
|
63
65
|
const pathname = location?.pathname ?? (0, import_navigation.usePathname)();
|
|
64
66
|
const params = location?.params ?? (0, import_navigation.useParams)();
|
|
65
67
|
const searchParams = location?.searchParams ?? Object.fromEntries((0, import_navigation.useSearchParams)());
|
|
@@ -80,7 +82,7 @@ const ClientPathWrapper = ({
|
|
|
80
82
|
{
|
|
81
83
|
value: {
|
|
82
84
|
pageType,
|
|
83
|
-
location: { pathname, params, searchParams, search, pathRoute },
|
|
85
|
+
location: { href, hash, pathname, params, searchParams, search, pathRoute },
|
|
84
86
|
gestureEnabled,
|
|
85
87
|
setGestureEnabled
|
|
86
88
|
},
|
package/esm/DraggableList.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { clsx } from "@akanjs/client";
|
|
4
4
|
import { animated, config, useSprings } from "@react-spring/web";
|
|
5
5
|
import { useGesture } from "@use-gesture/react";
|
|
6
6
|
import clamp from "lodash.clamp";
|
|
7
7
|
import swap from "lodash-move";
|
|
8
8
|
import { createContext, useContext, useRef } from "react";
|
|
9
|
+
import { BiTrash } from "react-icons/bi";
|
|
10
|
+
import { MdDragIndicator } from "react-icons/md";
|
|
9
11
|
const dragListContext = createContext({});
|
|
10
12
|
const useDragList = () => useContext(dragListContext);
|
|
11
|
-
const DragList = ({ className, mode = "vertical", children, onChange }) => {
|
|
13
|
+
const DragList = ({ className, mode = "vertical", children, onChange, onRemove }) => {
|
|
12
14
|
const refs = useRef([]);
|
|
13
15
|
const order = useRef(children.map((_, index) => index));
|
|
14
16
|
const clientLengths = useRef(children.map((_, index) => 0));
|
|
@@ -71,7 +73,18 @@ const DragList = ({ className, mode = "vertical", children, onChange }) => {
|
|
|
71
73
|
...mode === "vertical" ? { y: movement } : { x: movement }
|
|
72
74
|
// cursor: "grab",
|
|
73
75
|
},
|
|
74
|
-
children: /* @__PURE__ */ jsx(
|
|
76
|
+
children: /* @__PURE__ */ jsx(
|
|
77
|
+
dragListContext.Provider,
|
|
78
|
+
{
|
|
79
|
+
value: {
|
|
80
|
+
bind: () => bind(i),
|
|
81
|
+
onRemove: () => {
|
|
82
|
+
onRemove(children[i].props.value, i);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
children: children[i]
|
|
86
|
+
}
|
|
87
|
+
)
|
|
75
88
|
},
|
|
76
89
|
i
|
|
77
90
|
)) });
|
|
@@ -88,7 +101,21 @@ DragList.Cursor = ({ className, children }) => {
|
|
|
88
101
|
);
|
|
89
102
|
};
|
|
90
103
|
const Item = ({ value, children }) => {
|
|
91
|
-
|
|
104
|
+
const { onRemove } = useDragList();
|
|
105
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-2", children: [
|
|
106
|
+
/* @__PURE__ */ jsx(DraggableList.Cursor, { children: /* @__PURE__ */ jsx(MdDragIndicator, { className: "text-xl" }) }),
|
|
107
|
+
children,
|
|
108
|
+
/* @__PURE__ */ jsx(
|
|
109
|
+
"button",
|
|
110
|
+
{
|
|
111
|
+
className: "btn btn-xs btn-error btn-square btn-outline",
|
|
112
|
+
onClick: () => {
|
|
113
|
+
onRemove(value);
|
|
114
|
+
},
|
|
115
|
+
children: /* @__PURE__ */ jsx(BiTrash, {})
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
] }) });
|
|
92
119
|
};
|
|
93
120
|
DragList.Item = Item;
|
|
94
121
|
const fn = (order, heights, newHeights, active = false, originalIndex = 0, movement = 0, finished = false) => (index) => {
|
package/esm/Field.js
CHANGED
|
@@ -379,45 +379,55 @@ const TextList = ({
|
|
|
379
379
|
return /* @__PURE__ */ jsxs("div", { className: clsx("flex flex-col", className), children: [
|
|
380
380
|
label ? /* @__PURE__ */ jsx(Label, { className: labelClassName, nullable: !minlength, label, desc }) : null,
|
|
381
381
|
/* @__PURE__ */ jsxs("div", { className: "mb-5 h-full gap-2 rounded-md border border-gray-300 p-2", children: [
|
|
382
|
-
/* @__PURE__ */ jsx(
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
382
|
+
/* @__PURE__ */ jsx(
|
|
383
|
+
DraggableList,
|
|
384
|
+
{
|
|
385
|
+
className: "h-full gap-2",
|
|
386
|
+
onChange,
|
|
387
|
+
onRemove: (_, idx) => {
|
|
388
|
+
onChange(value.filter((_2, i) => i !== idx));
|
|
389
|
+
},
|
|
390
|
+
children: value.map((text, idx) => /* @__PURE__ */ jsx(DraggableList.Item, { value: text, children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center", children: [
|
|
391
|
+
/* @__PURE__ */ jsx(DraggableList.Cursor, { children: /* @__PURE__ */ jsx(MdDragIndicator, { className: "text-xl" }) }),
|
|
392
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-center gap-5", children: [
|
|
393
|
+
/* @__PURE__ */ jsx(
|
|
394
|
+
Input,
|
|
395
|
+
{
|
|
396
|
+
value: text,
|
|
397
|
+
cacheKey: cache ? `${label}-${desc}-textList-[${idx}]` : void 0,
|
|
398
|
+
onChange: (text2) => {
|
|
399
|
+
const newValue = [...value];
|
|
400
|
+
newValue[idx] = transform(text2);
|
|
401
|
+
onChange(newValue);
|
|
402
|
+
},
|
|
403
|
+
validate: (text2) => {
|
|
404
|
+
if (text2.length < minlength)
|
|
405
|
+
return l("shared.textTooShortError", { minlength: minTextlength });
|
|
406
|
+
else if (text2.length > maxlength)
|
|
407
|
+
return l("shared.textTooLongError", { maxlength: maxTextlength });
|
|
408
|
+
else
|
|
409
|
+
return validate?.(text2) ?? true;
|
|
410
|
+
},
|
|
411
|
+
className: clsx("w-full", inputClassName),
|
|
412
|
+
inputClassName: "w-full input-sm",
|
|
413
|
+
placeholder,
|
|
414
|
+
disabled
|
|
415
|
+
}
|
|
416
|
+
),
|
|
417
|
+
/* @__PURE__ */ jsx(
|
|
418
|
+
"button",
|
|
419
|
+
{
|
|
420
|
+
className: "btn btn-xs btn-error btn-square btn-outline",
|
|
421
|
+
onClick: () => {
|
|
422
|
+
onChange(value.filter((_, i) => i !== idx));
|
|
423
|
+
},
|
|
424
|
+
children: /* @__PURE__ */ jsx(BiTrash, {})
|
|
425
|
+
}
|
|
426
|
+
)
|
|
427
|
+
] })
|
|
428
|
+
] }) }, idx))
|
|
429
|
+
}
|
|
430
|
+
),
|
|
421
431
|
/* @__PURE__ */ jsx("div", { className: "bg-base-content/20 my-5 h-[0.5px]" }),
|
|
422
432
|
value.length <= maxTextlength ? /* @__PURE__ */ jsx(
|
|
423
433
|
"button",
|
|
@@ -960,7 +970,10 @@ const Parent = ({
|
|
|
960
970
|
selectClassName,
|
|
961
971
|
value: value?.id,
|
|
962
972
|
searchable: true,
|
|
963
|
-
options: modelList.map((model) =>
|
|
973
|
+
options: modelList.map((model) => {
|
|
974
|
+
const render = renderOption(model);
|
|
975
|
+
return { label: typeof render === "string" ? render : model.id, value: model.id };
|
|
976
|
+
}),
|
|
964
977
|
renderOption: (modelId) => {
|
|
965
978
|
const model = modelList.get(modelId);
|
|
966
979
|
if (!model)
|
|
@@ -980,11 +993,7 @@ const Parent = ({
|
|
|
980
993
|
if (!disabled)
|
|
981
994
|
void storeDo[namesOfSlice.initModel](...initArgs ?? []);
|
|
982
995
|
},
|
|
983
|
-
onSearch
|
|
984
|
-
if (text) {
|
|
985
|
-
onSearch?.(text);
|
|
986
|
-
}
|
|
987
|
-
}
|
|
996
|
+
onSearch
|
|
988
997
|
}
|
|
989
998
|
)
|
|
990
999
|
] });
|
|
@@ -1036,18 +1045,21 @@ const ParentId = ({
|
|
|
1036
1045
|
labelClassName,
|
|
1037
1046
|
selectClassName,
|
|
1038
1047
|
value,
|
|
1039
|
-
options: modelList.map((model) =>
|
|
1048
|
+
options: modelList.map((model) => {
|
|
1049
|
+
const label2 = renderOption?.(model) ?? model.id;
|
|
1050
|
+
return { label: typeof label2 === "string" ? label2 : model.id, value: model.id };
|
|
1051
|
+
}),
|
|
1040
1052
|
renderOption: (renderId) => {
|
|
1041
1053
|
const model = modelList.get(renderId);
|
|
1042
1054
|
if (!model)
|
|
1043
1055
|
return null;
|
|
1044
|
-
return renderOption?.(model);
|
|
1056
|
+
return renderOption?.(model) ?? null;
|
|
1045
1057
|
},
|
|
1046
1058
|
renderSelected: (renderId) => {
|
|
1047
1059
|
const model = modelList.get(renderId);
|
|
1048
1060
|
if (!model)
|
|
1049
1061
|
return null;
|
|
1050
|
-
return renderSelected?.(model);
|
|
1062
|
+
return renderSelected?.(model) ?? null;
|
|
1051
1063
|
},
|
|
1052
1064
|
onOpen: () => {
|
|
1053
1065
|
if (!disabled)
|
|
@@ -1056,11 +1068,7 @@ const ParentId = ({
|
|
|
1056
1068
|
onChange: (modelId) => {
|
|
1057
1069
|
onChange(modelId, modelList.get(modelId));
|
|
1058
1070
|
},
|
|
1059
|
-
onSearch
|
|
1060
|
-
if (text) {
|
|
1061
|
-
onSearch?.(text);
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1071
|
+
onSearch
|
|
1064
1072
|
}
|
|
1065
1073
|
)
|
|
1066
1074
|
] });
|
|
@@ -1117,7 +1125,10 @@ const Children = ({
|
|
|
1117
1125
|
selectClassName,
|
|
1118
1126
|
multiple: true,
|
|
1119
1127
|
value: value.map((model) => model.id),
|
|
1120
|
-
options: modelList.map((model) =>
|
|
1128
|
+
options: modelList.map((model) => {
|
|
1129
|
+
const label2 = renderOption(model);
|
|
1130
|
+
return { label: typeof label2 === "string" ? label2 : model.id, value: model.id };
|
|
1131
|
+
}),
|
|
1121
1132
|
renderOption: (modelId) => {
|
|
1122
1133
|
const model = modelList.get(modelId);
|
|
1123
1134
|
if (!model)
|
|
@@ -1133,11 +1144,7 @@ const Children = ({
|
|
|
1133
1144
|
onChange: (modelIds) => {
|
|
1134
1145
|
onChange(modelIds.map((id) => modelList.get(id)).filter((model) => model !== void 0));
|
|
1135
1146
|
},
|
|
1136
|
-
onSearch
|
|
1137
|
-
if (text) {
|
|
1138
|
-
onSearch?.(text);
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1147
|
+
onSearch
|
|
1141
1148
|
}
|
|
1142
1149
|
)
|
|
1143
1150
|
] });
|
|
@@ -1187,7 +1194,10 @@ const ChildrenId = ({
|
|
|
1187
1194
|
labelClassName,
|
|
1188
1195
|
multiple: true,
|
|
1189
1196
|
value,
|
|
1190
|
-
options: modelList.map((model) =>
|
|
1197
|
+
options: modelList.map((model) => {
|
|
1198
|
+
const label2 = renderOption(model);
|
|
1199
|
+
return { label: typeof label2 === "string" ? label2 : model.id, value: model.id };
|
|
1200
|
+
}),
|
|
1191
1201
|
renderOption: (renderId) => {
|
|
1192
1202
|
const model = modelList.get(renderId);
|
|
1193
1203
|
if (!model)
|
|
@@ -1197,11 +1207,7 @@ const ChildrenId = ({
|
|
|
1197
1207
|
onChange: (modelIds) => {
|
|
1198
1208
|
onChange(modelIds);
|
|
1199
1209
|
},
|
|
1200
|
-
onSearch
|
|
1201
|
-
if (text) {
|
|
1202
|
-
onSearch?.(text);
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1210
|
+
onSearch
|
|
1205
1211
|
}
|
|
1206
1212
|
)
|
|
1207
1213
|
] });
|
package/esm/Input.js
CHANGED
|
@@ -28,7 +28,7 @@ const Input = ({
|
|
|
28
28
|
}) => {
|
|
29
29
|
const { l } = usePage();
|
|
30
30
|
const [firstFocus, setFirstFocus] = useState(true);
|
|
31
|
-
const validateResult = validate(value);
|
|
31
|
+
const validateResult = validate ? validate(value) : void 0;
|
|
32
32
|
const status = !nullable && !value ? null : !value.length ? "warning" : validateResult === true ? "success" : "error";
|
|
33
33
|
const invalidMessage = value && !value.length || validateResult === true || firstFocus ? null : validateResult === false ? l("util.invalidValueError") : validateResult;
|
|
34
34
|
const statusClass = inputStyleType === "bordered" ? status === "error" ? "input-error" : !firstFocus && status === "warning" ? "input-warning" : status === "success" ? "input-success" : "" : "";
|
|
@@ -389,7 +389,7 @@ const Number = ({
|
|
|
389
389
|
useEffect(() => {
|
|
390
390
|
setFormatValue(generateFormat());
|
|
391
391
|
}, [value]);
|
|
392
|
-
return /* @__PURE__ */ jsxs("div", { className: clsx("relative isolate
|
|
392
|
+
return /* @__PURE__ */ jsxs("div", { className: clsx("relative isolate", className), children: [
|
|
393
393
|
/* @__PURE__ */ jsxs("div", { className: clsx("flex items-center", inputWrapperClassName), children: [
|
|
394
394
|
icon ? /* @__PURE__ */ jsx("div", { className: clsx("absolute inset-y-0 left-4 z-10 flex items-center justify-center", iconClassName), children: icon }) : null,
|
|
395
395
|
/* @__PURE__ */ jsx(
|
package/esm/Layout/Template.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { clsx } from "@akanjs/client";
|
|
3
3
|
const Template = ({ className, children }) => {
|
|
4
|
-
return /* @__PURE__ */ jsx("div", { className: clsx("flex w-full max-w-[100vw] flex-col gap-6 p-2
|
|
4
|
+
return /* @__PURE__ */ jsx("div", { className: clsx("flex w-full max-w-[100vw] flex-col gap-6 p-2", className), children });
|
|
5
5
|
};
|
|
6
6
|
export {
|
|
7
7
|
Template
|
package/esm/Link/CsrLink.js
CHANGED
|
@@ -16,19 +16,21 @@ function CsrLink({
|
|
|
16
16
|
const prefix = st.use.prefix();
|
|
17
17
|
const currentPath = st.use.path();
|
|
18
18
|
const { lang } = usePage();
|
|
19
|
-
const
|
|
20
|
-
const { path } = getPathInfo(href, lang, prefix ?? "");
|
|
19
|
+
const { path, hash } = getPathInfo(href, lang, prefix ?? "");
|
|
21
20
|
return /* @__PURE__ */ jsx(
|
|
22
21
|
"a",
|
|
23
22
|
{
|
|
24
23
|
className: clsx("cursor-pointer", className, { [activeClassName ?? ""]: currentPath === path }),
|
|
25
24
|
onClick: () => {
|
|
25
|
+
const isExternal = href.startsWith("http") || href.startsWith("mailto:") || href.startsWith("tel:");
|
|
26
|
+
const isHash = href.startsWith("#");
|
|
27
|
+
const url = isHash ? `${window.location.pathname}#${hash}` : href;
|
|
26
28
|
if (isExternal)
|
|
27
29
|
void Browser.open({ url: href, presentationStyle: "popover" });
|
|
28
30
|
else if (replace)
|
|
29
|
-
router.replace(
|
|
31
|
+
router.replace(url, { scrollToTop });
|
|
30
32
|
else
|
|
31
|
-
router.push(
|
|
33
|
+
router.push(url, { scrollToTop });
|
|
32
34
|
},
|
|
33
35
|
children
|
|
34
36
|
}
|
package/esm/Link/NextLink.js
CHANGED
|
@@ -17,19 +17,22 @@ function NextLink({
|
|
|
17
17
|
}) {
|
|
18
18
|
const prefix = st.use.prefix();
|
|
19
19
|
const { lang } = usePage();
|
|
20
|
-
const isExternal = href.startsWith("http") || href.startsWith("mailto:") || href.startsWith("tel:");
|
|
21
|
-
const { path, pathname } = getPathInfo(href, lang, prefix ?? "");
|
|
22
20
|
const currentPath = st.use.path();
|
|
21
|
+
const isExternal = href.startsWith("http") || href.startsWith("mailto:") || href.startsWith("tel:");
|
|
22
|
+
const { href: requestHref, path } = getPathInfo(href, lang, prefix ?? "");
|
|
23
|
+
if (href.startsWith("#")) {
|
|
24
|
+
return /* @__PURE__ */ jsx("a", { className: clsx(className, { [activeClassName ?? ""]: currentPath === path }), href, children });
|
|
25
|
+
}
|
|
23
26
|
return /* @__PURE__ */ jsx(
|
|
24
27
|
NextjsLink,
|
|
25
28
|
{
|
|
26
29
|
className: clsx(className, { [activeClassName ?? ""]: currentPath === path }),
|
|
27
|
-
href: isExternal ? href :
|
|
30
|
+
href: isExternal ? href : href.startsWith("#") ? href : requestHref,
|
|
28
31
|
passHref: true,
|
|
29
32
|
replace,
|
|
30
33
|
onClick: () => {
|
|
31
|
-
Logger.log(`pathChange-start:${
|
|
32
|
-
window.parent.postMessage({ type: "pathChange",
|
|
34
|
+
Logger.log(`pathChange-start:${requestHref}`);
|
|
35
|
+
window.parent.postMessage({ type: "pathChange", href: requestHref }, "*");
|
|
33
36
|
if (scrollToTop)
|
|
34
37
|
window.scrollTo(0, 0);
|
|
35
38
|
},
|
|
@@ -28,78 +28,84 @@ function SureToRemove({
|
|
|
28
28
|
}),
|
|
29
29
|
[]
|
|
30
30
|
);
|
|
31
|
-
return /* @__PURE__ */ jsxs(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
return /* @__PURE__ */ jsxs(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
className: "inline size-full",
|
|
35
|
+
onClick: (e) => {
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
setModalOpen(true);
|
|
38
|
+
},
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsxs(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
className: clsx(
|
|
44
|
+
"text-error flex size-full cursor-pointer flex-nowrap items-center justify-center gap-2 whitespace-nowrap",
|
|
45
|
+
className
|
|
46
|
+
),
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ jsx(AiOutlineDelete, {}),
|
|
49
|
+
" ",
|
|
50
|
+
l("shared.remove")
|
|
51
|
+
]
|
|
52
|
+
}
|
|
38
53
|
),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
setModalOpen(true);
|
|
42
|
-
},
|
|
43
|
-
children: [
|
|
44
|
-
/* @__PURE__ */ jsx(AiOutlineDelete, {}),
|
|
45
|
-
" ",
|
|
46
|
-
l("shared.remove")
|
|
47
|
-
]
|
|
48
|
-
}
|
|
49
|
-
),
|
|
50
|
-
/* @__PURE__ */ jsxs(
|
|
51
|
-
Modal,
|
|
52
|
-
{
|
|
53
|
-
open: modalOpen,
|
|
54
|
-
onCancel: () => {
|
|
55
|
-
setModalOpen(false);
|
|
56
|
-
},
|
|
57
|
-
title: /* @__PURE__ */ jsx("div", { className: "text-error text-lg font-bold", children: l("shared.removeModel", { model: l(`${modelName}.modelName`) }) }),
|
|
58
|
-
bodyClassName: "border-error",
|
|
59
|
-
action: /* @__PURE__ */ jsx(
|
|
60
|
-
"button",
|
|
54
|
+
/* @__PURE__ */ jsxs(
|
|
55
|
+
Modal,
|
|
61
56
|
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
onClick: async () => {
|
|
65
|
-
await storeDo[names.removeModel](modelId);
|
|
66
|
-
msg.success("shared.removeSuccess", { data: { model: l(`${modelName}.modelName`) } });
|
|
57
|
+
open: modalOpen,
|
|
58
|
+
onCancel: () => {
|
|
67
59
|
setModalOpen(false);
|
|
68
|
-
if (!redirect)
|
|
69
|
-
return;
|
|
70
|
-
if (redirect === "back")
|
|
71
|
-
router.back();
|
|
72
|
-
else
|
|
73
|
-
router.push(redirect);
|
|
74
60
|
},
|
|
75
|
-
children: l("shared.removeModel", { model: l(`${modelName}.modelName`) })
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
onChange: (e) => {
|
|
95
|
-
setRepeatName(e.target.value);
|
|
61
|
+
title: /* @__PURE__ */ jsx("div", { className: "text-error text-lg font-bold", children: l("shared.removeModel", { model: l(`${modelName}.modelName`) }) }),
|
|
62
|
+
bodyClassName: "border-error",
|
|
63
|
+
action: /* @__PURE__ */ jsx(
|
|
64
|
+
"button",
|
|
65
|
+
{
|
|
66
|
+
className: "btn btn-error w-full",
|
|
67
|
+
disabled: typeNameToRemove && repeatName !== name,
|
|
68
|
+
onClick: async () => {
|
|
69
|
+
await storeDo[names.removeModel](modelId);
|
|
70
|
+
msg.success("shared.removeSuccess", { data: { model: l(`${modelName}.modelName`) } });
|
|
71
|
+
setModalOpen(false);
|
|
72
|
+
if (!redirect)
|
|
73
|
+
return;
|
|
74
|
+
if (redirect === "back")
|
|
75
|
+
router.back();
|
|
76
|
+
else
|
|
77
|
+
router.push(redirect);
|
|
78
|
+
},
|
|
79
|
+
children: l("shared.removeModel", { model: l(`${modelName}.modelName`) })
|
|
96
80
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
81
|
+
),
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ jsxs("div", { className: "py-4", children: [
|
|
84
|
+
l("shared.sureToRemove", { model: l(`${modelName}.modelName`), name }),
|
|
85
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
86
|
+
l("shared.irreversibleOps"),
|
|
87
|
+
typeNameToRemove ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
88
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
89
|
+
l("shared.typeNameToRemove", { model: l(`${modelName}.modelName`), name })
|
|
90
|
+
] }) : null
|
|
91
|
+
] }),
|
|
92
|
+
typeNameToRemove ? /* @__PURE__ */ jsx(
|
|
93
|
+
"input",
|
|
94
|
+
{
|
|
95
|
+
className: "input w-full text-center",
|
|
96
|
+
placeholder: `${l(`${modelName}.modelName`)} name`,
|
|
97
|
+
value: repeatName,
|
|
98
|
+
onChange: (e) => {
|
|
99
|
+
setRepeatName(e.target.value);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
) : null
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
);
|
|
103
109
|
}
|
|
104
110
|
export {
|
|
105
111
|
SureToRemove as default
|
package/esm/Select.js
CHANGED
|
@@ -68,7 +68,8 @@ const Select = ({
|
|
|
68
68
|
};
|
|
69
69
|
const debouncedOnSearch = useDebounce(
|
|
70
70
|
(text) => {
|
|
71
|
-
|
|
71
|
+
if (text)
|
|
72
|
+
onSearch?.(text);
|
|
72
73
|
},
|
|
73
74
|
[searchText],
|
|
74
75
|
300
|
|
@@ -144,7 +145,7 @@ const Select = ({
|
|
|
144
145
|
return null;
|
|
145
146
|
return renderSelected ? renderSelected(optionValue.value) : optionValue.label;
|
|
146
147
|
})() }) : "" }),
|
|
147
|
-
searchable
|
|
148
|
+
searchable ? /* @__PURE__ */ jsx(
|
|
148
149
|
"input",
|
|
149
150
|
{
|
|
150
151
|
type: "text",
|
|
@@ -154,12 +155,13 @@ const Select = ({
|
|
|
154
155
|
onChange: (e) => {
|
|
155
156
|
if (!isOpen)
|
|
156
157
|
setIsOpen(true);
|
|
157
|
-
if (!onSearch)
|
|
158
|
+
if (!onSearch) {
|
|
158
159
|
setSearchOptions(
|
|
159
160
|
labeledOptions.filter(
|
|
160
161
|
(option) => option.label.toString().toLowerCase().includes(e.target.value.toLowerCase())
|
|
161
162
|
)
|
|
162
163
|
);
|
|
164
|
+
}
|
|
163
165
|
setSearchText(e.target.value);
|
|
164
166
|
debouncedOnSearch(e.target.value);
|
|
165
167
|
},
|
|
@@ -169,7 +171,7 @@ const Select = ({
|
|
|
169
171
|
setIsOpen(!isOpen);
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
|
-
)
|
|
174
|
+
) : null
|
|
173
175
|
] }),
|
|
174
176
|
multiple && selectedValues.length || !multiple && selectedValues[0] !== void 0 && selectedValues[0] !== null ? /* @__PURE__ */ jsx(
|
|
175
177
|
TiDelete,
|
package/esm/System/CSR.js
CHANGED
|
@@ -41,7 +41,7 @@ const CSRProvider = ({
|
|
|
41
41
|
return { lang };
|
|
42
42
|
},
|
|
43
43
|
render: ({ lang }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
|
-
/* @__PURE__ */ jsx(Client.Wrapper, { theme, children: /* @__PURE__ */
|
|
44
|
+
/* @__PURE__ */ jsx(Client.Wrapper, { theme, children: /* @__PURE__ */ jsx(
|
|
45
45
|
CSRWrapper,
|
|
46
46
|
{
|
|
47
47
|
className,
|
|
@@ -51,11 +51,7 @@ const CSRProvider = ({
|
|
|
51
51
|
fonts,
|
|
52
52
|
prefix,
|
|
53
53
|
layoutStyle,
|
|
54
|
-
children
|
|
55
|
-
children,
|
|
56
|
-
/* @__PURE__ */ jsx(Client.Inner, {}),
|
|
57
|
-
/* @__PURE__ */ jsx(CSRInner, {})
|
|
58
|
-
]
|
|
54
|
+
children
|
|
59
55
|
}
|
|
60
56
|
) }),
|
|
61
57
|
/* @__PURE__ */ jsx(
|
|
@@ -67,6 +63,8 @@ const CSRProvider = ({
|
|
|
67
63
|
fetchMe,
|
|
68
64
|
fetchSelf,
|
|
69
65
|
render: ({ mePromise, selfPromise }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
66
|
+
/* @__PURE__ */ jsx(Client.Inner, {}),
|
|
67
|
+
/* @__PURE__ */ jsx(CSRInner, {}),
|
|
70
68
|
/* @__PURE__ */ jsx(
|
|
71
69
|
Client.Bridge,
|
|
72
70
|
{
|
package/esm/System/Client.js
CHANGED
|
@@ -43,6 +43,8 @@ const ClientPathWrapper = ({
|
|
|
43
43
|
layoutStyle = "web",
|
|
44
44
|
...props
|
|
45
45
|
}) => {
|
|
46
|
+
const href = location?.href ?? (typeof window !== "undefined" ? window.location.href : "");
|
|
47
|
+
const hash = location?.hash ?? (typeof window !== "undefined" ? window.location.hash : "");
|
|
46
48
|
const pathname = location?.pathname ?? usePathname();
|
|
47
49
|
const params = location?.params ?? useParams();
|
|
48
50
|
const searchParams = location?.searchParams ?? Object.fromEntries(useSearchParams());
|
|
@@ -63,7 +65,7 @@ const ClientPathWrapper = ({
|
|
|
63
65
|
{
|
|
64
66
|
value: {
|
|
65
67
|
pageType,
|
|
66
|
-
location: { pathname, params, searchParams, search, pathRoute },
|
|
68
|
+
location: { href, hash, pathname, params, searchParams, search, pathRoute },
|
|
67
69
|
gestureEnabled,
|
|
68
70
|
setGestureEnabled
|
|
69
71
|
},
|