@kne/modules-dev 2.1.15 → 2.1.17

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.
@@ -1,4 +1,4 @@
1
- import React$1, { useRef, useEffect, useMemo, useState } from 'react';
1
+ import { useRef, useEffect, useMemo, useState } from 'react';
2
2
  import { HashRouter, useParams, useSearchParams, Navigate, useNavigate, Outlet, Routes, Route, useLocation } from 'react-router-dom';
3
3
  import { createWithRemoteLoader } from '@kne/remote-loader';
4
4
  import ensureSlash from '@kne/ensure-slash';
@@ -9,6 +9,7 @@ import classnames from 'classnames';
9
9
  import ExampleDriver from '@kne/example-driver';
10
10
  import hljs from 'highlight.js';
11
11
  import 'highlight.js/styles/github.css';
12
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
12
13
  import Fetch from '@kne/react-fetch';
13
14
  import Icon from '@kne/react-icon';
14
15
 
@@ -48,7 +49,7 @@ const Highlight = _ref => {
48
49
  hljs.highlightElement(el);
49
50
  });
50
51
  }, [html]);
51
- return /*#__PURE__*/React$1.createElement("div", _extends({}, props, {
52
+ return /*#__PURE__*/jsx("div", _extends({}, props, {
52
53
  ref: ref,
53
54
  dangerouslySetInnerHTML: {
54
55
  __html: html
@@ -66,7 +67,11 @@ const ExampleDriverContext = createWithRemoteLoader({
66
67
  } = _ref,
67
68
  props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
68
69
  const [GlobalProvider] = remoteModules;
69
- return /*#__PURE__*/React$1.createElement(HashRouter, null, /*#__PURE__*/React$1.createElement(GlobalProvider, props, children));
70
+ return /*#__PURE__*/jsx(HashRouter, {
71
+ children: /*#__PURE__*/jsx(GlobalProvider, _extends({}, props, {
72
+ children: children
73
+ }))
74
+ });
70
75
  });
71
76
  const ExampleContent = createWithRemoteLoader({
72
77
  modules: ["components-core:Global@useGlobalContext", "components-core:Global@usePreset"]
@@ -83,9 +88,10 @@ const ExampleContent = createWithRemoteLoader({
83
88
  const DriverContext = useMemo(() => {
84
89
  return ({
85
90
  children
86
- }) => /*#__PURE__*/React$1.createElement(ExampleDriverContext, _extends({}, global, {
87
- preset: preset
88
- }), children);
91
+ }) => /*#__PURE__*/jsx(ExampleDriverContext, _extends({}, global, {
92
+ preset: preset,
93
+ children: children
94
+ }));
89
95
  }, [global]);
90
96
  useEffect(() => {
91
97
  if (!exampleStyle) {
@@ -98,38 +104,53 @@ const ExampleContent = createWithRemoteLoader({
98
104
  document.head.removeChild(dom);
99
105
  };
100
106
  }, [exampleStyle]);
101
- return /*#__PURE__*/React$1.createElement(Space, {
107
+ return /*#__PURE__*/jsxs(Space, {
102
108
  className: classnames('container', style['main']),
103
- direction: "vertical"
104
- }, data.packageName && /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement("h2", {
105
- className: style['part-title']
106
- }, "\u5B89\u88C5"), /*#__PURE__*/React$1.createElement(Highlight, {
107
- className: "mark-down-html",
108
- html: `<pre><code class="language-shell hljs">npm install --save ${data.packageName}</code></pre>`
109
- })), data.description && /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement("h2", {
110
- className: style['part-title']
111
- }, "\u63CF\u8FF0"), /*#__PURE__*/React$1.createElement(Highlight, {
112
- className: "mark-down-html",
113
- html: data.description
114
- })), data.summary && /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement("h2", {
115
- className: style['part-title']
116
- }, "\u6982\u8FF0"), /*#__PURE__*/React$1.createElement(Highlight, {
117
- className: "mark-down-html",
118
- html: data.summary
119
- })), data.example.list && data.example.list.length > 0 && /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement("h2", {
120
- className: style['part-title']
121
- }, "\u4EE3\u7801\u793A\u4F8B"), /*#__PURE__*/React$1.createElement("div", {
122
- className: classnames(style['example'], data.example.className)
123
- }, /*#__PURE__*/React$1.createElement(ExampleDriver, {
124
- contextComponent: DriverContext,
125
- isFull: data.example.isFull,
126
- list: data.example.list
127
- }))), /*#__PURE__*/React$1.createElement("h2", {
128
- className: style['part-title']
129
- }, "API"), /*#__PURE__*/React$1.createElement(Highlight, {
130
- className: "mark-down-html",
131
- html: data.api
132
- }));
109
+ direction: "vertical",
110
+ children: [data.packageName && /*#__PURE__*/jsxs(Fragment, {
111
+ children: [/*#__PURE__*/jsx("h2", {
112
+ className: style['part-title'],
113
+ children: "\u5B89\u88C5"
114
+ }), /*#__PURE__*/jsx(Highlight, {
115
+ className: "mark-down-html",
116
+ html: `<pre><code class="language-shell hljs">npm install --save ${data.packageName}</code></pre>`
117
+ })]
118
+ }), data.description && /*#__PURE__*/jsxs(Fragment, {
119
+ children: [/*#__PURE__*/jsx("h2", {
120
+ className: style['part-title'],
121
+ children: "\u63CF\u8FF0"
122
+ }), /*#__PURE__*/jsx(Highlight, {
123
+ className: "mark-down-html",
124
+ html: data.description
125
+ })]
126
+ }), data.summary && /*#__PURE__*/jsxs(Fragment, {
127
+ children: [/*#__PURE__*/jsx("h2", {
128
+ className: style['part-title'],
129
+ children: "\u6982\u8FF0"
130
+ }), /*#__PURE__*/jsx(Highlight, {
131
+ className: "mark-down-html",
132
+ html: data.summary
133
+ })]
134
+ }), data.example.list && data.example.list.length > 0 && /*#__PURE__*/jsxs(Fragment, {
135
+ children: [/*#__PURE__*/jsx("h2", {
136
+ className: style['part-title'],
137
+ children: "\u4EE3\u7801\u793A\u4F8B"
138
+ }), /*#__PURE__*/jsx("div", {
139
+ className: classnames(style['example'], data.example.className),
140
+ children: /*#__PURE__*/jsx(ExampleDriver, {
141
+ contextComponent: DriverContext,
142
+ isFull: data.example.isFull,
143
+ list: data.example.list
144
+ })
145
+ })]
146
+ }), /*#__PURE__*/jsx("h2", {
147
+ className: style['part-title'],
148
+ children: "API"
149
+ }), /*#__PURE__*/jsx(Highlight, {
150
+ className: "mark-down-html",
151
+ html: data.api
152
+ })]
153
+ });
133
154
  });
134
155
  const ExamplePage = createWithRemoteLoader({
135
156
  modules: ["components-core:Layout@Page", "components-core:Layout@Menu", "components-core:Global@useGlobalContext"]
@@ -141,15 +162,17 @@ const ExamplePage = createWithRemoteLoader({
141
162
  pageProps: _pageProps = {}
142
163
  }) => {
143
164
  const [Page, Menu] = remoteModules;
144
- return /*#__PURE__*/React$1.createElement(Page, _extends({
165
+ return /*#__PURE__*/jsx(Page, _extends({
145
166
  title: data.name,
146
167
  className: style['example-page'],
147
- menu: items && items.length > 0 && /*#__PURE__*/React$1.createElement(Menu, {
168
+ menu: items && items.length > 0 && /*#__PURE__*/jsx(Menu, {
148
169
  currentKey: current,
149
170
  items: items
150
171
  })
151
- }, _pageProps), /*#__PURE__*/React$1.createElement(ExampleContent, {
152
- data: data
172
+ }, _pageProps, {
173
+ children: /*#__PURE__*/jsx(ExampleContent, {
174
+ data: data
175
+ })
153
176
  }));
154
177
  });
155
178
 
@@ -165,14 +188,14 @@ const Example = ({
165
188
  const searchString = searchParams.size > 0 ? '?' + searchParams.toString() : '';
166
189
  const data = readme[current];
167
190
  if (!(current && readme[current])) {
168
- return /*#__PURE__*/React$1.createElement(Navigate, {
191
+ return /*#__PURE__*/jsx(Navigate, {
169
192
  to: `${ensureSlash(baseUrl, true)}${Object.keys(readme)[0]}${searchString}`,
170
193
  replace: true
171
194
  });
172
195
  }
173
196
  const renderExamplePage = ({
174
197
  data
175
- }) => /*#__PURE__*/React$1.createElement(ExamplePage, {
198
+ }) => /*#__PURE__*/jsx(ExamplePage, {
176
199
  pageProps: pageProps,
177
200
  data: data,
178
201
  current: current,
@@ -185,7 +208,7 @@ const Example = ({
185
208
  })
186
209
  });
187
210
  if (data && data.hasOwnProperty('loader') || data.hasOwnProperty('url')) {
188
- return /*#__PURE__*/React$1.createElement(Fetch, _extends({}, Object.assign({}, data), {
211
+ return /*#__PURE__*/jsx(Fetch, _extends({}, Object.assign({}, data), {
189
212
  render: renderExamplePage
190
213
  }));
191
214
  }
@@ -203,14 +226,14 @@ const ModulesIsEmpty = ({
203
226
  }) => {
204
227
  const location = useLocation();
205
228
  if (readme && Object.keys(readme).length > 0 && ensureSlash(location.pathname, true) === baseUrl) {
206
- return /*#__PURE__*/React$1.createElement(Navigate, {
229
+ return /*#__PURE__*/jsx(Navigate, {
207
230
  to: `${baseUrl}${Object.keys(readme)[0]}`
208
231
  });
209
232
  }
210
233
  if (readme && Object.keys(readme).length > 0) {
211
- return /*#__PURE__*/React$1.createElement(Outlet, null);
234
+ return /*#__PURE__*/jsx(Outlet, {});
212
235
  }
213
- return /*#__PURE__*/React$1.createElement(Result, {
236
+ return /*#__PURE__*/jsx(Result, {
214
237
  status: "404",
215
238
  title: "\u6CA1\u6709\u68C0\u6D4B\u5230\u4E1A\u52A1\u7EC4\u4EF6",
216
239
  subTitle: "\u60A8\u53EF\u4EE5\u901A\u8FC7 modules-dev create \u547D\u4EE4\u521B\u5EFA\u7EC4\u4EF6\uFF0C\u5982\u679C\u5DF2\u7ECF\u6709\u7EC4\u4EF6\u8BF7\u68C0\u67E5\u73AF\u5883\u53D8\u91CF MODULES_DEV_BASE_DIR\u548CMODULES_DEV_ALIAS_NAME \u662F\u5426\u8BBE\u7F6E\u6B63\u786E"
@@ -223,8 +246,8 @@ const EntryButton = createWithRemoteLoader({
223
246
  }) => {
224
247
  const [Icon] = remoteModules;
225
248
  const navigate = useNavigate();
226
- return /*#__PURE__*/React$1.createElement(FloatButton, {
227
- icon: /*#__PURE__*/React$1.createElement(Icon, {
249
+ return /*#__PURE__*/jsx(FloatButton, {
250
+ icon: /*#__PURE__*/jsx(Icon, {
228
251
  className: "icon",
229
252
  type: "icon-liangdian"
230
253
  }),
@@ -243,14 +266,16 @@ const MainLayout = createWithRemoteLoader({
243
266
  } = _ref,
244
267
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
245
268
  const [Global, Layout] = remoteModules;
246
- return /*#__PURE__*/React$1.createElement(Global, _extends({}, props, {
247
- preset: preset
248
- }), /*#__PURE__*/React$1.createElement(Layout, {
249
- navigation: {
250
- showIndex: false,
251
- list: paths
252
- }
253
- }, /*#__PURE__*/React$1.createElement(Outlet, null)));
269
+ return /*#__PURE__*/jsx(Global, _extends({}, props, {
270
+ preset: preset,
271
+ children: /*#__PURE__*/jsx(Layout, {
272
+ navigation: {
273
+ showIndex: false,
274
+ list: paths
275
+ },
276
+ children: /*#__PURE__*/jsx(Outlet, {})
277
+ })
278
+ }));
254
279
  });
255
280
  const ExampleRoutes = _ref2 => {
256
281
  let {
@@ -275,36 +300,40 @@ const ExampleRoutes = _ref2 => {
275
300
  const componentsBaseUrl = ensureSlash(get(componentsPath, 'path', '/'), true);
276
301
  const baseUrlPrefix = new RegExp(`^${ensureSlash(baseUrl, true)}`);
277
302
  const componentsRoutePath = ensureSlash(componentsBaseUrl.replace(baseUrlPrefix, ''));
278
- return /*#__PURE__*/React$1.createElement(Routes, null, /*#__PURE__*/React$1.createElement(Route, {
279
- element: /*#__PURE__*/React$1.createElement(MainLayout, _extends({
280
- paths: paths,
281
- preset: preset,
282
- themeToken: themeToken
283
- }, props))
284
- }, componentsPath && /*#__PURE__*/React$1.createElement(Route, {
285
- path: componentsRoutePath,
286
- element: /*#__PURE__*/React$1.createElement(ModulesIsEmpty, {
287
- baseUrl: componentsBaseUrl,
288
- readme: readme
289
- })
290
- }, /*#__PURE__*/React$1.createElement(Route, {
291
- path: ":id",
292
- element: /*#__PURE__*/React$1.createElement(Example, {
293
- baseUrl: componentsBaseUrl,
294
- readme: readme,
295
- pageProps: pageProps
296
- })
297
- }), /*#__PURE__*/React$1.createElement(Route, {
298
- path: ":id/*",
299
- element: /*#__PURE__*/React$1.createElement(Example, {
300
- baseUrl: componentsBaseUrl,
301
- readme: readme,
302
- pageProps: pageProps
303
- })
304
- }))), /*#__PURE__*/React$1.createElement(Route, {
305
- path: "*",
306
- element: children
307
- }));
303
+ return /*#__PURE__*/jsxs(Routes, {
304
+ children: [/*#__PURE__*/jsx(Route, {
305
+ element: /*#__PURE__*/jsx(MainLayout, _extends({
306
+ paths: paths,
307
+ preset: preset,
308
+ themeToken: themeToken
309
+ }, props)),
310
+ children: componentsPath && /*#__PURE__*/jsxs(Route, {
311
+ path: componentsRoutePath,
312
+ element: /*#__PURE__*/jsx(ModulesIsEmpty, {
313
+ baseUrl: componentsBaseUrl,
314
+ readme: readme
315
+ }),
316
+ children: [/*#__PURE__*/jsx(Route, {
317
+ path: ":id",
318
+ element: /*#__PURE__*/jsx(Example, {
319
+ baseUrl: componentsBaseUrl,
320
+ readme: readme,
321
+ pageProps: pageProps
322
+ })
323
+ }), /*#__PURE__*/jsx(Route, {
324
+ path: ":id/*",
325
+ element: /*#__PURE__*/jsx(Example, {
326
+ baseUrl: componentsBaseUrl,
327
+ readme: readme,
328
+ pageProps: pageProps
329
+ })
330
+ })]
331
+ })
332
+ }), /*#__PURE__*/jsx(Route, {
333
+ path: "*",
334
+ element: children
335
+ })]
336
+ });
308
337
  };
309
338
  const createEntry = WrappedComponents => _ref3 => {
310
339
  let {
@@ -321,23 +350,26 @@ const createEntry = WrappedComponents => _ref3 => {
321
350
  setReadme(module.__esModule === true ? module.default : module);
322
351
  });
323
352
  }, []);
324
- return /*#__PURE__*/React$1.createElement(React$1.Fragment, null, Object.keys(readme).length > 0 ? /*#__PURE__*/React$1.createElement(ExampleRoutes, {
325
- preset: preset,
326
- baseUrl: baseUrl,
327
- projectName: projectName,
328
- readme: readme,
329
- pageProps: pageProps,
330
- paths: [{
331
- key: 'index',
332
- path: '/',
333
- title: '首页'
334
- }, {
335
- key: 'components',
336
- path: `${baseUrl}/modules-dev-components`,
337
- title: '组件'
338
- }],
339
- themeToken: themeToken
340
- }, /*#__PURE__*/React$1.createElement(WrappedComponents, props), /*#__PURE__*/React$1.createElement(EntryButton, null)) : /*#__PURE__*/React$1.createElement(WrappedComponents, props));
353
+ return /*#__PURE__*/jsx(Fragment, {
354
+ children: Object.keys(readme).length > 0 ? /*#__PURE__*/jsxs(ExampleRoutes, {
355
+ preset: preset,
356
+ baseUrl: baseUrl,
357
+ projectName: projectName,
358
+ readme: readme,
359
+ pageProps: pageProps,
360
+ paths: [{
361
+ key: 'index',
362
+ path: '/',
363
+ title: '首页'
364
+ }, {
365
+ key: 'components',
366
+ path: `${baseUrl}/modules-dev-components`,
367
+ title: '组件'
368
+ }],
369
+ themeToken: themeToken,
370
+ children: [/*#__PURE__*/jsx(WrappedComponents, _extends({}, props)), /*#__PURE__*/jsx(EntryButton, {})]
371
+ }) : /*#__PURE__*/jsx(WrappedComponents, _extends({}, props))
372
+ });
341
373
  };
342
374
  createEntry.Example = Example;
343
375
  createEntry.ExampleRoutes = ExampleRoutes;
@@ -348,72 +380,94 @@ const FontList = ({
348
380
  fonts
349
381
  }) => {
350
382
  const [value, setValue] = useState(30);
351
- return /*#__PURE__*/React.createElement(Flex, {
383
+ return /*#__PURE__*/jsxs(Flex, {
352
384
  vertical: true,
353
- gap: 20
354
- }, /*#__PURE__*/React.createElement(Flex, {
355
- gap: 8
356
- }, /*#__PURE__*/React.createElement("div", null, "\u8C03\u6574\u5927\u5C0F:"), /*#__PURE__*/React.createElement(Slider, {
357
- style: {
358
- width: 100
359
- },
360
- max: 60,
361
- min: 12,
362
- value: value,
363
- onChange: setValue
364
- }), /*#__PURE__*/React.createElement("div", null, value, "px")), Object.keys(fonts).map(fontClassName => {
365
- const {
366
- glyphs: list
367
- } = fonts[fontClassName];
368
- const isColorful = /-colorful$/.test(fontClassName);
369
- return /*#__PURE__*/React.createElement(Flex, {
370
- vertical: true,
385
+ gap: 20,
386
+ children: [/*#__PURE__*/jsxs(Flex, {
371
387
  gap: 8,
372
- key: fontClassName
373
- }, /*#__PURE__*/React.createElement(Typography.Title, {
374
- level: 4
375
- }, fontClassName), /*#__PURE__*/React.createElement(Flex, {
376
- gap: 12,
377
- wrap: true
378
- }, list.map(({
379
- font_class
380
- }) => {
381
- return /*#__PURE__*/React.createElement(Card, {
382
- size: "small",
383
- key: font_class
384
- }, isColorful ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Flex, {
385
- justify: "center"
386
- }, /*#__PURE__*/React.createElement(Icon, {
387
- colorful: true,
388
- type: font_class,
389
- size: value
390
- })), /*#__PURE__*/React.createElement(Typography.Text, {
388
+ children: [/*#__PURE__*/jsx("div", {
389
+ children: "\u8C03\u6574\u5927\u5C0F:"
390
+ }), /*#__PURE__*/jsx(Slider, {
391
391
  style: {
392
- display: 'block',
393
- width: '120px',
394
- wordBreak: 'break-all'
392
+ width: 100
395
393
  },
396
- copyable: {
397
- text: '<Icon colorful type="' + font_class + '" size={' + value + '}/>'
398
- }
399
- }, font_class)) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Flex, {
400
- justify: "center"
401
- }, /*#__PURE__*/React.createElement(Icon, {
402
- type: font_class,
403
- size: value,
404
- fontClassName: fontClassName
405
- })), /*#__PURE__*/React.createElement(Typography.Text, {
406
- style: {
407
- display: 'block',
408
- width: '120px',
409
- wordBreak: 'break-all'
410
- },
411
- copyable: {
412
- text: '<Icon type="' + font_class + '" size={' + value + '} fontClassName={' + fontClassName + '}/>'
413
- }
414
- }, font_class)));
415
- })));
416
- }));
394
+ max: 60,
395
+ min: 12,
396
+ value: value,
397
+ onChange: setValue
398
+ }), /*#__PURE__*/jsxs("div", {
399
+ children: [value, "px"]
400
+ })]
401
+ }), Object.keys(fonts).map(fontClassName => {
402
+ const {
403
+ glyphs: list
404
+ } = fonts[fontClassName];
405
+ const isColorful = /-colorful$/.test(fontClassName);
406
+ return /*#__PURE__*/jsxs(Flex, {
407
+ vertical: true,
408
+ gap: 8,
409
+ children: [/*#__PURE__*/jsx(Typography.Title, {
410
+ level: 4,
411
+ children: fontClassName
412
+ }), /*#__PURE__*/jsx(Flex, {
413
+ gap: 12,
414
+ wrap: true,
415
+ children: list.map(({
416
+ font_class
417
+ }) => {
418
+ return /*#__PURE__*/jsx(Card, {
419
+ size: "small",
420
+ children: isColorful ? /*#__PURE__*/jsxs(Fragment, {
421
+ children: [/*#__PURE__*/jsx(Flex, {
422
+ justify: "center",
423
+ children: /*#__PURE__*/jsx(Icon, {
424
+ colorful: true,
425
+ type: font_class,
426
+ size: value
427
+ })
428
+ }), /*#__PURE__*/jsx(Flex, {
429
+ justify: "center",
430
+ children: /*#__PURE__*/jsx(Typography.Text, {
431
+ style: {
432
+ display: 'block',
433
+ width: '120px',
434
+ wordBreak: 'break-all'
435
+ },
436
+ copyable: {
437
+ text: '<Icon colorful type="' + font_class + '"/>'
438
+ },
439
+ children: font_class
440
+ })
441
+ })]
442
+ }) : /*#__PURE__*/jsxs(Fragment, {
443
+ children: [/*#__PURE__*/jsx(Flex, {
444
+ justify: "center",
445
+ children: /*#__PURE__*/jsx(Icon, {
446
+ type: font_class,
447
+ size: value,
448
+ fontClassName: fontClassName
449
+ })
450
+ }), /*#__PURE__*/jsx(Flex, {
451
+ justify: "center",
452
+ children: /*#__PURE__*/jsx(Typography.Text, {
453
+ style: {
454
+ display: 'block',
455
+ width: '120px',
456
+ wordBreak: 'break-all'
457
+ },
458
+ copyable: {
459
+ text: '<Icon type="' + font_class + '" fontClassName="' + fontClassName + '"/>'
460
+ },
461
+ children: font_class
462
+ })
463
+ })]
464
+ })
465
+ }, font_class);
466
+ })
467
+ })]
468
+ }, fontClassName);
469
+ })]
470
+ });
417
471
  };
418
472
 
419
473
  export { Example, ExamplePage, FontList, createEntry as default };