lkb-fields-custom-views 1.0.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.
Files changed (30) hide show
  1. package/dictionary-values-editor/dist/lkb-fields-custom-views-dictionary-values-editor.cjs.d.ts +2 -0
  2. package/dictionary-values-editor/dist/lkb-fields-custom-views-dictionary-values-editor.cjs.js +232 -0
  3. package/dictionary-values-editor/dist/lkb-fields-custom-views-dictionary-values-editor.esm.js +226 -0
  4. package/dictionary-values-editor/package.json +4 -0
  5. package/dist/declarations/src/dictionary-values-editor/index.d.ts +6 -0
  6. package/dist/declarations/src/dictionary-values-editor/index.d.ts.map +1 -0
  7. package/dist/declarations/src/index.d.ts +1 -0
  8. package/dist/declarations/src/index.d.ts.map +1 -0
  9. package/dist/declarations/src/lng-lat-selector/index.d.ts +4 -0
  10. package/dist/declarations/src/lng-lat-selector/index.d.ts.map +1 -0
  11. package/dist/declarations/src/status-on-off-field/index.d.ts +3 -0
  12. package/dist/declarations/src/status-on-off-field/index.d.ts.map +1 -0
  13. package/dist/declarations/src/tree-node-order-field/index.d.ts +3 -0
  14. package/dist/declarations/src/tree-node-order-field/index.d.ts.map +1 -0
  15. package/dist/lkb-fields-custom-views.cjs.d.ts +2 -0
  16. package/dist/lkb-fields-custom-views.cjs.js +2 -0
  17. package/dist/lkb-fields-custom-views.esm.js +1 -0
  18. package/lng-lat-selector/dist/lkb-fields-custom-views-lng-lat-selector.cjs.d.ts +2 -0
  19. package/lng-lat-selector/dist/lkb-fields-custom-views-lng-lat-selector.cjs.js +62 -0
  20. package/lng-lat-selector/dist/lkb-fields-custom-views-lng-lat-selector.esm.js +58 -0
  21. package/lng-lat-selector/package.json +4 -0
  22. package/package.json +59 -0
  23. package/status-on-off-field/dist/lkb-fields-custom-views-status-on-off-field.cjs.d.ts +2 -0
  24. package/status-on-off-field/dist/lkb-fields-custom-views-status-on-off-field.cjs.js +23 -0
  25. package/status-on-off-field/dist/lkb-fields-custom-views-status-on-off-field.esm.js +19 -0
  26. package/status-on-off-field/package.json +4 -0
  27. package/tree-node-order-field/dist/lkb-fields-custom-views-tree-node-order-field.cjs.d.ts +2 -0
  28. package/tree-node-order-field/dist/lkb-fields-custom-views-tree-node-order-field.cjs.js +27 -0
  29. package/tree-node-order-field/dist/lkb-fields-custom-views-tree-node-order-field.esm.js +23 -0
  30. package/tree-node-order-field/package.json +4 -0
