x-star-design 0.0.79 → 0.0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/locales/en_US.d.ts +4 -0
- package/dist/locales/en_US.js +4 -0
- package/dist/locales/index.d.ts +9 -1
- package/dist/locales/zh_CN.d.ts +4 -0
- package/dist/locales/zh_CN.js +4 -0
- package/dist/zip-code-search-input/define.d.ts +5 -0
- package/dist/zip-code-search-input/define.js +1 -0
- package/dist/zip-code-search-input/index.d.ts +4 -0
- package/dist/zip-code-search-input/index.js +137 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -59,3 +59,4 @@ export { default as VisualDataConfig } from './visual-data-config';
|
|
|
59
59
|
export type { VisualDataConfigProps } from './visual-data-config';
|
|
60
60
|
export { default as XTabs } from './x-tabs';
|
|
61
61
|
export type { XTabsProps } from './x-tabs';
|
|
62
|
+
export { default as ZipCodeSearchInput } from './zip-code-search-input';
|
package/dist/index.js
CHANGED
|
@@ -29,4 +29,5 @@ export { default as TitleWithIcon } from "./title-with-icon";
|
|
|
29
29
|
export { default as UserAvatar } from "./user-avatar";
|
|
30
30
|
export { default as VirtualTable } from "./virtual-table";
|
|
31
31
|
export { default as VisualDataConfig } from "./visual-data-config";
|
|
32
|
-
export { default as XTabs } from "./x-tabs";
|
|
32
|
+
export { default as XTabs } from "./x-tabs";
|
|
33
|
+
export { default as ZipCodeSearchInput } from "./zip-code-search-input";
|
package/dist/locales/en_US.d.ts
CHANGED
|
@@ -176,5 +176,9 @@ declare const _default: {
|
|
|
176
176
|
readonly PrimarySchool: "Primary School";
|
|
177
177
|
readonly DropRenderText: "Statistical data as of December 2020";
|
|
178
178
|
};
|
|
179
|
+
readonly ZipCodeSearchInput: {
|
|
180
|
+
readonly placeholder: "Please enter the zip code";
|
|
181
|
+
readonly area: "Area";
|
|
182
|
+
};
|
|
179
183
|
};
|
|
180
184
|
export default _default;
|
package/dist/locales/en_US.js
CHANGED
|
@@ -175,5 +175,9 @@ export default {
|
|
|
175
175
|
MiddleSchool: 'Middle School',
|
|
176
176
|
PrimarySchool: 'Primary School',
|
|
177
177
|
DropRenderText: 'Statistical data as of December 2020'
|
|
178
|
+
},
|
|
179
|
+
ZipCodeSearchInput: {
|
|
180
|
+
placeholder: 'Please enter the zip code',
|
|
181
|
+
area: 'Area'
|
|
178
182
|
}
|
|
179
183
|
};
|
package/dist/locales/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface LocaleProviderProps {
|
|
|
7
7
|
}
|
|
8
8
|
export declare const LocaleProvider: ({ children, locale, }: LocaleProviderProps) => React.JSX.Element;
|
|
9
9
|
type MessageMap = typeof zh_CN | typeof en_US;
|
|
10
|
-
export declare const useLocale: <T extends "VisualDataConfig" | "TranslateButton" | "CodeDetailModal" | "ContactButton" | "ErrorPage" | "Feedback" | "MicroApp" | "ContestTimeInput" | "AcConfig" | "ScoreReport" | "SchoolInput">(slice: T) => {
|
|
10
|
+
export declare const useLocale: <T extends "VisualDataConfig" | "TranslateButton" | "CodeDetailModal" | "ContactButton" | "ErrorPage" | "Feedback" | "MicroApp" | "ContestTimeInput" | "AcConfig" | "ScoreReport" | "SchoolInput" | "ZipCodeSearchInput">(slice: T) => {
|
|
11
11
|
locale: string;
|
|
12
12
|
format: <U extends keyof MessageMap[T]>(key: U) => ({
|
|
13
13
|
readonly VisualDataConfig: {
|
|
@@ -187,6 +187,10 @@ export declare const useLocale: <T extends "VisualDataConfig" | "TranslateButton
|
|
|
187
187
|
readonly PrimarySchool: "小学";
|
|
188
188
|
readonly DropRenderText: "统计数据截至于2020年12月";
|
|
189
189
|
};
|
|
190
|
+
readonly ZipCodeSearchInput: {
|
|
191
|
+
readonly placeholder: "请输入邮政编码";
|
|
192
|
+
readonly area: "所选地区";
|
|
193
|
+
};
|
|
190
194
|
} | {
|
|
191
195
|
readonly VisualDataConfig: {
|
|
192
196
|
readonly Time_MS: "Time Limit(MS)";
|
|
@@ -365,6 +369,10 @@ export declare const useLocale: <T extends "VisualDataConfig" | "TranslateButton
|
|
|
365
369
|
readonly PrimarySchool: "Primary School";
|
|
366
370
|
readonly DropRenderText: "Statistical data as of December 2020";
|
|
367
371
|
};
|
|
372
|
+
readonly ZipCodeSearchInput: {
|
|
373
|
+
readonly placeholder: "Please enter the zip code";
|
|
374
|
+
readonly area: "Area";
|
|
375
|
+
};
|
|
368
376
|
})[T][U];
|
|
369
377
|
};
|
|
370
378
|
export {};
|
package/dist/locales/zh_CN.d.ts
CHANGED
|
@@ -176,5 +176,9 @@ declare const _default: {
|
|
|
176
176
|
readonly PrimarySchool: "小学";
|
|
177
177
|
readonly DropRenderText: "统计数据截至于2020年12月";
|
|
178
178
|
};
|
|
179
|
+
readonly ZipCodeSearchInput: {
|
|
180
|
+
readonly placeholder: "请输入邮政编码";
|
|
181
|
+
readonly area: "所选地区";
|
|
182
|
+
};
|
|
179
183
|
};
|
|
180
184
|
export default _default;
|
package/dist/locales/zh_CN.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
6
|
+
var _excluded = ["value", "onChange", "debounceTimeout"];
|
|
7
|
+
import { Empty, Select, Spin } from 'antd';
|
|
8
|
+
import React, { useEffect, useState } from 'react';
|
|
9
|
+
import { useLocale } from "../locales";
|
|
10
|
+
var debounce = function debounce(func, delay) {
|
|
11
|
+
var timer = null;
|
|
12
|
+
return function () {
|
|
13
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14
|
+
args[_key] = arguments[_key];
|
|
15
|
+
}
|
|
16
|
+
if (timer) {
|
|
17
|
+
clearTimeout(timer);
|
|
18
|
+
}
|
|
19
|
+
timer = setTimeout(function () {
|
|
20
|
+
func.apply(void 0, args);
|
|
21
|
+
}, delay);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
var ZipCodeSearchInput = function ZipCodeSearchInput(props) {
|
|
25
|
+
var value = props.value,
|
|
26
|
+
_onChange = props.onChange,
|
|
27
|
+
_props$debounceTimeou = props.debounceTimeout,
|
|
28
|
+
debounceTimeout = _props$debounceTimeou === void 0 ? 1000 : _props$debounceTimeou,
|
|
29
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
30
|
+
var _useLocale = useLocale('ZipCodeSearchInput'),
|
|
31
|
+
t = _useLocale.format;
|
|
32
|
+
var _useState = useState([]),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
data = _useState2[0],
|
|
35
|
+
setData = _useState2[1];
|
|
36
|
+
var _useState3 = useState(),
|
|
37
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
38
|
+
originValue = _useState4[0],
|
|
39
|
+
setOriginValue = _useState4[1];
|
|
40
|
+
var _useState5 = useState(false),
|
|
41
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
42
|
+
loading = _useState6[0],
|
|
43
|
+
setLoading = _useState6[1];
|
|
44
|
+
useEffect(function () {
|
|
45
|
+
if (value) {
|
|
46
|
+
setOriginValue(value);
|
|
47
|
+
}
|
|
48
|
+
}, [value]);
|
|
49
|
+
var handleSearch = /*#__PURE__*/function () {
|
|
50
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(newValue) {
|
|
51
|
+
var response, res, state, city;
|
|
52
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
53
|
+
while (1) switch (_context.prev = _context.next) {
|
|
54
|
+
case 0:
|
|
55
|
+
_context.prev = 0;
|
|
56
|
+
if (newValue) {
|
|
57
|
+
_context.next = 3;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
return _context.abrupt("return", setData([]));
|
|
61
|
+
case 3:
|
|
62
|
+
setLoading(true);
|
|
63
|
+
_context.next = 6;
|
|
64
|
+
return fetch("https://api.zippopotam.us/us/".concat(newValue));
|
|
65
|
+
case 6:
|
|
66
|
+
response = _context.sent;
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
_context.next = 19;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
_context.next = 10;
|
|
72
|
+
return response.json();
|
|
73
|
+
case 10:
|
|
74
|
+
res = _context.sent;
|
|
75
|
+
if (res !== null && res !== void 0 && res.places) {
|
|
76
|
+
_context.next = 14;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
setData([]);
|
|
80
|
+
return _context.abrupt("return", setLoading(false));
|
|
81
|
+
case 14:
|
|
82
|
+
state = res.places[0]['state'];
|
|
83
|
+
city = res.places[0]['place name'];
|
|
84
|
+
setData([{
|
|
85
|
+
label: "".concat(state, "/").concat(city),
|
|
86
|
+
value: "".concat(state, "/").concat(city)
|
|
87
|
+
}]);
|
|
88
|
+
_context.next = 20;
|
|
89
|
+
break;
|
|
90
|
+
case 19:
|
|
91
|
+
setData([]);
|
|
92
|
+
case 20:
|
|
93
|
+
_context.next = 25;
|
|
94
|
+
break;
|
|
95
|
+
case 22:
|
|
96
|
+
_context.prev = 22;
|
|
97
|
+
_context.t0 = _context["catch"](0);
|
|
98
|
+
setData([]);
|
|
99
|
+
case 25:
|
|
100
|
+
_context.prev = 25;
|
|
101
|
+
setLoading(false);
|
|
102
|
+
return _context.finish(25);
|
|
103
|
+
case 28:
|
|
104
|
+
case "end":
|
|
105
|
+
return _context.stop();
|
|
106
|
+
}
|
|
107
|
+
}, _callee, null, [[0, 22, 25, 28]]);
|
|
108
|
+
}));
|
|
109
|
+
return function handleSearch(_x) {
|
|
110
|
+
return _ref.apply(this, arguments);
|
|
111
|
+
};
|
|
112
|
+
}();
|
|
113
|
+
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
114
|
+
showSearch: true,
|
|
115
|
+
value: originValue,
|
|
116
|
+
placeholder: t('placeholder'),
|
|
117
|
+
defaultActiveFirstOption: false,
|
|
118
|
+
suffixIcon: null,
|
|
119
|
+
filterOption: false,
|
|
120
|
+
onSearch: debounce(handleSearch, debounceTimeout),
|
|
121
|
+
onChange: function onChange(value, option) {
|
|
122
|
+
setOriginValue(value);
|
|
123
|
+
if (!value) setData([]);
|
|
124
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(value, option);
|
|
125
|
+
},
|
|
126
|
+
notFoundContent: loading ? /*#__PURE__*/React.createElement(Spin, {
|
|
127
|
+
size: "small",
|
|
128
|
+
style: {
|
|
129
|
+
width: '100%',
|
|
130
|
+
margin: 'auto'
|
|
131
|
+
}
|
|
132
|
+
}) : /*#__PURE__*/React.createElement(Empty, null),
|
|
133
|
+
options: data,
|
|
134
|
+
allowClear: true
|
|
135
|
+
}, otherProps));
|
|
136
|
+
};
|
|
137
|
+
export default ZipCodeSearchInput;
|