kintone-pretty-fields 0.4.0 → 0.5.0
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/README.md +14 -9
- package/dist/functions/formField.d.ts +5 -1
- package/dist/functions/formField.d.ts.map +1 -1
- package/dist/functions/utility.d.ts +1 -1
- package/dist/functions/utility.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -92
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -117,20 +117,25 @@ Here is a sample code that retrieves form fields of an app.
|
|
|
117
117
|
|
|
118
118
|
```ts
|
|
119
119
|
import { KintoneRestAPIClient } from "@kintone/rest-api-client";
|
|
120
|
-
import { kintonePrettyFields } from "kintone-pretty-fields";
|
|
120
|
+
import { kintonePrettyFields, kintonePrettyType } from "kintone-pretty-fields";
|
|
121
121
|
|
|
122
122
|
const client = new KintoneRestAPIClient();
|
|
123
123
|
const { fields, spacers } = await kintonePrettyFields.get({ client, app: 1, lang: "en", preview: false });
|
|
124
124
|
console.log({ fields, spacers });
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
126
|
+
const checkBoxFields = fields.filter(kintonePrettyFields.isCheckBox);
|
|
127
|
+
console.log(checkBoxFields);
|
|
128
|
+
|
|
129
|
+
const inSubtableFields = fields.filter(kintonePrettyFields.enableInSubtable).filter(kintonePrettyFields.isInSubtable);
|
|
130
|
+
console.log(inSubtableFields);
|
|
131
|
+
|
|
132
|
+
const myFunction1 = (fields: kintonePrettyType.OneOf[]) => {
|
|
133
|
+
// do something
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const myFunction2 = (field: kintonePrettyType.CheckBox) => {
|
|
137
|
+
// do something
|
|
138
|
+
};
|
|
134
139
|
```
|
|
135
140
|
|
|
136
141
|
## License
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as kintonePrettyType from "../exportTypes/formField";
|
|
2
2
|
export declare const isRecordNumber: (field: kintonePrettyType.OneOf) => field is kintonePrettyType.RecordNumber;
|
|
3
3
|
export declare const isCreator: (field: kintonePrettyType.OneOf) => field is kintonePrettyType.Creator;
|
|
4
4
|
export declare const isCreatedTime: (field: kintonePrettyType.OneOf) => field is kintonePrettyType.CreatedTime;
|
|
@@ -32,4 +32,8 @@ export declare const isReferenceTable: (field: kintonePrettyType.OneOf) => field
|
|
|
32
32
|
export declare const isCategory: (field: kintonePrettyType.OneOf) => field is kintonePrettyType.Category;
|
|
33
33
|
export declare const isStatus: (field: kintonePrettyType.OneOf) => field is kintonePrettyType.Status;
|
|
34
34
|
export declare const isStatusAssignee: (field: kintonePrettyType.OneOf) => field is kintonePrettyType.StatusAssignee;
|
|
35
|
+
export declare const enableInSubtable: (field: kintonePrettyType.OneOf) => field is kintonePrettyType.InSubtable;
|
|
36
|
+
export declare const isInSubtable: <T extends kintonePrettyType.InSubtable>(field: T) => field is T & {
|
|
37
|
+
table: string;
|
|
38
|
+
};
|
|
35
39
|
//# sourceMappingURL=formField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formField.d.ts","sourceRoot":"","sources":["../../src/functions/formField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"formField.d.ts","sourceRoot":"","sources":["../../src/functions/formField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,iBAAiB,MAAM,0BAA0B,CAAC;AAEnE,eAAO,MAAM,cAAc,UAAW,kBAAkB,KAAK,4CAA4E,CAAC;AAC1I,eAAO,MAAM,SAAS,UAAW,kBAAkB,KAAK,uCAAiE,CAAC;AAC1H,eAAO,MAAM,aAAa,UAAW,kBAAkB,KAAK,2CAA0E,CAAC;AACvI,eAAO,MAAM,UAAU,UAAW,kBAAkB,KAAK,wCAAmE,CAAC;AAC7H,eAAO,MAAM,aAAa,UAAW,kBAAkB,KAAK,2CAA0E,CAAC;AACvI,eAAO,MAAM,gBAAgB,UAAW,kBAAkB,KAAK,8CAC5B,CAAC;AACpC,eAAO,MAAM,eAAe,UAAW,kBAAkB,KAAK,6CAC5B,CAAC;AACnC,eAAO,MAAM,UAAU,UAAW,kBAAkB,KAAK,wCAAoE,CAAC;AAC9H,eAAO,MAAM,QAAQ,UAAW,kBAAkB,KAAK,sCAA+D,CAAC;AACvH,eAAO,MAAM,MAAM,UAAW,kBAAkB,KAAK,oCAA2D,CAAC;AACjH,eAAO,MAAM,UAAU,UAAW,kBAAkB,KAAK,wCAAoE,CAAC;AAC9H,eAAO,MAAM,aAAa,UAAW,kBAAkB,KAAK,2CAA0E,CAAC;AACvI,eAAO,MAAM,aAAa,UAAW,kBAAkB,KAAK,2CAA0E,CAAC;AACvI,eAAO,MAAM,UAAU,UAAW,kBAAkB,KAAK,wCAAoE,CAAC;AAC9H,eAAO,MAAM,YAAY,UAAW,kBAAkB,KAAK,0CAAwE,CAAC;AACpI,eAAO,MAAM,oBAAoB,UAAW,kBAAkB,KAAK,kDAC7B,CAAC;AACvC,eAAO,MAAM,aAAa,UAAW,kBAAkB,KAAK,2CAA0E,CAAC;AACvI,eAAO,MAAM,MAAM,UAAW,kBAAkB,KAAK,oCAA2D,CAAC;AACjH,eAAO,MAAM,MAAM,UAAW,kBAAkB,KAAK,oCAA2D,CAAC;AACjH,eAAO,MAAM,UAAU,UAAW,kBAAkB,KAAK,wCAAmE,CAAC;AAC7H,eAAO,MAAM,MAAM,UAAW,kBAAkB,KAAK,oCAA2D,CAAC;AACjH,eAAO,MAAM,MAAM,UAAW,kBAAkB,KAAK,oCAA2D,CAAC;AACjH,eAAO,MAAM,QAAQ,UAAW,kBAAkB,KAAK,sCAC8B,CAAC;AACtF,eAAO,MAAM,UAAU,UACd,kBAAkB,KAAK;;EAC0F,CAAC;AAC3H,eAAO,MAAM,OAAO,UACX,kBAAkB,KAAK;;EACiF,CAAC;AAClH,eAAO,MAAM,gBAAgB,UAAW,kBAAkB,KAAK,8CAC7B,CAAC;AACnC,eAAO,MAAM,UAAU,UAAW,kBAAkB,KAAK,wCAAmE,CAAC;AAC7H,eAAO,MAAM,QAAQ,UAAW,kBAAkB,KAAK,sCAA+D,CAAC;AACvH,eAAO,MAAM,gBAAgB,UAAW,kBAAkB,KAAK,8CAC7B,CAAC;AACnC,eAAO,MAAM,gBAAgB,UAAW,kBAAkB,KAAK,0CAsB9D,CAAC;AACF,eAAO,MAAM,YAAY;WAA6E,MAAM;CAA+B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { KintoneRestAPIClient } from "@kintone/rest-api-client";
|
|
2
2
|
import { AppID, Lang } from "@kintone/rest-api-client/lib/src/client/types";
|
|
3
3
|
import { Spacer } from "@kintone/rest-api-client/lib/src/KintoneFields/types/fieldLayout";
|
|
4
|
-
import
|
|
4
|
+
import type * as kintonePrettyType from "../exportTypes/formField";
|
|
5
5
|
declare const get: ({ client, app, lang, preview }: {
|
|
6
6
|
client: KintoneRestAPIClient;
|
|
7
7
|
app: AppID;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../src/functions/utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAsB,MAAM,+CAA+C,CAAC;AAChG,OAAO,EAAE,MAAM,EAAE,MAAM,kEAAkE,CAAC;AAI1F,OAAO,
|
|
1
|
+
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../src/functions/utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAsB,MAAM,+CAA+C,CAAC;AAChG,OAAO,EAAE,MAAM,EAAE,MAAM,kEAAkE,CAAC;AAI1F,OAAO,KAAK,KAAK,iBAAiB,MAAM,0BAA0B,CAAC;AAuNnE,QAAA,MAAM,GAAG;YAAoD,oBAAoB;SAAO,KAAK;UAAQ,IAAI;aAAW,OAAO;;;;EAO1H,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,10 @@ declare const kintonePrettyFields: {
|
|
|
33
33
|
isCategory: (field: kintonePrettyType.OneOf) => field is kintonePrettyType.Category;
|
|
34
34
|
isStatus: (field: kintonePrettyType.OneOf) => field is kintonePrettyType.Status;
|
|
35
35
|
isStatusAssignee: (field: kintonePrettyType.OneOf) => field is kintonePrettyType.StatusAssignee;
|
|
36
|
+
enableInSubtable: (field: kintonePrettyType.OneOf) => field is kintonePrettyType.InSubtable;
|
|
37
|
+
isInSubtable: <T extends kintonePrettyType.InSubtable>(field: T) => field is T & {
|
|
38
|
+
table: string;
|
|
39
|
+
};
|
|
36
40
|
get: ({ client, app, lang, preview }: {
|
|
37
41
|
client: import("@kintone/rest-api-client").KintoneRestAPIClient;
|
|
38
42
|
app: import("@kintone/rest-api-client/lib/src/client/types").AppID;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,iBAAiB,MAAM,yBAAyB,CAAC;AAGlE,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAqC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,73 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const H = (t) => t.type === "RECORD_NUMBER", z = (t) => t.type === "CREATOR", K = (t) => t.type === "CREATED_TIME", W = (t) => t.type === "MODIFIER", Z = (t) => t.type === "UPDATED_TIME", S = (t) => t.type === "SINGLE_LINE_TEXT", m = (t) => t.type === "MULTI_LINE_TEXT", R = (t) => t.type === "RICH_TEXT", L = (t) => t.type === "NUMBER", j = (t) => t.type === "CALC", g = (t) => t.type === "CHECK_BOX", _ = (t) => t.type === "RADIO_BUTTON", C = (t) => t.type === "MULTI_SELECT", b = (t) => t.type === "DROP_DOWN", O = (t) => t.type === "USER_SELECT", I = (t) => t.type === "ORGANIZATION_SELECT", A = (t) => t.type === "GROUP_SELECT", f = (t) => t.type === "DATE", N = (t) => t.type === "TIME", D = (t) => t.type === "DATETIME", M = (t) => t.type === "LINK", v = (t) => t.type === "FILE", X = (t) => (t.type === "SINGLE_LINE_TEXT" || t.type === "NUMBER") && "lookup" in t, Y = (t) => t.type === "SUBTABLE", q = (t) => t.type === "GROUP", w = (t) => t.type === "REFERENCE_TABLE", J = (t) => t.type === "CATEGORY", Q = (t) => t.type === "STATUS", V = (t) => t.type === "STATUS_ASSIGNEE", $ = (t) => S(t) || L(t) || j(t) || m(t) || R(t) || M(t) || g(t) || _(t) || b(t) || C(t) || v(t) || f(t) || N(t) || D(t) || O(t) || I(t) || A(t) || w(t) || X(t), ee = (t) => t.table !== void 0, te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2
|
+
__proto__: null,
|
|
3
|
+
enableInSubtable: $,
|
|
4
|
+
isCalc: j,
|
|
5
|
+
isCategory: J,
|
|
6
|
+
isCheckBox: g,
|
|
7
|
+
isCreatedTime: K,
|
|
8
|
+
isCreator: z,
|
|
9
|
+
isDate: f,
|
|
10
|
+
isDatetime: D,
|
|
11
|
+
isDropDown: b,
|
|
12
|
+
isFile: v,
|
|
13
|
+
isGroup: q,
|
|
14
|
+
isGroupSelect: A,
|
|
15
|
+
isInSubtable: ee,
|
|
16
|
+
isLink: M,
|
|
17
|
+
isLookup: X,
|
|
18
|
+
isModifier: W,
|
|
19
|
+
isMultiLineText: m,
|
|
20
|
+
isMultiSelect: C,
|
|
21
|
+
isNumber: L,
|
|
22
|
+
isOrganizationSelect: I,
|
|
23
|
+
isRadioButton: _,
|
|
24
|
+
isRecordNumber: H,
|
|
25
|
+
isReferenceTable: w,
|
|
26
|
+
isRichText: R,
|
|
27
|
+
isSingleLineText: S,
|
|
28
|
+
isStatus: Q,
|
|
29
|
+
isStatusAssignee: V,
|
|
30
|
+
isSubtable: Y,
|
|
31
|
+
isTime: N,
|
|
32
|
+
isUpdatedTime: Z,
|
|
33
|
+
isUserSelect: O
|
|
34
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
35
|
+
var ie = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, F = { exports: {} };
|
|
36
|
+
(function(t, a) {
|
|
37
|
+
(function(o, c) {
|
|
38
|
+
c(a);
|
|
39
|
+
})(ie, function(o) {
|
|
40
|
+
const c = Object.freeze(Object.defineProperty({ __proto__: null, isCalc: (e) => e.type === "CALC", isCategory: (e) => e.type === "CATEGORY", isCheckBox: (e) => e.type === "CHECK_BOX", isCreatedTime: (e) => e.type === "CREATED_TIME", isCreator: (e) => e.type === "CREATOR", isDate: (e) => e.type === "DATE", isDatetime: (e) => e.type === "DATETIME", isDropDown: (e) => e.type === "DROP_DOWN", isFile: (e) => e.type === "FILE", isGroup: (e) => e.type === "GROUP", isGroupSelect: (e) => e.type === "GROUP_SELECT", isLink: (e) => e.type === "LINK", isLookup: (e) => (e.type === "SINGLE_LINE_TEXT" || e.type === "NUMBER") && "lookup" in e, isModifier: (e) => e.type === "MODIFIER", isMultiLineText: (e) => e.type === "MULTI_LINE_TEXT", isMultiSelect: (e) => e.type === "MULTI_SELECT", isNumber: (e) => e.type === "NUMBER", isOrganizationSelect: (e) => e.type === "ORGANIZATION_SELECT", isRadioButton: (e) => e.type === "RADIO_BUTTON", isRecordNumber: (e) => e.type === "RECORD_NUMBER", isReferenceTable: (e) => e.type === "REFERENCE_TABLE", isRichText: (e) => e.type === "RICH_TEXT", isSingleLineText: (e) => e.type === "SINGLE_LINE_TEXT", isStatus: (e) => e.type === "STATUS", isStatusAssignee: (e) => e.type === "STATUS_ASSIGNEE", isSubtable: (e) => e.type === "SUBTABLE", isTime: (e) => e.type === "TIME", isUpdatedTime: (e) => e.type === "UPDATED_TIME", isUserSelect: (e) => e.type === "USER_SELECT" }, Symbol.toStringTag, { value: "Module" })), E = Object.freeze(Object.defineProperty({ __proto__: null, isCalc: (e) => e.type === "CALC", isCheckBox: (e) => e.type === "CHECK_BOX", isCreatedTime: (e) => e.type === "CREATED_TIME", isCreator: (e) => e.type === "CREATOR", isDate: (e) => e.type === "DATE", isDatetime: (e) => e.type === "DATETIME", isDropDown: (e) => e.type === "DROP_DOWN", isFile: (e) => e.type === "FILE", isGroup: (e) => e.type === "GROUP", isGroupSelect: (e) => e.type === "GROUP_SELECT", isHr: (e) => e.type === "HR", isLabel: (e) => e.type === "LABEL", isLink: (e) => e.type === "LINK", isModifier: (e) => e.type === "MODIFIER", isMultiLineText: (e) => e.type === "MULTI_LINE_TEXT", isMultiSelect: (e) => e.type === "MULTI_SELECT", isNumber: (e) => e.type === "NUMBER", isOrganizationSelect: (e) => e.type === "ORGANIZATION_SELECT", isRadioButon: (e) => e.type === "RADIO_BUTTON", isRecordNumber: (e) => e.type === "RECORD_NUMBER", isReferenceTable: (e) => e.type === "REFERENCE_TABLE", isRichText: (e) => e.type === "RICH_TEXT", isRow: (e) => e.type === "ROW", isSingleLineText: (e) => e.type === "SINGLE_LINE_TEXT", isSpacer: (e) => e.type === "SPACER", isSubtable: (e) => e.type === "SUBTABLE", isTime: (e) => e.type === "TIME", isUpdatedTime: (e) => e.type === "UPDATED_TIME", isUserSelect: (e) => e.type === "USER_SELECT" }, Symbol.toStringTag, { value: "Module" })), T = Object.freeze(Object.defineProperty({ __proto__: null, isCalc: (e) => e.type === "CALC", isCategory: (e) => e.type === "CATEGORY", isCheckBox: (e) => e.type === "CHECK_BOX", isCreatedTime: (e) => e.type === "CREATED_TIME", isCreator: (e) => e.type === "CREATOR", isDate: (e) => e.type === "DATE", isDatetime: (e) => e.type === "DATETIME", isDropDown: (e) => e.type === "DROP_DOWN", isFile: (e) => e.type === "FILE", isGroupSelect: (e) => e.type === "GROUP_SELECT", isLink: (e) => e.type === "LINK", isModifier: (e) => e.type === "MODIFIER", isMultiLineText: (e) => e.type === "MULTI_LINE_TEXT", isMultiSelect: (e) => e.type === "MULTI_SELECT", isNumber: (e) => e.type === "NUMBER", isOrganizationSelect: (e) => e.type === "ORGANIZATION_SELECT", isRadioButton: (e) => e.type === "RADIO_BUTTON", isRecordNumber: (e) => e.type === "RECORD_NUMBER", isRichText: (e) => e.type === "RICH_TEXT", isSingleLineText: (e) => e.type === "SINGLE_LINE_TEXT", isStatus: (e) => e.type === "STATUS", isStatusAssignee: (e) => e.type === "STATUS_ASSIGNEE", isSubtable: (e) => e.type === "SUBTABLE", isTime: (e) => e.type === "TIME", isUpdatedTime: (e) => e.type === "UPDATED_TIME", isUserSelect: (e) => e.type === "USER_SELECT" }, Symbol.toStringTag, { value: "Module" }));
|
|
41
|
+
o.guardFormField = c, o.guardFormLayout = E, o.guardRecord = T, Object.defineProperty(o, Symbol.toStringTag, { value: "Module" });
|
|
8
42
|
});
|
|
9
|
-
})(
|
|
10
|
-
var i =
|
|
11
|
-
const
|
|
12
|
-
var
|
|
13
|
-
const o = [],
|
|
14
|
-
T && T.enabled && o.push(T);
|
|
15
|
-
const E = Object.values(t).find(i.guardFormField.isStatusAssignee);
|
|
43
|
+
})(F, F.exports);
|
|
44
|
+
var i = F.exports;
|
|
45
|
+
const l = (t) => Object.values(t).sort((a, o) => Number(a.index) - Number(o.index)).map(({ label: a }) => a), oe = (t, a) => {
|
|
46
|
+
var P;
|
|
47
|
+
const o = [], c = [], E = Object.values(t).find(i.guardFormField.isStatus);
|
|
16
48
|
E && E.enabled && o.push(E);
|
|
49
|
+
const T = Object.values(t).find(i.guardFormField.isStatusAssignee);
|
|
50
|
+
T && T.enabled && o.push(T);
|
|
17
51
|
const e = Object.values(t).find(i.guardFormField.isCategory);
|
|
18
52
|
e && e.enabled && o.push(e);
|
|
19
|
-
for (const
|
|
20
|
-
if (i.guardFormLayout.isRow(
|
|
21
|
-
for (const r of
|
|
53
|
+
for (const p of a)
|
|
54
|
+
if (i.guardFormLayout.isRow(p))
|
|
55
|
+
for (const r of p.fields) {
|
|
22
56
|
if (i.guardFormLayout.isLabel(r) || i.guardFormLayout.isHr(r))
|
|
23
57
|
continue;
|
|
24
58
|
if (i.guardFormLayout.isSpacer(r)) {
|
|
25
|
-
|
|
59
|
+
c.push(r);
|
|
26
60
|
continue;
|
|
27
61
|
}
|
|
28
62
|
const n = t[r.code];
|
|
29
63
|
if (!i.guardFormField.isSubtable(n) && !i.guardFormField.isGroup(n)) {
|
|
30
64
|
if (i.guardFormField.isCheckBox(n) || i.guardFormField.isDropDown(n) || i.guardFormField.isMultiSelect(n) || i.guardFormField.isRadioButton(n)) {
|
|
31
|
-
const s =
|
|
65
|
+
const s = l(n.options);
|
|
32
66
|
o.push({ ...n, sortedOptions: s });
|
|
33
67
|
continue;
|
|
34
68
|
}
|
|
35
69
|
o.push(n);
|
|
36
70
|
}
|
|
37
71
|
}
|
|
38
|
-
else if (i.guardFormLayout.isSubtable(
|
|
39
|
-
const r =
|
|
72
|
+
else if (i.guardFormLayout.isSubtable(p)) {
|
|
73
|
+
const r = p.code, n = t[r];
|
|
40
74
|
if (!i.guardFormField.isSubtable(n))
|
|
41
75
|
continue;
|
|
42
76
|
const s = {};
|
|
43
|
-
for (const { code: y } of
|
|
44
|
-
const
|
|
45
|
-
if (i.guardFormField.isCheckBox(
|
|
46
|
-
const u =
|
|
47
|
-
s[
|
|
77
|
+
for (const { code: y } of p.fields) {
|
|
78
|
+
const d = n.fields[y];
|
|
79
|
+
if (i.guardFormField.isCheckBox(d) || i.guardFormField.isDropDown(d) || i.guardFormField.isMultiSelect(d) || i.guardFormField.isRadioButton(d)) {
|
|
80
|
+
const u = l(d.options);
|
|
81
|
+
s[d.code] = { ...d, table: r, sortedOptions: u }, o.push({ ...d, table: r, sortedOptions: u });
|
|
48
82
|
continue;
|
|
49
83
|
}
|
|
50
|
-
s[
|
|
84
|
+
s[d.code] = { ...d, table: r }, o.push({ ...d, table: r });
|
|
51
85
|
}
|
|
52
86
|
o.push({ ...n, fields: s });
|
|
53
|
-
} else if (i.guardFormLayout.isGroup(
|
|
54
|
-
const r =
|
|
87
|
+
} else if (i.guardFormLayout.isGroup(p)) {
|
|
88
|
+
const r = p.code, n = t[r];
|
|
55
89
|
if (!i.guardFormField.isGroup(n))
|
|
56
90
|
continue;
|
|
57
91
|
const s = {};
|
|
58
|
-
for (const y of
|
|
59
|
-
for (const
|
|
60
|
-
if (i.guardFormLayout.isLabel(
|
|
92
|
+
for (const y of p.layout)
|
|
93
|
+
for (const d of y.fields) {
|
|
94
|
+
if (i.guardFormLayout.isLabel(d) || i.guardFormLayout.isHr(d))
|
|
61
95
|
continue;
|
|
62
|
-
if (i.guardFormLayout.isSpacer(
|
|
63
|
-
|
|
96
|
+
if (i.guardFormLayout.isSpacer(d)) {
|
|
97
|
+
c.push(d);
|
|
64
98
|
continue;
|
|
65
99
|
}
|
|
66
|
-
const u = t[
|
|
100
|
+
const u = t[d.code];
|
|
67
101
|
if (!i.guardFormField.isCategory(u) && !i.guardFormField.isStatus(u) && !i.guardFormField.isStatusAssignee(u) && !i.guardFormField.isSubtable(u) && !i.guardFormField.isGroup(u)) {
|
|
68
102
|
if (i.guardFormField.isCheckBox(u) || i.guardFormField.isDropDown(u) || i.guardFormField.isMultiSelect(u) || i.guardFormField.isRadioButton(u)) {
|
|
69
|
-
const
|
|
70
|
-
s[u.code] = { ...u, group: r, sortedOptions:
|
|
103
|
+
const k = l(u.options);
|
|
104
|
+
s[u.code] = { ...u, group: r, sortedOptions: k }, o.push({ ...u, group: r, sortedOptions: k });
|
|
71
105
|
continue;
|
|
72
106
|
}
|
|
73
107
|
s[u.code] = { ...u, group: r }, o.push({ ...u, group: r });
|
|
@@ -75,65 +109,34 @@ const F = (t) => Object.values(t).sort((c, o) => Number(c.index) - Number(o.inde
|
|
|
75
109
|
}
|
|
76
110
|
o.push({ ...n, fields: s });
|
|
77
111
|
}
|
|
78
|
-
for (const
|
|
79
|
-
if (i.guardFormField.isLookup(
|
|
80
|
-
if (
|
|
112
|
+
for (const p of Object.values(o))
|
|
113
|
+
if (i.guardFormField.isLookup(p)) {
|
|
114
|
+
if (p.lookup === null)
|
|
81
115
|
continue;
|
|
82
|
-
for (const r of
|
|
83
|
-
const n = (
|
|
84
|
-
(s) =>
|
|
85
|
-
)) == null ? void 0 :
|
|
116
|
+
for (const r of p.lookup.fieldMappings) {
|
|
117
|
+
const n = (P = o.filter(
|
|
118
|
+
(s) => S(s) || L(s) || m(s) || R(s) || M(s) || g(s) || _(s) || b(s) || C(s) || f(s) || N(s) || D(s) || O(s) || I(s) || A(s)
|
|
119
|
+
)) == null ? void 0 : P.find((s) => s.code === r.field);
|
|
86
120
|
n && (n.isLookupCopy = !0);
|
|
87
121
|
}
|
|
88
122
|
}
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
return
|
|
99
|
-
},
|
|
100
|
-
const [{ properties:
|
|
101
|
-
t.app.getFormFields({ app:
|
|
102
|
-
t.app.getFormLayout({ app:
|
|
123
|
+
const U = Object.values(t).find(i.guardFormField.isRecordNumber);
|
|
124
|
+
U && (o.some(i.guardFormField.isRecordNumber) || o.push(U));
|
|
125
|
+
const B = Object.values(t).find(i.guardFormField.isCreator);
|
|
126
|
+
B && (o.some(i.guardFormField.isCreator) || o.push(B));
|
|
127
|
+
const G = Object.values(t).find(i.guardFormField.isCreatedTime);
|
|
128
|
+
G && (o.some(i.guardFormField.isCreatedTime) || o.push(G));
|
|
129
|
+
const h = Object.values(t).find(i.guardFormField.isModifier);
|
|
130
|
+
h && (o.some(i.guardFormField.isModifier) || o.push(h));
|
|
131
|
+
const x = Object.values(t).find(i.guardFormField.isUpdatedTime);
|
|
132
|
+
return x && (o.some(i.guardFormField.isUpdatedTime) || o.push(x)), { fields: o, spacers: c };
|
|
133
|
+
}, se = async ({ client: t, app: a, lang: o, preview: c }) => {
|
|
134
|
+
const [{ properties: E }, { layout: T }] = await Promise.all([
|
|
135
|
+
t.app.getFormFields({ app: a, lang: o, preview: c }),
|
|
136
|
+
t.app.getFormLayout({ app: a, preview: c })
|
|
103
137
|
]);
|
|
104
|
-
return
|
|
105
|
-
},
|
|
106
|
-
__proto__: null,
|
|
107
|
-
isCalc: k,
|
|
108
|
-
isCategory: ee,
|
|
109
|
-
isCheckBox: P,
|
|
110
|
-
isCreatedTime: N,
|
|
111
|
-
isCreator: D,
|
|
112
|
-
isDate: K,
|
|
113
|
-
isDatetime: Z,
|
|
114
|
-
isDropDown: v,
|
|
115
|
-
isFile: q,
|
|
116
|
-
isGroup: V,
|
|
117
|
-
isGroupSelect: z,
|
|
118
|
-
isLink: Y,
|
|
119
|
-
isLookup: J,
|
|
120
|
-
isModifier: M,
|
|
121
|
-
isMultiLineText: G,
|
|
122
|
-
isMultiSelect: X,
|
|
123
|
-
isNumber: x,
|
|
124
|
-
isOrganizationSelect: H,
|
|
125
|
-
isRadioButton: j,
|
|
126
|
-
isRecordNumber: A,
|
|
127
|
-
isReferenceTable: $,
|
|
128
|
-
isRichText: h,
|
|
129
|
-
isSingleLineText: B,
|
|
130
|
-
isStatus: te,
|
|
131
|
-
isStatusAssignee: ie,
|
|
132
|
-
isSubtable: Q,
|
|
133
|
-
isTime: W,
|
|
134
|
-
isUpdatedTime: U,
|
|
135
|
-
isUserSelect: w
|
|
136
|
-
}, Symbol.toStringTag, { value: "Module" })), a = { get: b, ...oe };
|
|
138
|
+
return oe(E, T);
|
|
139
|
+
}, re = { get: se, ...te };
|
|
137
140
|
export {
|
|
138
|
-
|
|
141
|
+
re as kintonePrettyFields
|
|
139
142
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(E,
|
|
1
|
+
(function(E,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(E=typeof globalThis<"u"?globalThis:E||self,l(E.KintonePrettyFields={}))})(this,function(E){"use strict";const l=t=>t.type==="RECORD_NUMBER",z=t=>t.type==="CREATOR",W=t=>t.type==="CREATED_TIME",Z=t=>t.type==="MODIFIER",Y=t=>t.type==="UPDATED_TIME",F=t=>t.type==="SINGLE_LINE_TEXT",S=t=>t.type==="MULTI_LINE_TEXT",m=t=>t.type==="RICH_TEXT",R=t=>t.type==="NUMBER",G=t=>t.type==="CALC",g=t=>t.type==="CHECK_BOX",L=t=>t.type==="RADIO_BUTTON",_=t=>t.type==="MULTI_SELECT",b=t=>t.type==="DROP_DOWN",C=t=>t.type==="USER_SELECT",I=t=>t.type==="ORGANIZATION_SELECT",O=t=>t.type==="GROUP_SELECT",f=t=>t.type==="DATE",A=t=>t.type==="TIME",N=t=>t.type==="DATETIME",M=t=>t.type==="LINK",h=t=>t.type==="FILE",x=t=>(t.type==="SINGLE_LINE_TEXT"||t.type==="NUMBER")&&"lookup"in t,q=t=>t.type==="SUBTABLE",J=t=>t.type==="GROUP",P=t=>t.type==="REFERENCE_TABLE",Q=Object.freeze(Object.defineProperty({__proto__:null,enableInSubtable:t=>F(t)||R(t)||G(t)||S(t)||m(t)||M(t)||g(t)||L(t)||b(t)||_(t)||h(t)||f(t)||A(t)||N(t)||C(t)||I(t)||O(t)||P(t)||x(t),isCalc:G,isCategory:t=>t.type==="CATEGORY",isCheckBox:g,isCreatedTime:W,isCreator:z,isDate:f,isDatetime:N,isDropDown:b,isFile:h,isGroup:J,isGroupSelect:O,isInSubtable:t=>t.table!==void 0,isLink:M,isLookup:x,isModifier:Z,isMultiLineText:S,isMultiSelect:_,isNumber:R,isOrganizationSelect:I,isRadioButton:L,isRecordNumber:l,isReferenceTable:P,isRichText:m,isSingleLineText:F,isStatus:t=>t.type==="STATUS",isStatusAssignee:t=>t.type==="STATUS_ASSIGNEE",isSubtable:q,isTime:A,isUpdatedTime:Y,isUserSelect:C},Symbol.toStringTag,{value:"Module"}));var V=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},D={exports:{}};(function(t,a){(function(o,c){c(a)})(V,function(o){const c=Object.freeze(Object.defineProperty({__proto__:null,isCalc:e=>e.type==="CALC",isCategory:e=>e.type==="CATEGORY",isCheckBox:e=>e.type==="CHECK_BOX",isCreatedTime:e=>e.type==="CREATED_TIME",isCreator:e=>e.type==="CREATOR",isDate:e=>e.type==="DATE",isDatetime:e=>e.type==="DATETIME",isDropDown:e=>e.type==="DROP_DOWN",isFile:e=>e.type==="FILE",isGroup:e=>e.type==="GROUP",isGroupSelect:e=>e.type==="GROUP_SELECT",isLink:e=>e.type==="LINK",isLookup:e=>(e.type==="SINGLE_LINE_TEXT"||e.type==="NUMBER")&&"lookup"in e,isModifier:e=>e.type==="MODIFIER",isMultiLineText:e=>e.type==="MULTI_LINE_TEXT",isMultiSelect:e=>e.type==="MULTI_SELECT",isNumber:e=>e.type==="NUMBER",isOrganizationSelect:e=>e.type==="ORGANIZATION_SELECT",isRadioButton:e=>e.type==="RADIO_BUTTON",isRecordNumber:e=>e.type==="RECORD_NUMBER",isReferenceTable:e=>e.type==="REFERENCE_TABLE",isRichText:e=>e.type==="RICH_TEXT",isSingleLineText:e=>e.type==="SINGLE_LINE_TEXT",isStatus:e=>e.type==="STATUS",isStatusAssignee:e=>e.type==="STATUS_ASSIGNEE",isSubtable:e=>e.type==="SUBTABLE",isTime:e=>e.type==="TIME",isUpdatedTime:e=>e.type==="UPDATED_TIME",isUserSelect:e=>e.type==="USER_SELECT"},Symbol.toStringTag,{value:"Module"})),T=Object.freeze(Object.defineProperty({__proto__:null,isCalc:e=>e.type==="CALC",isCheckBox:e=>e.type==="CHECK_BOX",isCreatedTime:e=>e.type==="CREATED_TIME",isCreator:e=>e.type==="CREATOR",isDate:e=>e.type==="DATE",isDatetime:e=>e.type==="DATETIME",isDropDown:e=>e.type==="DROP_DOWN",isFile:e=>e.type==="FILE",isGroup:e=>e.type==="GROUP",isGroupSelect:e=>e.type==="GROUP_SELECT",isHr:e=>e.type==="HR",isLabel:e=>e.type==="LABEL",isLink:e=>e.type==="LINK",isModifier:e=>e.type==="MODIFIER",isMultiLineText:e=>e.type==="MULTI_LINE_TEXT",isMultiSelect:e=>e.type==="MULTI_SELECT",isNumber:e=>e.type==="NUMBER",isOrganizationSelect:e=>e.type==="ORGANIZATION_SELECT",isRadioButon:e=>e.type==="RADIO_BUTTON",isRecordNumber:e=>e.type==="RECORD_NUMBER",isReferenceTable:e=>e.type==="REFERENCE_TABLE",isRichText:e=>e.type==="RICH_TEXT",isRow:e=>e.type==="ROW",isSingleLineText:e=>e.type==="SINGLE_LINE_TEXT",isSpacer:e=>e.type==="SPACER",isSubtable:e=>e.type==="SUBTABLE",isTime:e=>e.type==="TIME",isUpdatedTime:e=>e.type==="UPDATED_TIME",isUserSelect:e=>e.type==="USER_SELECT"},Symbol.toStringTag,{value:"Module"})),y=Object.freeze(Object.defineProperty({__proto__:null,isCalc:e=>e.type==="CALC",isCategory:e=>e.type==="CATEGORY",isCheckBox:e=>e.type==="CHECK_BOX",isCreatedTime:e=>e.type==="CREATED_TIME",isCreator:e=>e.type==="CREATOR",isDate:e=>e.type==="DATE",isDatetime:e=>e.type==="DATETIME",isDropDown:e=>e.type==="DROP_DOWN",isFile:e=>e.type==="FILE",isGroupSelect:e=>e.type==="GROUP_SELECT",isLink:e=>e.type==="LINK",isModifier:e=>e.type==="MODIFIER",isMultiLineText:e=>e.type==="MULTI_LINE_TEXT",isMultiSelect:e=>e.type==="MULTI_SELECT",isNumber:e=>e.type==="NUMBER",isOrganizationSelect:e=>e.type==="ORGANIZATION_SELECT",isRadioButton:e=>e.type==="RADIO_BUTTON",isRecordNumber:e=>e.type==="RECORD_NUMBER",isRichText:e=>e.type==="RICH_TEXT",isSingleLineText:e=>e.type==="SINGLE_LINE_TEXT",isStatus:e=>e.type==="STATUS",isStatusAssignee:e=>e.type==="STATUS_ASSIGNEE",isSubtable:e=>e.type==="SUBTABLE",isTime:e=>e.type==="TIME",isUpdatedTime:e=>e.type==="UPDATED_TIME",isUserSelect:e=>e.type==="USER_SELECT"},Symbol.toStringTag,{value:"Module"}));o.guardFormField=c,o.guardFormLayout=T,o.guardRecord=y,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})})})(D,D.exports);var i=D.exports;const U=t=>Object.values(t).sort((a,o)=>Number(a.index)-Number(o.index)).map(({label:a})=>a),$=(t,a)=>{var H;const o=[],c=[],T=Object.values(t).find(i.guardFormField.isStatus);T&&T.enabled&&o.push(T);const y=Object.values(t).find(i.guardFormField.isStatusAssignee);y&&y.enabled&&o.push(y);const e=Object.values(t).find(i.guardFormField.isCategory);e&&e.enabled&&o.push(e);for(const p of a)if(i.guardFormLayout.isRow(p))for(const r of p.fields){if(i.guardFormLayout.isLabel(r)||i.guardFormLayout.isHr(r))continue;if(i.guardFormLayout.isSpacer(r)){c.push(r);continue}const n=t[r.code];if(!i.guardFormField.isSubtable(n)&&!i.guardFormField.isGroup(n)){if(i.guardFormField.isCheckBox(n)||i.guardFormField.isDropDown(n)||i.guardFormField.isMultiSelect(n)||i.guardFormField.isRadioButton(n)){const s=U(n.options);o.push({...n,sortedOptions:s});continue}o.push(n)}}else if(i.guardFormLayout.isSubtable(p)){const r=p.code,n=t[r];if(!i.guardFormField.isSubtable(n))continue;const s={};for(const{code:B}of p.fields){const d=n.fields[B];if(i.guardFormField.isCheckBox(d)||i.guardFormField.isDropDown(d)||i.guardFormField.isMultiSelect(d)||i.guardFormField.isRadioButton(d)){const u=U(d.options);s[d.code]={...d,table:r,sortedOptions:u},o.push({...d,table:r,sortedOptions:u});continue}s[d.code]={...d,table:r},o.push({...d,table:r})}o.push({...n,fields:s})}else if(i.guardFormLayout.isGroup(p)){const r=p.code,n=t[r];if(!i.guardFormField.isGroup(n))continue;const s={};for(const B of p.layout)for(const d of B.fields){if(i.guardFormLayout.isLabel(d)||i.guardFormLayout.isHr(d))continue;if(i.guardFormLayout.isSpacer(d)){c.push(d);continue}const u=t[d.code];if(!i.guardFormField.isCategory(u)&&!i.guardFormField.isStatus(u)&&!i.guardFormField.isStatusAssignee(u)&&!i.guardFormField.isSubtable(u)&&!i.guardFormField.isGroup(u)){if(i.guardFormField.isCheckBox(u)||i.guardFormField.isDropDown(u)||i.guardFormField.isMultiSelect(u)||i.guardFormField.isRadioButton(u)){const K=U(u.options);s[u.code]={...u,group:r,sortedOptions:K},o.push({...u,group:r,sortedOptions:K});continue}s[u.code]={...u,group:r},o.push({...u,group:r})}}o.push({...n,fields:s})}for(const p of Object.values(o))if(i.guardFormField.isLookup(p)){if(p.lookup===null)continue;for(const r of p.lookup.fieldMappings){const n=(H=o.filter(s=>F(s)||R(s)||S(s)||m(s)||M(s)||g(s)||L(s)||b(s)||_(s)||f(s)||A(s)||N(s)||C(s)||I(s)||O(s)))==null?void 0:H.find(s=>s.code===r.field);n&&(n.isLookupCopy=!0)}}const k=Object.values(t).find(i.guardFormField.isRecordNumber);k&&(o.some(i.guardFormField.isRecordNumber)||o.push(k));const j=Object.values(t).find(i.guardFormField.isCreator);j&&(o.some(i.guardFormField.isCreator)||o.push(j));const v=Object.values(t).find(i.guardFormField.isCreatedTime);v&&(o.some(i.guardFormField.isCreatedTime)||o.push(v));const X=Object.values(t).find(i.guardFormField.isModifier);X&&(o.some(i.guardFormField.isModifier)||o.push(X));const w=Object.values(t).find(i.guardFormField.isUpdatedTime);return w&&(o.some(i.guardFormField.isUpdatedTime)||o.push(w)),{fields:o,spacers:c}},ee={get:async({client:t,app:a,lang:o,preview:c})=>{const[{properties:T},{layout:y}]=await Promise.all([t.app.getFormFields({app:a,lang:o,preview:c}),t.app.getFormLayout({app:a,preview:c})]);return $(T,y)},...Q};E.kintonePrettyFields=ee,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|