@@ -0,0 +1,2 @@
1
+ export * from "../../dist/declarations/src/dictionary-values-editor/index.js";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1jdXN0b20tdmlld3MtZGljdGlvbmFyeS12YWx1ZXMtZWRpdG9yLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vZGlzdC9kZWNsYXJhdGlvbnMvc3JjL2RpY3Rpb25hcnktdmFsdWVzLWVkaXRvci9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
@@ -0,0 +1,232 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var react = require('react');
6
+ var icon = require('@keystar/ui/icon');
7
+ var button = require('@keystar/ui/button');
8
+ var typography = require('@keystar/ui/typography');
9
+ var textField = require('@keystar/ui/text-field');
10
+ var layout = require('@keystar/ui/layout');
11
+ var style = require('@keystar/ui/style');
12
+ var plusIcon = require('@keystar/ui/icon/icons/plusIcon');
13
+ var jsxRuntime = require('react/jsx-runtime');
14
+ var core = require('@keystar/ui/core');
15
+ var field = require('@keystar/ui/field');
16
+ var views = require('lkb-core/fields/types/json/views');
17
+
18
+ const formatDate = date => {
19
+ return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
20
+ };
21
+ function ValuesEditor(props) {
22
+ const initList = props.value || props.defaultValue || [];
23
+ const [list, setList] = react.useState(initList);
24
+ const submitJson = list => {
25
+ var _props$onChange;
26
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, list);
27
+ };
28
+
29
+ //------------------------------------
30
+
31
+ const handleAdd = () => {
32
+ const newList = [...list];
33
+ newList.push({
34
+ id: Date.now(),
35
+ label: '',
36
+ value: '',
37
+ desc: '',
38
+ status: 1,
39
+ createdAt: formatDate(new Date())
40
+ });
41
+ setList(newList);
42
+ submitJson(newList);
43
+ };
44
+ const handleRemove = id => {
45
+ const newList = [...list];
46
+ const index = newList.findIndex(item => item.id === id);
47
+ newList.splice(index, 1);
48
+ setList(newList);
49
+ submitJson(newList);
50
+ };
51
+ const handleSave = (id, field, value) => {
52
+ const newList = [...list];
53
+ const item = newList.find(item => item.id === id);
54
+ const index = newList.findIndex(item => item.id === id);
55
+ if (!item) return;
56
+ newList.splice(index, 1, {
57
+ ...item,
58
+ [field]: value
59
+ });
60
+ setList(newList);
61
+ submitJson(newList);
62
+ };
63
+ const textFieldStyle = style.css({
64
+ input: {
65
+ '&:hover, &:focus': {
66
+ backgroundColor: style.tokenSchema.color.background.canvas,
67
+ border: `1px solid ${style.tokenSchema.color.border.neutral}`
68
+ }
69
+ },
70
+ '> div > div': {
71
+ display: 'none'
72
+ }
73
+ });
74
+ return /*#__PURE__*/jsxRuntime.jsxs(layout.VStack, {
75
+ gap: "medium",
76
+ children: [/*#__PURE__*/jsxRuntime.jsxs(layout.VStack, {
77
+ UNSAFE_className: style.css({
78
+ backgroundColor: style.tokenSchema.color.background.canvas,
79
+ border: `1px solid ${style.tokenSchema.color.border.neutral}`,
80
+ borderRadius: style.tokenSchema.size.radius.regular,
81
+ display: list !== null && list !== void 0 && list.length ? 'block' : 'none'
82
+ }),
83
+ children: [/*#__PURE__*/jsxRuntime.jsxs(layout.HStack, {
84
+ gap: "medium",
85
+ UNSAFE_className: "py-3 pl-2 border-b",
86
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
87
+ className: "flex-1 pl-3",
88
+ children: /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
89
+ children: "\u6807\u7B7E"
90
+ })
91
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
92
+ className: "flex-1 pl-3",
93
+ children: /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
94
+ children: "\u503C"
95
+ })
96
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
97
+ className: "flex-1 pl-3",
98
+ children: /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
99
+ children: "\u5907\u6CE8"
100
+ })
101
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
102
+ className: "w-24 text-center",
103
+ children: /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
104
+ children: "\u72B6\u6001"
105
+ })
106
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
107
+ className: "w-24 text-center",
108
+ children: /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
109
+ children: "\u521B\u5EFA\u65F6\u95F4"
110
+ })
111
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
112
+ className: "w-14 text-center",
113
+ children: /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
114
+ children: "\xA0"
115
+ })
116
+ })]
117
+ }), /*#__PURE__*/jsxRuntime.jsx(layout.VStack, {
118
+ gap: "small",
119
+ UNSAFE_className: "py-2 pl-2",
120
+ children: list.map(item => /*#__PURE__*/jsxRuntime.jsxs(layout.HStack, {
121
+ gap: "medium",
122
+ alignItems: "center",
123
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
124
+ className: "flex-1",
125
+ children: /*#__PURE__*/jsxRuntime.jsx(textField.TextField, {
126
+ defaultValue: item.label,
127
+ placeholder: "\u8BF7\u8F93\u5165\u6807\u7B7E",
128
+ onChange: value => handleSave(item.id, 'label', value),
129
+ UNSAFE_className: textFieldStyle
130
+ })
131
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
132
+ className: "flex-1",
133
+ children: /*#__PURE__*/jsxRuntime.jsx(textField.TextField, {
134
+ defaultValue: item.value,
135
+ placeholder: "\u8BF7\u8F93\u5165\u503C",
136
+ onChange: value => handleSave(item.id, 'value', value),
137
+ UNSAFE_className: textFieldStyle
138
+ })
139
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
140
+ className: "flex-1",
141
+ children: /*#__PURE__*/jsxRuntime.jsx(textField.TextField, {
142
+ defaultValue: item.desc,
143
+ placeholder: "\u8BF7\u8F93\u5165\u5907\u6CE8",
144
+ onChange: value => handleSave(item.id, 'desc', value),
145
+ UNSAFE_className: textFieldStyle
146
+ })
147
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
148
+ className: "w-24 text-center",
149
+ children: /*#__PURE__*/jsxRuntime.jsx("a", {
150
+ className: "cursor-pointer",
151
+ onClick: () => handleSave(item.id, 'status', item.status === 1 ? 0 : 1),
152
+ children: /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
153
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
154
+ className: item.status === 1 ? '' : 'text-red-300',
155
+ children: item.status === 1 ? '启用' : '停用'
156
+ })
157
+ })
158
+ })
159
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
160
+ className: "w-24 text-center",
161
+ children: /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
162
+ children: item.createdAt
163
+ })
164
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
165
+ className: "w-14 text-center",
166
+ children: /*#__PURE__*/jsxRuntime.jsx("a", {
167
+ className: "cursor-pointer",
168
+ onClick: () => handleRemove(item.id),
169
+ children: /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
170
+ children: "\u5220\u9664"
171
+ })
172
+ })
173
+ })]
174
+ }, item.id))
175
+ })]
176
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
177
+ children: /*#__PURE__*/jsxRuntime.jsxs(button.Button, {
178
+ onClick: handleAdd,
179
+ children: [/*#__PURE__*/jsxRuntime.jsx(icon.Icon, {
180
+ src: plusIcon.plusIcon
181
+ }), /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
182
+ children: "\u6DFB\u52A0\u5B57\u5178\u503C"
183
+ })]
184
+ })
185
+ })]
186
+ });
187
+ }
188
+
189
+ const Field = props => {
190
+ const {
191
+ field: field$1,
192
+ forceValidation,
193
+ onChange,
194
+ value
195
+ } = props;
196
+ const errorMessage = forceValidation ? 'Invalid JSON' : undefined;
197
+ let initValue = [];
198
+ if (value) {
199
+ try {
200
+ initValue = JSON.parse(value);
201
+ } catch (e) {
202
+ initValue = [];
203
+ }
204
+ }
205
+ return /*#__PURE__*/jsxRuntime.jsx(field.Field, {
206
+ label: field$1.label,
207
+ description: field$1.description,
208
+ errorMessage: errorMessage,
209
+ children: inputProps => {
210
+ return /*#__PURE__*/jsxRuntime.jsx(core.KeystarProvider, {
211
+ children: /*#__PURE__*/jsxRuntime.jsx(ValuesEditor, {
212
+ ...inputProps,
213
+ defaultValue: initValue,
214
+ onChange: json => onChange === null || onChange === void 0 ? void 0 : onChange(JSON.stringify(json))
215
+ })
216
+ });
217
+ }
218
+ });
219
+ };
220
+ const Cell = ({
221
+ value
222
+ }) => {
223
+ var _value$length;
224
+ return value ? /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
225
+ children: (_value$length = value === null || value === void 0 ? void 0 : value.length) !== null && _value$length !== void 0 ? _value$length : 0
226
+ }) : null;
227
+ };
228
+ const controller = views.controller;
229
+
230
+ exports.Cell = Cell;
231
+ exports.Field = Field;
232
+ exports.controller = controller;
@@ -0,0 +1,226 @@
1
+ import { useState } from 'react';
2
+ import { Icon } from '@keystar/ui/icon';
3
+ import { Button } from '@keystar/ui/button';
4
+ import { Text } from '@keystar/ui/typography';
5
+ import { TextField } from '@keystar/ui/text-field';
6
+ import { VStack, HStack } from '@keystar/ui/layout';
7
+ import { css, tokenSchema } from '@keystar/ui/style';
8
+ import { plusIcon } from '@keystar/ui/icon/icons/plusIcon';
9
+ import { jsxs, jsx } from 'react/jsx-runtime';
10
+ import { KeystarProvider } from '@keystar/ui/core';
11
+ import { Field as Field$1 } from '@keystar/ui/field';
12
+ import { controller as controller$1 } from 'lkb-core/fields/types/json/views';
13
+
14
+ const formatDate = date => {
15
+ return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
16
+ };
17
+ function ValuesEditor(props) {
18
+ const initList = props.value || props.defaultValue || [];
19
+ const [list, setList] = useState(initList);
20
+ const submitJson = list => {
21
+ var _props$onChange;
22
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, list);
23
+ };
24
+
25
+ //------------------------------------
26
+
27
+ const handleAdd = () => {
28
+ const newList = [...list];
29
+ newList.push({
30
+ id: Date.now(),
31
+ label: '',
32
+ value: '',
33
+ desc: '',
34
+ status: 1,
35
+ createdAt: formatDate(new Date())
36
+ });
37
+ setList(newList);
38
+ submitJson(newList);
39
+ };
40
+ const handleRemove = id => {
41
+ const newList = [...list];
42
+ const index = newList.findIndex(item => item.id === id);
43
+ newList.splice(index, 1);
44
+ setList(newList);
45
+ submitJson(newList);
46
+ };
47
+ const handleSave = (id, field, value) => {
48
+ const newList = [...list];
49
+ const item = newList.find(item => item.id === id);
50
+ const index = newList.findIndex(item => item.id === id);
51
+ if (!item) return;
52
+ newList.splice(index, 1, {
53
+ ...item,
54
+ [field]: value
55
+ });
56
+ setList(newList);
57
+ submitJson(newList);
58
+ };
59
+ const textFieldStyle = css({
60
+ input: {
61
+ '&:hover, &:focus': {
62
+ backgroundColor: tokenSchema.color.background.canvas,
63
+ border: `1px solid ${tokenSchema.color.border.neutral}`
64
+ }
65
+ },
66
+ '> div > div': {
67
+ display: 'none'
68
+ }
69
+ });
70
+ return /*#__PURE__*/jsxs(VStack, {
71
+ gap: "medium",
72
+ children: [/*#__PURE__*/jsxs(VStack, {
73
+ UNSAFE_className: css({
74
+ backgroundColor: tokenSchema.color.background.canvas,
75
+ border: `1px solid ${tokenSchema.color.border.neutral}`,
76
+ borderRadius: tokenSchema.size.radius.regular,
77
+ display: list !== null && list !== void 0 && list.length ? 'block' : 'none'
78
+ }),
79
+ children: [/*#__PURE__*/jsxs(HStack, {
80
+ gap: "medium",
81
+ UNSAFE_className: "py-3 pl-2 border-b",
82
+ children: [/*#__PURE__*/jsx("div", {
83
+ className: "flex-1 pl-3",
84
+ children: /*#__PURE__*/jsx(Text, {
85
+ children: "\u6807\u7B7E"
86
+ })
87
+ }), /*#__PURE__*/jsx("div", {
88
+ className: "flex-1 pl-3",
89
+ children: /*#__PURE__*/jsx(Text, {
90
+ children: "\u503C"
91
+ })
92
+ }), /*#__PURE__*/jsx("div", {
93
+ className: "flex-1 pl-3",
94
+ children: /*#__PURE__*/jsx(Text, {
95
+ children: "\u5907\u6CE8"
96
+ })
97
+ }), /*#__PURE__*/jsx("div", {
98
+ className: "w-24 text-center",
99
+ children: /*#__PURE__*/jsx(Text, {
100
+ children: "\u72B6\u6001"
101
+ })
102
+ }), /*#__PURE__*/jsx("div", {
103
+ className: "w-24 text-center",
104
+ children: /*#__PURE__*/jsx(Text, {
105
+ children: "\u521B\u5EFA\u65F6\u95F4"
106
+ })
107
+ }), /*#__PURE__*/jsx("div", {
108
+ className: "w-14 text-center",
109
+ children: /*#__PURE__*/jsx(Text, {
110
+ children: "\xA0"
111
+ })
112
+ })]
113
+ }), /*#__PURE__*/jsx(VStack, {
114
+ gap: "small",
115
+ UNSAFE_className: "py-2 pl-2",
116
+ children: list.map(item => /*#__PURE__*/jsxs(HStack, {
117
+ gap: "medium",
118
+ alignItems: "center",
119
+ children: [/*#__PURE__*/jsx("div", {
120
+ className: "flex-1",
121
+ children: /*#__PURE__*/jsx(TextField, {
122
+ defaultValue: item.label,
123
+ placeholder: "\u8BF7\u8F93\u5165\u6807\u7B7E",
124
+ onChange: value => handleSave(item.id, 'label', value),
125
+ UNSAFE_className: textFieldStyle
126
+ })
127
+ }), /*#__PURE__*/jsx("div", {
128
+ className: "flex-1",
129
+ children: /*#__PURE__*/jsx(TextField, {
130
+ defaultValue: item.value,
131
+ placeholder: "\u8BF7\u8F93\u5165\u503C",
132
+ onChange: value => handleSave(item.id, 'value', value),
133
+ UNSAFE_className: textFieldStyle
134
+ })
135
+ }), /*#__PURE__*/jsx("div", {
136
+ className: "flex-1",
137
+ children: /*#__PURE__*/jsx(TextField, {
138
+ defaultValue: item.desc,
139
+ placeholder: "\u8BF7\u8F93\u5165\u5907\u6CE8",
140
+ onChange: value => handleSave(item.id, 'desc', value),
141
+ UNSAFE_className: textFieldStyle
142
+ })
143
+ }), /*#__PURE__*/jsx("div", {
144
+ className: "w-24 text-center",
145
+ children: /*#__PURE__*/jsx("a", {
146
+ className: "cursor-pointer",
147
+ onClick: () => handleSave(item.id, 'status', item.status === 1 ? 0 : 1),
148
+ children: /*#__PURE__*/jsx(Text, {
149
+ children: /*#__PURE__*/jsx("span", {
150
+ className: item.status === 1 ? '' : 'text-red-300',
151
+ children: item.status === 1 ? '启用' : '停用'
152
+ })
153
+ })
154
+ })
155
+ }), /*#__PURE__*/jsx("div", {
156
+ className: "w-24 text-center",
157
+ children: /*#__PURE__*/jsx(Text, {
158
+ children: item.createdAt
159
+ })
160
+ }), /*#__PURE__*/jsx("div", {
161
+ className: "w-14 text-center",
162
+ children: /*#__PURE__*/jsx("a", {
163
+ className: "cursor-pointer",
164
+ onClick: () => handleRemove(item.id),
165
+ children: /*#__PURE__*/jsx(Text, {
166
+ children: "\u5220\u9664"
167
+ })
168
+ })
169
+ })]
170
+ }, item.id))
171
+ })]
172
+ }), /*#__PURE__*/jsx("div", {
173
+ children: /*#__PURE__*/jsxs(Button, {
174
+ onClick: handleAdd,
175
+ children: [/*#__PURE__*/jsx(Icon, {
176
+ src: plusIcon
177
+ }), /*#__PURE__*/jsx(Text, {
178
+ children: "\u6DFB\u52A0\u5B57\u5178\u503C"
179
+ })]
180
+ })
181
+ })]
182
+ });
183
+ }
184
+
185
+ const Field = props => {
186
+ const {
187
+ field,
188
+ forceValidation,
189
+ onChange,
190
+ value
191
+ } = props;
192
+ const errorMessage = forceValidation ? 'Invalid JSON' : undefined;
193
+ let initValue = [];
194
+ if (value) {
195
+ try {
196
+ initValue = JSON.parse(value);
197
+ } catch (e) {
198
+ initValue = [];
199
+ }
200
+ }
201
+ return /*#__PURE__*/jsx(Field$1, {
202
+ label: field.label,
203
+ description: field.description,
204
+ errorMessage: errorMessage,
205
+ children: inputProps => {
206
+ return /*#__PURE__*/jsx(KeystarProvider, {
207
+ children: /*#__PURE__*/jsx(ValuesEditor, {
208
+ ...inputProps,
209
+ defaultValue: initValue,
210
+ onChange: json => onChange === null || onChange === void 0 ? void 0 : onChange(JSON.stringify(json))
211
+ })
212
+ });
213
+ }
214
+ });
215
+ };
216
+ const Cell = ({
217
+ value
218
+ }) => {
219
+ var _value$length;
220
+ return value ? /*#__PURE__*/jsx(Text, {
221
+ children: (_value$length = value === null || value === void 0 ? void 0 : value.length) !== null && _value$length !== void 0 ? _value$length : 0
222
+ }) : null;
223
+ };
224
+ const controller = controller$1;
225
+
226
+ export { Cell, Field, controller };
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "dist/lkb-fields-custom-views-dictionary-values-editor.cjs.js",
3
+ "module": "dist/lkb-fields-custom-views-dictionary-values-editor.esm.js"
4
+ }
@@ -0,0 +1,6 @@
1
+ import { type CellComponent, type FieldProps } from 'lkb-core/types';
2
+ import { controller as JsonController } from 'lkb-core/fields/types/json/views';
3
+ export declare const Field: (props: FieldProps<typeof JsonController>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const Cell: CellComponent<typeof JsonController>;
5
+ export declare const controller: typeof JsonController;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/dictionary-values-editor","sources":["index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAE/E,eAAO,MAAM,KAAK,GAAI,OAAO,UAAU,CAAC,OAAO,cAAc,CAAC,4CA4B7D,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,aAAa,CAAC,OAAO,cAAc,CAErD,CAAA;AAED,eAAO,MAAM,UAAU,uBAAiB,CAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { type FieldProps } from 'lkb-core/types';
2
+ import { type controller } from 'lkb-core/fields/types/text/views';
3
+ export declare function Field(props: FieldProps<typeof controller>): import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/lng-lat-selector","sources":["index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAKlE,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,2CAoCzD"}
@@ -0,0 +1,3 @@
1
+ import { type CellComponent } from 'lkb-core/types';
2
+ export declare const Cell: CellComponent;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/status-on-off-field","sources":["index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,eAAO,MAAM,IAAI,EAAE,aAMlB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { type CellComponent } from 'lkb-core/types';
2
+ export declare const Cell: CellComponent;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/tree-node-order-field","sources":["index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,eAAO,MAAM,IAAI,EAAE,aAUlB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from "./declarations/src/index.js";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1jdXN0b20tdmlld3MuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuL2RlY2xhcmF0aW9ucy9zcmMvaW5kZXguZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,2 @@
1
+ export * from "../../dist/declarations/src/lng-lat-selector/index.js";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1jdXN0b20tdmlld3MtbG5nLWxhdC1zZWxlY3Rvci5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL2Rpc3QvZGVjbGFyYXRpb25zL3NyYy9sbmctbGF0LXNlbGVjdG9yL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var layout = require('@keystar/ui/layout');
6
+ var button = require('@keystar/ui/button');
7
+ var core = require('@keystar/ui/core');
8
+ var textField = require('@keystar/ui/text-field');
9
+ var field = require('@keystar/ui/field');
10
+ var jsxRuntime = require('react/jsx-runtime');
11
+
12
+ // 百度地图选择经纬度工具地址。
13
+ const baiduMapUrl = 'https://api.map.baidu.com/lbsapi/getpoint/';
14
+ function Field(props) {
15
+ const {
16
+ autoFocus,
17
+ field: field$1,
18
+ onChange,
19
+ value,
20
+ isRequired
21
+ } = props;
22
+ const isReadOnly = onChange == null;
23
+ const isNull = value.inner.kind === 'null';
24
+ return /*#__PURE__*/jsxRuntime.jsx(field.Field, {
25
+ label: field$1.label,
26
+ description: field$1.description,
27
+ children: inputProps => {
28
+ return /*#__PURE__*/jsxRuntime.jsx(core.KeystarProvider, {
29
+ children: /*#__PURE__*/jsxRuntime.jsxs(layout.HStack, {
30
+ gap: "medium",
31
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
32
+ className: "flex-1",
33
+ children: /*#__PURE__*/jsxRuntime.jsx(textField.TextField, {
34
+ autoFocus: autoFocus,
35
+ isDisabled: isNull,
36
+ isReadOnly: isReadOnly,
37
+ isRequired: isRequired,
38
+ onChange: textValue => {
39
+ onChange === null || onChange === void 0 || onChange({
40
+ ...value,
41
+ inner: {
42
+ kind: 'value',
43
+ value: textValue
44
+ }
45
+ });
46
+ }
47
+ // maintain the previous value when set to null in aid of continuity for
48
+ // the user. it will be cleared when the item is saved
49
+ ,
50
+ value: value.inner.kind === 'value' ? value.inner.value : value.inner.prev
51
+ })
52
+ }), /*#__PURE__*/jsxRuntime.jsx(button.Button, {
53
+ onClick: () => window.open(baiduMapUrl),
54
+ children: "\u9009\u53D6\u7ECF\u7EAC\u5EA6"
55
+ })]
56
+ })
57
+ });
58
+ }
59
+ });
60
+ }
61
+
62
+ exports.Field = Field;
@@ -0,0 +1,58 @@
1
+ import { HStack } from '@keystar/ui/layout';
2
+ import { Button } from '@keystar/ui/button';
3
+ import { KeystarProvider } from '@keystar/ui/core';
4
+ import { TextField } from '@keystar/ui/text-field';
5
+ import { Field as Field$1 } from '@keystar/ui/field';
6
+ import { jsx, jsxs } from 'react/jsx-runtime';
7
+
8
+ // 百度地图选择经纬度工具地址。
9
+ const baiduMapUrl = 'https://api.map.baidu.com/lbsapi/getpoint/';
10
+ function Field(props) {
11
+ const {
12
+ autoFocus,
13
+ field,
14
+ onChange,
15
+ value,
16
+ isRequired
17
+ } = props;
18
+ const isReadOnly = onChange == null;
19
+ const isNull = value.inner.kind === 'null';
20
+ return /*#__PURE__*/jsx(Field$1, {
21
+ label: field.label,
22
+ description: field.description,
23
+ children: inputProps => {
24
+ return /*#__PURE__*/jsx(KeystarProvider, {
25
+ children: /*#__PURE__*/jsxs(HStack, {
26
+ gap: "medium",
27
+ children: [/*#__PURE__*/jsx("div", {
28
+ className: "flex-1",
29
+ children: /*#__PURE__*/jsx(TextField, {
30
+ autoFocus: autoFocus,
31
+ isDisabled: isNull,
32
+ isReadOnly: isReadOnly,
33
+ isRequired: isRequired,
34
+ onChange: textValue => {
35
+ onChange === null || onChange === void 0 || onChange({
36
+ ...value,
37
+ inner: {
38
+ kind: 'value',
39
+ value: textValue
40
+ }
41
+ });
42
+ }
43
+ // maintain the previous value when set to null in aid of continuity for
44
+ // the user. it will be cleared when the item is saved
45
+ ,
46
+ value: value.inner.kind === 'value' ? value.inner.value : value.inner.prev
47
+ })
48
+ }), /*#__PURE__*/jsx(Button, {
49
+ onClick: () => window.open(baiduMapUrl),
50
+ children: "\u9009\u53D6\u7ECF\u7EAC\u5EA6"
51
+ })]
52
+ })
53
+ });
54
+ }
55
+ });
56
+ }
57
+
58
+ export { Field };
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "dist/lkb-fields-custom-views-lng-lat-selector.cjs.js",
3
+ "module": "dist/lkb-fields-custom-views-lng-lat-selector.esm.js"
4
+ }
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "lkb-fields-custom-views",
3
+ "version": "1.0.0",
4
+ "main": "dist/lkb-fields-custom-views.cjs.js",
5
+ "module": "dist/lkb-fields-custom-views.esm.js",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/lkb-fields-custom-views.cjs.js",
9
+ "module": "./dist/lkb-fields-custom-views.esm.js",
10
+ "default": "./dist/lkb-fields-custom-views.cjs.js"
11
+ },
12
+ "./lng-lat-selector": {
13
+ "types": "./lng-lat-selector/dist/lkb-fields-custom-views-lng-lat-selector.cjs.js",
14
+ "module": "./lng-lat-selector/dist/lkb-fields-custom-views-lng-lat-selector.esm.js",
15
+ "default": "./lng-lat-selector/dist/lkb-fields-custom-views-lng-lat-selector.cjs.js"
16
+ },
17
+ "./status-on-off-field": {
18
+ "types": "./status-on-off-field/dist/lkb-fields-custom-views-status-on-off-field.cjs.js",
19
+ "module": "./status-on-off-field/dist/lkb-fields-custom-views-status-on-off-field.esm.js",
20
+ "default": "./status-on-off-field/dist/lkb-fields-custom-views-status-on-off-field.cjs.js"
21
+ },
22
+ "./tree-node-order-field": {
23
+ "types": "./tree-node-order-field/dist/lkb-fields-custom-views-tree-node-order-field.cjs.js",
24
+ "module": "./tree-node-order-field/dist/lkb-fields-custom-views-tree-node-order-field.esm.js",
25
+ "default": "./tree-node-order-field/dist/lkb-fields-custom-views-tree-node-order-field.cjs.js"
26
+ },
27
+ "./dictionary-values-editor": {
28
+ "types": "./dictionary-values-editor/dist/lkb-fields-custom-views-dictionary-values-editor.cjs.js",
29
+ "module": "./dictionary-values-editor/dist/lkb-fields-custom-views-dictionary-values-editor.esm.js",
30
+ "default": "./dictionary-values-editor/dist/lkb-fields-custom-views-dictionary-values-editor.cjs.js"
31
+ },
32
+ "./package.json": "./package.json"
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "lng-lat-selector",
37
+ "status-on-off-field",
38
+ "tree-node-order-field",
39
+ "dictionary-values-editor"
40
+ ],
41
+ "preconstruct": {
42
+ "entrypoints": [
43
+ "index.ts",
44
+ "lng-lat-selector/index.tsx",
45
+ "status-on-off-field/index.tsx",
46
+ "tree-node-order-field/index.tsx",
47
+ "dictionary-values-editor/index.tsx"
48
+ ]
49
+ },
50
+ "dependencies": {
51
+ "react": "19.2.4",
52
+ "react-dom": "19.2.4",
53
+ "@keystar/ui": "^0.7.16",
54
+ "lkb-core": "workspace:^"
55
+ },
56
+ "peerDependencies": {
57
+ "lkb-core": "workspace:^"
58
+ }
59
+ }
@@ -0,0 +1,2 @@
1
+ export * from "../../dist/declarations/src/status-on-off-field/index.js";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1jdXN0b20tdmlld3Mtc3RhdHVzLW9uLW9mZi1maWVsZC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL2Rpc3QvZGVjbGFyYXRpb25zL3NyYy9zdGF0dXMtb24tb2ZmLWZpZWxkL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var typography = require('@keystar/ui/typography');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ const Cell = ({
9
+ value
10
+ }) => {
11
+ if (value === 1) {
12
+ return /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
13
+ children: "\u542F\u7528"
14
+ });
15
+ } else {
16
+ return /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
17
+ color: "critical",
18
+ children: "\u7981\u7528"
19
+ });
20
+ }
21
+ };
22
+
23
+ exports.Cell = Cell;
@@ -0,0 +1,19 @@
1
+ import { Text } from '@keystar/ui/typography';
2
+ import { jsx } from 'react/jsx-runtime';
3
+
4
+ const Cell = ({
5
+ value
6
+ }) => {
7
+ if (value === 1) {
8
+ return /*#__PURE__*/jsx(Text, {
9
+ children: "\u542F\u7528"
10
+ });
11
+ } else {
12
+ return /*#__PURE__*/jsx(Text, {
13
+ color: "critical",
14
+ children: "\u7981\u7528"
15
+ });
16
+ }
17
+ };
18
+
19
+ export { Cell };
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "dist/lkb-fields-custom-views-status-on-off-field.cjs.js",
3
+ "module": "dist/lkb-fields-custom-views-status-on-off-field.esm.js"
4
+ }
@@ -0,0 +1,2 @@
1
+ export * from "../../dist/declarations/src/tree-node-order-field/index.js";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1jdXN0b20tdmlld3MtdHJlZS1ub2RlLW9yZGVyLWZpZWxkLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vZGlzdC9kZWNsYXJhdGlvbnMvc3JjL3RyZWUtbm9kZS1vcmRlci1maWVsZC9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var typography = require('@keystar/ui/typography');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ const Cell = ({
9
+ value,
10
+ item
11
+ }) => {
12
+ if (item.parent) {
13
+ return /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
14
+ color: "neutralTertiary",
15
+ UNSAFE_style: {
16
+ paddingLeft: 20
17
+ },
18
+ children: value
19
+ });
20
+ } else {
21
+ return /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
22
+ children: value
23
+ });
24
+ }
25
+ };
26
+
27
+ exports.Cell = Cell;
@@ -0,0 +1,23 @@
1
+ import { Text } from '@keystar/ui/typography';
2
+ import { jsx } from 'react/jsx-runtime';
3
+
4
+ const Cell = ({
5
+ value,
6
+ item
7
+ }) => {
8
+ if (item.parent) {
9
+ return /*#__PURE__*/jsx(Text, {
10
+ color: "neutralTertiary",
11
+ UNSAFE_style: {
12
+ paddingLeft: 20
13
+ },
14
+ children: value
15
+ });
16
+ } else {
17
+ return /*#__PURE__*/jsx(Text, {
18
+ children: value
19
+ });
20
+ }
21
+ };
22
+
23
+ export { Cell };
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "dist/lkb-fields-custom-views-tree-node-order-field.cjs.js",
3
+ "module": "dist/lkb-fields-custom-views-tree-node-order-field.esm.js"
4
+ }