neko-ui 2.8.21 → 2.8.23
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/es/avatar/README.mdx +10 -0
- package/es/avatar/examples/basic.md +14 -0
- package/es/avatar/examples/group.md +57 -0
- package/es/avatar/examples/size.md +21 -0
- package/es/avatar/group.js +2 -2
- package/es/avatar/group.js.map +1 -1
- package/es/avatar/index.js +2 -2
- package/es/avatar/index.js.map +1 -1
- package/es/avatar/style.js +2 -2
- package/es/avatar/style.js.map +1 -1
- package/es/back-top/README.mdx +10 -0
- package/es/back-top/examples/basic.md +19 -0
- package/es/back-top/examples/mount.md +36 -0
- package/es/back-top/examples/target.md +46 -0
- package/es/back-top/index.js +1 -1
- package/es/back-top/index.js.map +1 -1
- package/es/basic-config/README.mdx +11 -0
- package/es/button/README.mdx +10 -0
- package/es/button/examples/basic.md +21 -0
- package/es/button/examples/block.md +33 -0
- package/es/button/examples/circle.md +21 -0
- package/es/button/examples/danger.md +23 -0
- package/es/button/examples/dashed.md +21 -0
- package/es/button/examples/disabled.md +35 -0
- package/es/button/examples/fill.md +21 -0
- package/es/button/examples/flat.md +21 -0
- package/es/button/examples/ghost.md +21 -0
- package/es/button/examples/icon.md +30 -0
- package/es/button/examples/link.md +21 -0
- package/es/button/examples/size.md +23 -0
- package/es/button/index.js +1 -1
- package/es/button/index.js.map +1 -1
- package/es/button/style.js +1 -0
- package/es/button/style.js.map +1 -1
- package/es/capture-screen/README.mdx +10 -0
- package/es/capture-screen/examples/basic.md +13 -0
- package/es/capture-screen/examples/custom-save.md +30 -0
- package/es/capture-screen/examples/preview.md +13 -0
- package/es/capture-screen/examples/recorder-save.md +13 -0
- package/es/capture-screen/index.js +1 -1
- package/es/capture-screen/index.js.map +1 -1
- package/es/carousel/README.mdx +10 -0
- package/es/carousel/examples/autoplay.md +21 -0
- package/es/carousel/examples/basic.md +23 -0
- package/es/carousel/examples/dots.md +23 -0
- package/es/carousel/examples/header.md +38 -0
- package/es/carousel/index.js +1 -1
- package/es/carousel/index.js.map +1 -1
- package/es/checkbox/README.mdx +10 -0
- package/es/checkbox/examples/basic.md +31 -0
- package/es/checkbox/examples/check-all.md +37 -0
- package/es/checkbox/examples/disabled-all.md +28 -0
- package/es/checkbox/examples/disabled-option.md +35 -0
- package/es/checkbox/examples/field-names.md +40 -0
- package/es/checkbox/examples/status.md +37 -0
- package/es/checkbox/examples/vertical.md +36 -0
- package/es/checkbox/index.js +1 -1
- package/es/checkbox/index.js.map +1 -1
- package/es/code/README.mdx +10 -0
- package/es/code/examples/basic.md +19 -0
- package/es/code/examples/diff.md +45 -0
- package/es/code/examples/line-number.md +18 -0
- package/es/code/examples/live-edit.md +20 -0
- package/es/code/examples/toolbar.md +18 -0
- package/es/code/index.js +2 -2
- package/es/code/index.js.map +1 -1
- package/es/code/worker.js.map +1 -1
- package/es/color-palette/README.mdx +10 -0
- package/es/color-palette/examples/default-value.md +25 -0
- package/es/color-palette/examples/hexa.md +13 -0
- package/es/color-palette/examples/hsla.md +13 -0
- package/es/color-palette/examples/rgba.md +13 -0
- package/es/color-palette/index.js +1 -1
- package/es/color-palette/index.js.map +1 -1
- package/es/color-picker/README.mdx +10 -0
- package/es/color-picker/examples/basic.md +12 -0
- package/es/color-picker/examples/default-value.md +20 -0
- package/es/color-picker/examples/size.md +17 -0
- package/es/color-picker/index.js +1 -1
- package/es/color-picker/index.js.map +1 -1
- package/es/cron/README.mdx +10 -0
- package/es/cron/begin-interval.js.map +1 -1
- package/es/cron/day.js.map +1 -1
- package/es/cron/examples/basic.md +19 -0
- package/es/cron/examples/card.md +12 -0
- package/es/cron/examples/show-cron.md +12 -0
- package/es/cron/hour.js +1 -1
- package/es/cron/hour.js.map +1 -1
- package/es/cron/index.js +1 -1
- package/es/cron/index.js.map +1 -1
- package/es/cron/item.js.map +1 -1
- package/es/cron/minute.js +1 -1
- package/es/cron/minute.js.map +1 -1
- package/es/cron/month.js +1 -1
- package/es/cron/month.js.map +1 -1
- package/es/cron/period.js.map +1 -1
- package/es/cron/second.js +1 -1
- package/es/cron/second.js.map +1 -1
- package/es/cron/some.js.map +1 -1
- package/es/date-picker/README.mdx +10 -0
- package/es/date-picker/date.js +1 -1
- package/es/date-picker/date.js.map +1 -1
- package/es/date-picker/dayjs.js +1 -1
- package/es/date-picker/dayjs.js.map +1 -1
- package/es/date-picker/examples/basic.md +24 -0
- package/es/date-picker/examples/date.md +13 -0
- package/es/date-picker/examples/disbaled.md +13 -0
- package/es/date-picker/examples/header.md +13 -0
- package/es/date-picker/examples/month.md +13 -0
- package/es/date-picker/examples/time.md +15 -0
- package/es/date-picker/examples/today.md +13 -0
- package/es/date-picker/examples/year.md +13 -0
- package/es/date-picker/index.js +1 -1
- package/es/date-picker/index.js.map +1 -1
- package/es/date-picker/month.js +1 -1
- package/es/date-picker/month.js.map +1 -1
- package/es/date-picker/panel.js +1 -1
- package/es/date-picker/panel.js.map +1 -1
- package/es/date-picker/time.js +1 -1
- package/es/date-picker/time.js.map +1 -1
- package/es/date-picker/year.js +1 -1
- package/es/date-picker/year.js.map +1 -1
- package/es/dropdown/README.mdx +10 -0
- package/es/dropdown/examples/arrow.md +59 -0
- package/es/dropdown/examples/basic.md +17 -0
- package/es/dropdown/examples/click.md +45 -0
- package/es/dropdown/examples/context-menu.md +66 -0
- package/es/dropdown/examples/field-names.md +44 -0
- package/es/dropdown/examples/icon.md +30 -0
- package/es/dropdown/examples/multiple.md +45 -0
- package/es/dropdown/examples/no-data.md +16 -0
- package/es/dropdown/examples/placement.md +59 -0
- package/es/dropdown/examples/toggle.md +36 -0
- package/es/dropdown/index.js +1 -1
- package/es/dropdown/index.js.map +1 -1
- package/es/empty/index.js.map +1 -1
- package/es/from-schema/index.js +1 -1
- package/es/from-schema/index.js.map +1 -1
- package/es/highlight-text/README.mdx +10 -0
- package/es/highlight-text/examples/basic.md +19 -0
- package/es/highlight-text/examples/mut.md +47 -0
- package/es/highlight-text/examples/not-hightlight.md +19 -0
- package/es/highlight-text/index.js +2 -2
- package/es/highlight-text/index.js.map +1 -1
- package/es/img/README.mdx +10 -0
- package/es/img/examples/basic.md +17 -0
- package/es/img/examples/close-mask.md +21 -0
- package/es/img/examples/disabled.md +16 -0
- package/es/img/examples/error.md +13 -0
- package/es/img/examples/esc.md +21 -0
- package/es/img/examples/open-change.md +25 -0
- package/es/img/index.js +1 -1
- package/es/img/index.js.map +1 -1
- package/es/img/lazy.js +1 -1
- package/es/img/lazy.js.map +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/input/README.mdx +10 -0
- package/es/input/examples/basic.md +31 -0
- package/es/input/examples/prefix&suffix.md +33 -0
- package/es/input/examples/size.md +21 -0
- package/es/input/examples/status.md +23 -0
- package/es/input/index.js +1 -1
- package/es/input/index.js.map +1 -1
- package/es/input-number/README.mdx +10 -0
- package/es/input-number/examples/basic.md +26 -0
- package/es/input-number/examples/formatter.md +36 -0
- package/es/input-number/examples/max-min.md +13 -0
- package/es/input-number/index.js.map +1 -1
- package/es/katex/README.mdx +42 -0
- package/es/katex/examples/block.md +25 -0
- package/es/katex/examples/inline.md +19 -0
- package/es/md/README.mdx +10 -0
- package/es/md/examples/in-children.md +23 -0
- package/es/md/examples/in-text.md +32 -0
- package/es/md/examples/math.md +36 -0
- package/es/md/index.js +1 -1
- package/es/md/index.js.map +1 -1
- package/es/menu/README.mdx +10 -0
- package/es/menu/examples/basic.md +17 -0
- package/es/menu/examples/field-names.md +42 -0
- package/es/menu/examples/icon.md +125 -0
- package/es/menu/examples/multiple.md +42 -0
- package/es/menu/index.js +1 -1
- package/es/menu/index.js.map +1 -1
- package/es/modal/README.mdx +10 -0
- package/es/modal/examples/basic.md +56 -0
- package/es/modal/examples/close-icon.md +57 -0
- package/es/modal/examples/esc-closable.md +64 -0
- package/es/modal/examples/mask-blur.md +56 -0
- package/es/modal/examples/mask-closable.md +64 -0
- package/es/modal/index.js +1 -1
- package/es/modal/index.js.map +1 -1
- package/es/notification/README.mdx +11 -0
- package/es/notification/examples/basic.md +35 -0
- package/es/notification/examples/close.md +35 -0
- package/es/notification/examples/type.md +84 -0
- package/es/notification/examples/update.md +52 -0
- package/es/notification/index.js.map +1 -1
- package/es/notification/notification.js +1 -1
- package/es/notification/notification.js.map +1 -1
- package/es/pagination/README.mdx +10 -0
- package/es/pagination/examples/basic.md +13 -0
- package/es/pagination/examples/onchange.md +29 -0
- package/es/pagination/examples/size.md +23 -0
- package/es/pagination/examples/total-text.md +42 -0
- package/es/pagination/index.js +1 -1
- package/es/pagination/index.js.map +1 -1
- package/es/popover/README.mdx +10 -0
- package/es/popover/examples/basic.md +35 -0
- package/es/popover/examples/click.md +15 -0
- package/es/popover/examples/context-menu.md +58 -0
- package/es/popover/examples/controlled.md +47 -0
- package/es/popover/index.js +1 -1
- package/es/popover/index.js.map +1 -1
- package/es/prism/css.js.map +1 -1
- package/es/prism/index.js.map +1 -1
- package/es/provider/README.mdx +10 -0
- package/es/provider/examples/scheme.md +14 -0
- package/es/provider/index.js.map +1 -1
- package/es/radio/README.mdx +10 -0
- package/es/radio/examples/basic.md +19 -0
- package/es/radio/examples/disabled-option.md +19 -0
- package/es/radio/examples/disabled.md +19 -0
- package/es/radio/examples/field-names.md +39 -0
- package/es/radio/examples/layout-vertical.md +19 -0
- package/es/radio/examples/status.md +31 -0
- package/es/radio/index.js +1 -1
- package/es/radio/index.js.map +1 -1
- package/es/segmented/README.mdx +10 -0
- package/es/segmented/examples/basic.md +18 -0
- package/es/segmented/examples/custom-field-names.md +43 -0
- package/es/segmented/examples/disabled-option.md +29 -0
- package/es/segmented/examples/disabled.md +18 -0
- package/es/segmented/examples/icon.md +28 -0
- package/es/segmented/examples/options.md +21 -0
- package/es/segmented/index.js +2 -2
- package/es/segmented/index.js.map +1 -1
- package/es/select/README.mdx +10 -0
- package/es/select/examples/basic.md +44 -0
- package/es/select/examples/disabled-option.md +21 -0
- package/es/select/examples/disabled.md +24 -0
- package/es/select/examples/field-names.md +40 -0
- package/es/select/examples/item-suffix.md +84 -0
- package/es/select/examples/multiple.md +61 -0
- package/es/select/examples/no-data.md +12 -0
- package/es/select/examples/prefix-icon.md +74 -0
- package/es/select/index.js +1 -1
- package/es/select/index.js.map +1 -1
- package/es/skeleton/README.mdx +10 -0
- package/es/skeleton/examples/animation.md +13 -0
- package/es/skeleton/examples/avatar.md +13 -0
- package/es/skeleton/examples/basic.md +12 -0
- package/es/skeleton/examples/rows.md +13 -0
- package/es/skeleton/examples/title.md +12 -0
- package/es/skeleton/index.js +3 -3
- package/es/skeleton/index.js.map +1 -1
- package/es/spin/README.mdx +10 -0
- package/es/spin/examples/basic.md +67 -0
- package/es/spin/index.js +4 -4
- package/es/spin/index.js.map +1 -1
- package/es/switch/README.mdx +10 -0
- package/es/switch/examples/basic.md +24 -0
- package/es/switch/examples/checked-text.md +17 -0
- package/es/switch/examples/disabled.md +15 -0
- package/es/switch/examples/loading.md +17 -0
- package/es/switch/index.js +1 -1
- package/es/switch/index.js.map +1 -1
- package/es/table/README.mdx +10 -0
- package/es/table/examples/basic.md +29 -0
- package/es/table/examples/key.md +29 -0
- package/es/table/examples/order.md +29 -0
- package/es/table/examples/pagination.md +67 -0
- package/es/table/examples/render.md +92 -0
- package/es/table/examples/size.md +52 -0
- package/es/table/examples/summary.md +40 -0
- package/es/table/index.js +1 -1
- package/es/table/index.js.map +1 -1
- package/es/tabs/README.mdx +10 -0
- package/es/tabs/examples/add-remove.md +115 -0
- package/es/tabs/examples/animated.md +33 -0
- package/es/tabs/examples/basic.md +32 -0
- package/es/tabs/examples/card.md +33 -0
- package/es/tabs/examples/center.md +33 -0
- package/es/tabs/examples/disabled-tab.md +34 -0
- package/es/tabs/examples/disabled.md +33 -0
- package/es/tabs/examples/extra.md +65 -0
- package/es/tabs/index.js +2 -2
- package/es/tabs/index.js.map +1 -1
- package/es/tag/README.mdx +10 -0
- package/es/tag/examples/basic.md +28 -0
- package/es/tag/examples/bordered.md +19 -0
- package/es/tag/examples/color.md +25 -0
- package/es/tag/examples/icon.md +21 -0
- package/es/tag/examples/type.md +19 -0
- package/es/tag/index.js +3 -3
- package/es/tag/index.js.map +1 -1
- package/es/theme/README.mdx +10 -0
- package/es/theme/examples/colors.md +123 -0
- package/es/theme/examples/theme.md +19 -0
- package/es/theme/index.js +1 -1
- package/es/theme/index.js.map +1 -1
- package/es/tree/README.mdx +10 -0
- package/es/tree/examples/basic.md +108 -0
- package/es/tree/examples/custom-render.md +115 -0
- package/es/tree/examples/direction.md +100 -0
- package/es/tree/examples/field-names.md +114 -0
- package/es/tree/examples/multiple.md +117 -0
- package/es/tree/examples/readonly.md +90 -0
- package/es/tree/examples/render-tree-string1.md +70 -0
- package/es/tree/examples/render-tree-string2.md +52 -0
- package/es/tree/examples/schema.md +130 -0
- package/es/tree/examples/size.md +125 -0
- package/es/tree/examples/toggle.md +71 -0
- package/es/tree/index.js +1 -1
- package/es/tree/index.js.map +1 -1
- package/es/tree/register.js.map +1 -1
- package/es/typography/README.mdx +10 -0
- package/es/typography/examples/basic.md +27 -0
- package/es/typography/examples/tag.md +25 -0
- package/es/typography/examples/truncated.md +17 -0
- package/es/typography/index.js +3 -3
- package/es/typography/index.js.map +1 -1
- package/eslint.config.mjs +9 -0
- package/lib/avatar/README.mdx +10 -0
- package/lib/avatar/examples/basic.md +14 -0
- package/lib/avatar/examples/group.md +57 -0
- package/lib/avatar/examples/size.md +21 -0
- package/lib/avatar/group.js.map +1 -1
- package/lib/avatar/index.js +2 -2
- package/lib/avatar/index.js.map +1 -1
- package/lib/avatar/style.js +2 -2
- package/lib/avatar/style.js.map +1 -1
- package/lib/back-top/README.mdx +10 -0
- package/lib/back-top/examples/basic.md +19 -0
- package/lib/back-top/examples/mount.md +36 -0
- package/lib/back-top/examples/target.md +46 -0
- package/lib/back-top/index.js +1 -1
- package/lib/back-top/index.js.map +1 -1
- package/lib/basic-config/README.mdx +11 -0
- package/lib/button/README.mdx +10 -0
- package/lib/button/examples/basic.md +21 -0
- package/lib/button/examples/block.md +33 -0
- package/lib/button/examples/circle.md +21 -0
- package/lib/button/examples/danger.md +23 -0
- package/lib/button/examples/dashed.md +21 -0
- package/lib/button/examples/disabled.md +35 -0
- package/lib/button/examples/fill.md +21 -0
- package/lib/button/examples/flat.md +21 -0
- package/lib/button/examples/ghost.md +21 -0
- package/lib/button/examples/icon.md +30 -0
- package/lib/button/examples/link.md +21 -0
- package/lib/button/examples/size.md +23 -0
- package/lib/button/index.js +1 -1
- package/lib/button/index.js.map +1 -1
- package/lib/button/style.js +1 -0
- package/lib/button/style.js.map +1 -1
- package/lib/capture-screen/README.mdx +10 -0
- package/lib/capture-screen/examples/basic.md +13 -0
- package/lib/capture-screen/examples/custom-save.md +30 -0
- package/lib/capture-screen/examples/preview.md +13 -0
- package/lib/capture-screen/examples/recorder-save.md +13 -0
- package/lib/capture-screen/index.js +1 -1
- package/lib/capture-screen/index.js.map +1 -1
- package/lib/carousel/README.mdx +10 -0
- package/lib/carousel/examples/autoplay.md +21 -0
- package/lib/carousel/examples/basic.md +23 -0
- package/lib/carousel/examples/dots.md +23 -0
- package/lib/carousel/examples/header.md +38 -0
- package/lib/carousel/index.js +1 -1
- package/lib/carousel/index.js.map +1 -1
- package/lib/checkbox/README.mdx +10 -0
- package/lib/checkbox/examples/basic.md +31 -0
- package/lib/checkbox/examples/check-all.md +37 -0
- package/lib/checkbox/examples/disabled-all.md +28 -0
- package/lib/checkbox/examples/disabled-option.md +35 -0
- package/lib/checkbox/examples/field-names.md +40 -0
- package/lib/checkbox/examples/status.md +37 -0
- package/lib/checkbox/examples/vertical.md +36 -0
- package/lib/checkbox/index.js +1 -1
- package/lib/checkbox/index.js.map +1 -1
- package/lib/code/README.mdx +10 -0
- package/lib/code/examples/basic.md +19 -0
- package/lib/code/examples/diff.md +45 -0
- package/lib/code/examples/line-number.md +18 -0
- package/lib/code/examples/live-edit.md +20 -0
- package/lib/code/examples/toolbar.md +18 -0
- package/lib/code/index.js +2 -2
- package/lib/code/index.js.map +1 -1
- package/lib/code/worker.js.map +1 -1
- package/lib/color-palette/README.mdx +10 -0
- package/lib/color-palette/examples/default-value.md +25 -0
- package/lib/color-palette/examples/hexa.md +13 -0
- package/lib/color-palette/examples/hsla.md +13 -0
- package/lib/color-palette/examples/rgba.md +13 -0
- package/lib/color-palette/index.js +1 -1
- package/lib/color-palette/index.js.map +1 -1
- package/lib/color-picker/README.mdx +10 -0
- package/lib/color-picker/examples/basic.md +12 -0
- package/lib/color-picker/examples/default-value.md +20 -0
- package/lib/color-picker/examples/size.md +17 -0
- package/lib/color-picker/index.js +1 -1
- package/lib/color-picker/index.js.map +1 -1
- package/lib/cron/README.mdx +10 -0
- package/lib/cron/begin-interval.js.map +1 -1
- package/lib/cron/day.js.map +1 -1
- package/lib/cron/examples/basic.md +19 -0
- package/lib/cron/examples/card.md +12 -0
- package/lib/cron/examples/show-cron.md +12 -0
- package/lib/cron/hour.js +1 -1
- package/lib/cron/hour.js.map +1 -1
- package/lib/cron/index.js.map +1 -1
- package/lib/cron/item.js.map +1 -1
- package/lib/cron/minute.js +1 -1
- package/lib/cron/minute.js.map +1 -1
- package/lib/cron/month.js +1 -1
- package/lib/cron/month.js.map +1 -1
- package/lib/cron/period.js.map +1 -1
- package/lib/cron/second.js +1 -1
- package/lib/cron/second.js.map +1 -1
- package/lib/cron/some.js.map +1 -1
- package/lib/date-picker/README.mdx +10 -0
- package/lib/date-picker/date.js.map +1 -1
- package/lib/date-picker/dayjs.js +1 -1
- package/lib/date-picker/dayjs.js.map +1 -1
- package/lib/date-picker/examples/basic.md +24 -0
- package/lib/date-picker/examples/date.md +13 -0
- package/lib/date-picker/examples/disbaled.md +13 -0
- package/lib/date-picker/examples/header.md +13 -0
- package/lib/date-picker/examples/month.md +13 -0
- package/lib/date-picker/examples/time.md +15 -0
- package/lib/date-picker/examples/today.md +13 -0
- package/lib/date-picker/examples/year.md +13 -0
- package/lib/date-picker/index.js +1 -1
- package/lib/date-picker/index.js.map +1 -1
- package/lib/date-picker/month.js.map +1 -1
- package/lib/date-picker/panel.js +1 -1
- package/lib/date-picker/panel.js.map +1 -1
- package/lib/date-picker/time.js.map +1 -1
- package/lib/date-picker/year.js.map +1 -1
- package/lib/dropdown/README.mdx +10 -0
- package/lib/dropdown/examples/arrow.md +59 -0
- package/lib/dropdown/examples/basic.md +17 -0
- package/lib/dropdown/examples/click.md +45 -0
- package/lib/dropdown/examples/context-menu.md +66 -0
- package/lib/dropdown/examples/field-names.md +44 -0
- package/lib/dropdown/examples/icon.md +30 -0
- package/lib/dropdown/examples/multiple.md +45 -0
- package/lib/dropdown/examples/no-data.md +16 -0
- package/lib/dropdown/examples/placement.md +59 -0
- package/lib/dropdown/examples/toggle.md +36 -0
- package/lib/dropdown/index.js +1 -1
- package/lib/dropdown/index.js.map +1 -1
- package/lib/empty/index.js.map +1 -1
- package/lib/from-schema/index.js +1 -1
- package/lib/from-schema/index.js.map +1 -1
- package/lib/highlight-text/README.mdx +10 -0
- package/lib/highlight-text/examples/basic.md +19 -0
- package/lib/highlight-text/examples/mut.md +47 -0
- package/lib/highlight-text/examples/not-hightlight.md +19 -0
- package/lib/highlight-text/index.js.map +1 -1
- package/lib/img/README.mdx +10 -0
- package/lib/img/examples/basic.md +17 -0
- package/lib/img/examples/close-mask.md +21 -0
- package/lib/img/examples/disabled.md +16 -0
- package/lib/img/examples/error.md +13 -0
- package/lib/img/examples/esc.md +21 -0
- package/lib/img/examples/open-change.md +25 -0
- package/lib/img/index.js +1 -1
- package/lib/img/index.js.map +1 -1
- package/lib/img/lazy.js +1 -1
- package/lib/img/lazy.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/input/README.mdx +10 -0
- package/lib/input/examples/basic.md +31 -0
- package/lib/input/examples/prefix&suffix.md +33 -0
- package/lib/input/examples/size.md +21 -0
- package/lib/input/examples/status.md +23 -0
- package/lib/input/index.js +1 -1
- package/lib/input/index.js.map +1 -1
- package/lib/input-number/README.mdx +10 -0
- package/lib/input-number/examples/basic.md +26 -0
- package/lib/input-number/examples/formatter.md +36 -0
- package/lib/input-number/examples/max-min.md +13 -0
- package/lib/input-number/index.js.map +1 -1
- package/lib/katex/README.mdx +42 -0
- package/lib/katex/examples/block.md +25 -0
- package/lib/katex/examples/inline.md +19 -0
- package/lib/md/README.mdx +10 -0
- package/lib/md/examples/in-children.md +23 -0
- package/lib/md/examples/in-text.md +32 -0
- package/lib/md/examples/math.md +36 -0
- package/lib/md/index.js +1 -1
- package/lib/md/index.js.map +1 -1
- package/lib/menu/README.mdx +10 -0
- package/lib/menu/examples/basic.md +17 -0
- package/lib/menu/examples/field-names.md +42 -0
- package/lib/menu/examples/icon.md +125 -0
- package/lib/menu/examples/multiple.md +42 -0
- package/lib/menu/index.js +1 -1
- package/lib/menu/index.js.map +1 -1
- package/lib/modal/README.mdx +10 -0
- package/lib/modal/examples/basic.md +56 -0
- package/lib/modal/examples/close-icon.md +57 -0
- package/lib/modal/examples/esc-closable.md +64 -0
- package/lib/modal/examples/mask-blur.md +56 -0
- package/lib/modal/examples/mask-closable.md +64 -0
- package/lib/modal/index.js.map +1 -1
- package/lib/notification/README.mdx +11 -0
- package/lib/notification/examples/basic.md +35 -0
- package/lib/notification/examples/close.md +35 -0
- package/lib/notification/examples/type.md +84 -0
- package/lib/notification/examples/update.md +52 -0
- package/lib/notification/index.js.map +1 -1
- package/lib/notification/notification.js +1 -1
- package/lib/notification/notification.js.map +1 -1
- package/lib/pagination/README.mdx +10 -0
- package/lib/pagination/examples/basic.md +13 -0
- package/lib/pagination/examples/onchange.md +29 -0
- package/lib/pagination/examples/size.md +23 -0
- package/lib/pagination/examples/total-text.md +42 -0
- package/lib/pagination/index.js +1 -1
- package/lib/pagination/index.js.map +1 -1
- package/lib/popover/README.mdx +10 -0
- package/lib/popover/examples/basic.md +35 -0
- package/lib/popover/examples/click.md +15 -0
- package/lib/popover/examples/context-menu.md +58 -0
- package/lib/popover/examples/controlled.md +47 -0
- package/lib/popover/index.js +1 -1
- package/lib/popover/index.js.map +1 -1
- package/lib/prism/css.js.map +1 -1
- package/lib/prism/index.js.map +1 -1
- package/lib/provider/README.mdx +10 -0
- package/lib/provider/examples/scheme.md +14 -0
- package/lib/provider/index.js.map +1 -1
- package/lib/radio/README.mdx +10 -0
- package/lib/radio/examples/basic.md +19 -0
- package/lib/radio/examples/disabled-option.md +19 -0
- package/lib/radio/examples/disabled.md +19 -0
- package/lib/radio/examples/field-names.md +39 -0
- package/lib/radio/examples/layout-vertical.md +19 -0
- package/lib/radio/examples/status.md +31 -0
- package/lib/radio/index.js +1 -1
- package/lib/radio/index.js.map +1 -1
- package/lib/segmented/README.mdx +10 -0
- package/lib/segmented/examples/basic.md +18 -0
- package/lib/segmented/examples/custom-field-names.md +43 -0
- package/lib/segmented/examples/disabled-option.md +29 -0
- package/lib/segmented/examples/disabled.md +18 -0
- package/lib/segmented/examples/icon.md +28 -0
- package/lib/segmented/examples/options.md +21 -0
- package/lib/segmented/index.js +2 -2
- package/lib/segmented/index.js.map +1 -1
- package/lib/select/README.mdx +10 -0
- package/lib/select/examples/basic.md +44 -0
- package/lib/select/examples/disabled-option.md +21 -0
- package/lib/select/examples/disabled.md +24 -0
- package/lib/select/examples/field-names.md +40 -0
- package/lib/select/examples/item-suffix.md +84 -0
- package/lib/select/examples/multiple.md +61 -0
- package/lib/select/examples/no-data.md +12 -0
- package/lib/select/examples/prefix-icon.md +74 -0
- package/lib/select/index.js +1 -1
- package/lib/select/index.js.map +1 -1
- package/lib/skeleton/README.mdx +10 -0
- package/lib/skeleton/examples/animation.md +13 -0
- package/lib/skeleton/examples/avatar.md +13 -0
- package/lib/skeleton/examples/basic.md +12 -0
- package/lib/skeleton/examples/rows.md +13 -0
- package/lib/skeleton/examples/title.md +12 -0
- package/lib/skeleton/index.js.map +1 -1
- package/lib/spin/README.mdx +10 -0
- package/lib/spin/examples/basic.md +67 -0
- package/lib/spin/index.js +3 -3
- package/lib/spin/index.js.map +1 -1
- package/lib/switch/README.mdx +10 -0
- package/lib/switch/examples/basic.md +24 -0
- package/lib/switch/examples/checked-text.md +17 -0
- package/lib/switch/examples/disabled.md +15 -0
- package/lib/switch/examples/loading.md +17 -0
- package/lib/switch/index.js +1 -1
- package/lib/switch/index.js.map +1 -1
- package/lib/table/README.mdx +10 -0
- package/lib/table/examples/basic.md +29 -0
- package/lib/table/examples/key.md +29 -0
- package/lib/table/examples/order.md +29 -0
- package/lib/table/examples/pagination.md +67 -0
- package/lib/table/examples/render.md +92 -0
- package/lib/table/examples/size.md +52 -0
- package/lib/table/examples/summary.md +40 -0
- package/lib/table/index.js +1 -1
- package/lib/table/index.js.map +1 -1
- package/lib/tabs/README.mdx +10 -0
- package/lib/tabs/examples/add-remove.md +115 -0
- package/lib/tabs/examples/animated.md +33 -0
- package/lib/tabs/examples/basic.md +32 -0
- package/lib/tabs/examples/card.md +33 -0
- package/lib/tabs/examples/center.md +33 -0
- package/lib/tabs/examples/disabled-tab.md +34 -0
- package/lib/tabs/examples/disabled.md +33 -0
- package/lib/tabs/examples/extra.md +65 -0
- package/lib/tabs/index.js +2 -2
- package/lib/tabs/index.js.map +1 -1
- package/lib/tag/README.mdx +10 -0
- package/lib/tag/examples/basic.md +28 -0
- package/lib/tag/examples/bordered.md +19 -0
- package/lib/tag/examples/color.md +25 -0
- package/lib/tag/examples/icon.md +21 -0
- package/lib/tag/examples/type.md +19 -0
- package/lib/tag/index.js +3 -3
- package/lib/tag/index.js.map +1 -1
- package/lib/theme/README.mdx +10 -0
- package/lib/theme/examples/colors.md +123 -0
- package/lib/theme/examples/theme.md +19 -0
- package/lib/theme/index.js +1 -1
- package/lib/theme/index.js.map +1 -1
- package/lib/tree/README.mdx +10 -0
- package/lib/tree/examples/basic.md +108 -0
- package/lib/tree/examples/custom-render.md +115 -0
- package/lib/tree/examples/direction.md +100 -0
- package/lib/tree/examples/field-names.md +114 -0
- package/lib/tree/examples/multiple.md +117 -0
- package/lib/tree/examples/readonly.md +90 -0
- package/lib/tree/examples/render-tree-string1.md +70 -0
- package/lib/tree/examples/render-tree-string2.md +52 -0
- package/lib/tree/examples/schema.md +130 -0
- package/lib/tree/examples/size.md +125 -0
- package/lib/tree/examples/toggle.md +71 -0
- package/lib/tree/index.js +1 -1
- package/lib/tree/index.js.map +1 -1
- package/lib/tree/register.js.map +1 -1
- package/lib/typography/README.mdx +10 -0
- package/lib/typography/examples/basic.md +27 -0
- package/lib/typography/examples/tag.md +25 -0
- package/lib/typography/examples/truncated.md +17 -0
- package/lib/typography/index.js.map +1 -1
- package/package.json +18 -18
- package/types/avatar/group.d.ts +1 -1
- package/types/back-top/index.d.ts +1 -1
- package/types/capture-screen/index.d.ts +1 -1
- package/types/color-palette/index.d.ts +1 -1
- package/types/color-picker/index.d.ts +1 -1
- package/types/cron/begin-interval.d.ts +3 -3
- package/types/cron/index.d.ts +5 -5
- package/types/cron/item.d.ts +4 -4
- package/types/cron/period.d.ts +3 -3
- package/types/cron/some.d.ts +3 -3
- package/types/date-picker/date.d.ts +2 -2
- package/types/date-picker/index.d.ts +2 -2
- package/types/date-picker/month.d.ts +2 -2
- package/types/date-picker/panel.d.ts +3 -3
- package/types/date-picker/time.d.ts +2 -2
- package/types/date-picker/year.d.ts +2 -2
- package/types/dropdown/index.d.ts +1 -1
- package/types/empty/index.d.ts +1 -1
- package/types/from-schema/index.d.ts +4 -4
- package/types/index.d.ts +12 -12
- package/types/md/index.d.ts +1 -1
- package/types/modal/index.d.ts +1 -1
- package/types/notification/index.d.ts +1 -1
- package/types/pagination/index.d.ts +1 -1
- package/types/provider/index.d.ts +1 -1
- package/types/segmented/index.d.ts +1 -1
- package/types/select/index.d.ts +1 -1
- package/types/table/index.d.ts +1 -1
- package/types/tabs/index.d.ts +1 -1
- package/types/tree/index.d.ts +1 -1
- package/umd/assets/svg/favicon.svg +1 -0
- package/umd/index.js +2 -2
- package/umd/js/46e8f96158e59015.js +1 -0
package/lib/input/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../components/input/index.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../components/input/index.tsx"],"sourcesContent":["import { createEffect, createMemo, createSignal, mergeProps, Show } from 'solid-js';\nimport { isFunction } from '@moneko/common';\nimport { css, cx } from '@moneko/css';\nimport { customElement } from 'solid-element';\n\nimport type { BasicConfig, CustomElement } from '..';\nimport theme from '../theme';\n\nimport { style } from './style';\n\nexport interface InputProps {\n /** 自定义类名 */\n class?: string;\n /** 自定义样式表 */\n css?: string;\n /** 前缀 */\n prefixIcon?: JSX.Element;\n /** 后缀 */\n suffixIcon?: JSX.Element;\n /** 大写锁定图标, 可以结合密码输入框使用\n * @since 2.5.2\n */\n capsLockIcon?: JSX.Element;\n /** 禁用 */\n disabled?: boolean;\n /** 自动完成 */\n autoComplete?: string;\n /** 占位文本 */\n placeholder?: string;\n /** 组件尺寸\n * @default 'normal'\n */\n size?: BasicConfig['size'];\n /** 描述 */\n label?: JSX.Element;\n /** 状态 */\n status?: 'error' | 'warning' | 'success';\n /** 类型\n * @default 'text'\n */\n type?: 'email' | 'hidden' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'url';\n /** HTML attribute: accept */\n accept?: string;\n /** 值 */\n value?: string | number;\n /** 默认值 */\n defaultValue?: string | number;\n /** 值变更时触发的函数 */\n onChange?: (value: InputProps['value']) => void;\n onKeyDown?(e: KeyboardEvent): void;\n onMouseDown?(e: MouseEvent): void;\n onFocus?(e: FocusEvent): void;\n onBlur?(e: FocusEvent): void;\n onKeyUp?(e: KeyboardEvent): void;\n /** 指定输入框展示值的格式 */\n formatter?: (value?: InputProps['value']) => InputProps['value'];\n /** 搭配 formatter 使用, 将转换后的值转回原来的值 */\n parser?: (value?: InputProps['value']) => InputProps['value'];\n}\n\nfunction Input(props: InputProps) {\n const { baseStyle } = theme;\n let inputRef: HTMLInputElement | undefined;\n const [x, setX] = createSignal<string>();\n const [capsLock, setCapsLock] = createSignal(false);\n\n function parserValue(val: InputProps['value']) {\n if (props.parser) {\n return isFunction(props.parser) ? props.parser(val) : props.parser;\n } else if (props.type === 'number' && typeof val === 'string') {\n const num = val.replace(/[^\\d]/g, '');\n\n return num.length ? parseFloat(num) : void 0;\n }\n return val;\n }\n\n function handleInput(e: Event & { target?: HTMLInputElement }) {\n props.onChange?.(parserValue(e.target?.value));\n }\n function handleMouseDown(e: MouseEvent) {\n props.onMouseDown?.(e);\n }\n function handleKeyDown(e: KeyboardEvent) {\n if (props.capsLockIcon) {\n setCapsLock(e.getModifierState('CapsLock'));\n }\n props.onKeyDown?.(e);\n }\n function handleBlur(e: FocusEvent) {\n props.onBlur?.(e);\n }\n function handleKeyUp(e: KeyboardEvent) {\n props.onKeyUp?.(e);\n }\n\n const value = createMemo(() => {\n if (props.formatter) {\n return isFunction(props.formatter) ? props.formatter(props.value) : props.formatter;\n }\n return props.value;\n });\n\n createEffect(() => {\n if (props.label) {\n setX(`.label {--x: ${inputRef?.offsetLeft || 0}px;opacity:1;}`);\n }\n });\n\n return (\n <>\n <style textContent={baseStyle()} />\n <style textContent={style} />\n <style textContent={x()} />\n <Show when={props.css}>\n <style textContent={css(props.css)} />\n </Show>\n <fieldset\n class={cx('fieldset', props.size, props.status, props.class)}\n disabled={props.disabled}\n >\n <Show when={props.prefixIcon}>\n <span class=\"prefix\">{props.prefixIcon}</span>\n </Show>\n <input\n ref={inputRef}\n class=\"input\"\n part=\"input\"\n onChange={handleInput}\n type={props.type}\n value={value()}\n autocomplete={props.autoComplete}\n accept={props.accept}\n placeholder={props.placeholder}\n onMouseDown={handleMouseDown}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onBlur={handleBlur}\n />\n <Show when={props.label}>\n <label class=\"label\">{props.label}</label>\n </Show>\n <Show when={props.capsLockIcon && capsLock()}>\n <span class=\"caps-lock\">{props.capsLockIcon}</span>\n </Show>\n <Show when={props.suffixIcon}>\n <span class=\"suffix\">{props.suffixIcon}</span>\n </Show>\n </fieldset>\n </>\n );\n}\n\nexport type InputElement = CustomElement<InputProps>;\n\nexport const defaultInportProps = {\n class: void 0,\n css: void 0,\n suffixIcon: void 0,\n prefixIcon: void 0,\n capsLockIcon: void 0,\n size: void 0,\n disabled: void 0,\n status: void 0,\n type: void 0,\n label: void 0,\n value: void 0,\n defaultValue: void 0,\n formatter: void 0,\n parser: void 0,\n onChange: void 0,\n onMouseDown: void 0,\n onKeyDown: void 0,\n accept: void 0,\n autoComplete: void 0,\n placeholder: '请输入',\n};\n\ncustomElement<InputProps>('n-input', defaultInportProps, (_, opt) => {\n const el = opt.element;\n const props = mergeProps(\n {\n css: el.css,\n size: el.size || 'normal',\n value: el.value || el.defaultValue || '',\n type: el.type || 'text',\n onChange(val?: number | string) {\n el.dispatchEvent(\n new CustomEvent('change', {\n detail: val,\n }),\n );\n },\n },\n _,\n );\n\n return <Input {...props} />;\n});\n\nexport default Input;\n"],"names":["defaultInportProps","Input","props","inputRef","baseStyle","theme","x","setX","createSignal","capsLock","setCapsLock","handleInput","e","onChange","parserValue","val","parser","isFunction","type","num","replace","length","parseFloat","target","value","handleMouseDown","onMouseDown","handleKeyDown","capsLockIcon","getModifierState","onKeyDown","handleBlur","onBlur","handleKeyUp","onKeyUp","createMemo","formatter","createEffect","label","offsetLeft","style","Show","css","prefixIcon","suffixIcon","cx","size","status","class","disabled","autoComplete","accept","placeholder","defaultValue","customElement","_","opt","el","element","mergeProps","dispatchEvent","CustomEvent","detail"],"mappings":"+JAwMA,OAAqB,mBAArB,GA7CaA,kBAAkB,mBAAlBA,+CA3J4D,wBAC9C,4CACH,yBACM,6BAGZ,uBAEI,yWAoDtB,SAASC,EAAMC,CAAiB,MAE1BC,EADJ,GAAM,CAAEC,UAAAA,CAAS,CAAE,CAAGC,SAAK,CAErB,CAACC,EAAGC,EAAK,CAAGC,GAAAA,cAAY,IACxB,CAACC,EAAUC,EAAY,CAAGF,GAAAA,cAAY,EAAC,CAAA,GAa7C,SAASG,EAAYC,CAAwC,EAC3DV,EAAMW,QAAQ,GAAGC,AAZnB,SAAq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ACF,EACAwC,GAGF,4BAAQtD,EAAUC,EACpB,SAEA,EAAeD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 基本使用
|
|
3
|
+
description: 可以通过 `value` 设置值, 通过 `change` 事件获取值变更的消息
|
|
4
|
+
order: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<n-input-number label="获取焦点时按住鼠标左键开始拖动试试" value="0"></n-input-number>
|
|
9
|
+
<script>
|
|
10
|
+
const el = container.querySelector('n-input-number');
|
|
11
|
+
|
|
12
|
+
el.onchange = function (e) {
|
|
13
|
+
console.log('html', e.detail);
|
|
14
|
+
};
|
|
15
|
+
</script>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```jsx
|
|
19
|
+
<n-input-number
|
|
20
|
+
label="获取焦点时按住鼠标左键开始拖动试试"
|
|
21
|
+
value={0}
|
|
22
|
+
onChange={(e) => {
|
|
23
|
+
console.log('jsx', e.detail);
|
|
24
|
+
}}
|
|
25
|
+
/>
|
|
26
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 自定义格式
|
|
3
|
+
description: 通过 `formatter` 和 `parser` 来自定义输入栏显示内容
|
|
4
|
+
order: 2
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<n-input-number label="完成度" min="0" max="1" step="0.01"></n-input-number>
|
|
9
|
+
<script>
|
|
10
|
+
const el = container.querySelector('n-input-number');
|
|
11
|
+
|
|
12
|
+
el.formatter = function (v = 0) {
|
|
13
|
+
return `${Number((v * 100).toFixed(2))}%`;
|
|
14
|
+
};
|
|
15
|
+
el.parser = function (v = '') {
|
|
16
|
+
return Number(v.replace(/%$/, '') || '0') / 100;
|
|
17
|
+
};
|
|
18
|
+
</script>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
<n-input-number
|
|
23
|
+
label="完成度"
|
|
24
|
+
min={0}
|
|
25
|
+
max={1}
|
|
26
|
+
step={0.01}
|
|
27
|
+
formatter={() =>
|
|
28
|
+
(v = 0) =>
|
|
29
|
+
`${Number((v * 100).toFixed(2))}%`
|
|
30
|
+
}
|
|
31
|
+
parser={() =>
|
|
32
|
+
(v = '0%') =>
|
|
33
|
+
Number(v.replace(/%$/, '')) / 100
|
|
34
|
+
}
|
|
35
|
+
/>
|
|
36
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 最大值 & 最小值
|
|
3
|
+
description: 通过设置 `min` 来约束最小值; 通过设置 `max` 来约束最大值
|
|
4
|
+
order: 3
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<n-input-number label="范围" placeholder="请输入0~100以内的数值" min="0" max="100"></n-input-number>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
<n-input-number label="范围" placeholder="请输入0~100以内的数值" min={0} max={100} />
|
|
13
|
+
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../components/input-number/index.tsx"],"sourcesContent":["import { createEffect, createSignal, mergeProps, onCleanup } from 'solid-js';\nimport { passiveSupported } from '@moneko/common';\nimport { css, cx } from '@moneko/css';\nimport { customElement } from 'solid-element';\nimport
|
|
1
|
+
{"version":3,"sources":["../../components/input-number/index.tsx"],"sourcesContent":["import { createEffect, createSignal, mergeProps, onCleanup } from 'solid-js';\nimport { passiveSupported } from '@moneko/common';\nimport { css, cx } from '@moneko/css';\nimport { customElement } from 'solid-element';\n\nimport type { CustomElement, InputProps } from '..';\nimport Input, { defaultInportProps } from '../input';\n\nconst style = css`\n /** 隐藏原生加减控件 */\n .number[type='number'] {\n appearance: textfield;\n }\n\n .number[type='number']::-webkit-inner-spin-button,\n .number[type='number']::-webkit-outer-spin-button {\n appearance: none;\n }\n`;\n\n/** API\n * @since 2.0.0\n */\nexport interface InputNumberProps extends Omit<InputProps, 'value' | 'defaultValue' | 'onChange'> {\n /** 值 */\n value?: number;\n /** 默认值\n * @default 0\n */\n defaultValue?: number;\n /** 最小值\n * @default Number.MIN_SAFE_INTEGER\n */\n min?: number;\n /** 最大值\n * @default Number.MAX_SAFE_INTEGER\n */\n max?: number;\n /** 值变更时触发的函数 */\n onChange?: (value?: number) => void;\n /** 每次改变步数,可以为小数\n * @default 1\n */\n step?: number;\n /** 数值精度\n * @default 2\n */\n precision?: number;\n}\nexport type InputNumberElement = CustomElement<InputNumberProps>;\n\nfunction InputNumber(props: InputNumberProps) {\n const [move, setMove] = createSignal(false);\n\n function onMouseDown(e: MouseEvent) {\n e.stopPropagation();\n setMove(true);\n }\n function onKeyDown(e: KeyboardEvent) {\n switch (e.key) {\n case 'ArrowUp':\n mouseMove({ movementX: 0, movementY: -1 });\n break;\n case 'ArrowDown':\n mouseMove({ movementX: 0, movementY: 1 });\n break;\n default:\n break;\n }\n }\n function mouseUp() {\n setMove(false);\n }\n const _ = mergeProps(\n {\n size: 'normal',\n value: '',\n defaultValue: 0,\n type: 'text',\n onKeyDown: onKeyDown,\n onMouseDown: onMouseDown,\n step: 1,\n precision: 2,\n max: Number.MAX_SAFE_INTEGER,\n min: Number.MIN_SAFE_INTEGER,\n },\n props,\n );\n\n function change(val?: string | number) {\n let _val = typeof val === 'string' ? parseFloat(val) : val;\n\n if (isNaN(_val!)) {\n _val = '' as unknown as number;\n }\n if (typeof _val !== 'undefined') {\n if (_val < _.min) _val = _.min;\n if (_val > _.max) _val = _.max;\n }\n props.onChange?.(_val);\n }\n\n function mouseMove(e: { movementX: number; movementY: number }) {\n const { movementX, movementY } = e;\n const _val = _.value;\n const val = typeof _val === 'number' && !isNaN(_val) ? _val : Number(_val) || 0;\n\n change(Number(Number(val + (movementX - movementY) * _.step).toFixed(_.precision)));\n }\n\n createEffect(() => {\n if (move()) {\n document.body.addEventListener('mousemove', mouseMove, {\n passive: passiveSupported,\n });\n document.body.addEventListener('mouseup', mouseUp, {\n passive: passiveSupported,\n });\n }\n onCleanup(() => {\n document.body.removeEventListener('mousemove', mouseMove, false);\n document.body.removeEventListener('mouseup', mouseUp, passiveSupported);\n });\n });\n\n return (\n <Input\n {...(_ as InputProps)}\n class={cx('number', props.class)}\n onChange={change}\n css={style + (props.css || '')}\n />\n );\n}\n\ncustomElement<InputNumberProps>(\n 'n-input-number',\n {\n ...defaultInportProps,\n defaultValue: void 0,\n max: void 0,\n min: void 0,\n onChange: void 0,\n step: void 0,\n precision: void 0,\n },\n (_, opt) => {\n const el = opt.element;\n const props = mergeProps(\n {\n onChange(val?: number | string) {\n el.value = val;\n el.dispatchEvent(\n new CustomEvent('change', {\n detail: val,\n }),\n );\n },\n },\n _,\n );\n\n return <InputNumber {...props} />;\n },\n);\n\nexport default InputNumber;\n"],"names":["style","css","InputNumber","props","move","setMove","createSignal","mouseUp","_","mergeProps","size","value","defaultValue","type","onKeyDown","e","key","mouseMove","movementX","movementY","onMouseDown","stopPropagation","step","precision","max","Number","MAX_SAFE_INTEGER","min","MIN_SAFE_INTEGER","change","val","_val","parseFloat","isNaN","onChange","toFixed","createEffect","document","body","addEventListener","passive","passiveSupported","onCleanup","removeEventListener","Input","cx","class","customElement","defaultInportProps","opt","el","element","dispatchEvent","CustomEvent","detail"],"mappings":"wGAsKA,+CAAA,+CAtKkE,yBACjC,8EACT,yBACM,ueAGY,4IAE1C,MAAMA,EAAQC,GAAAA,KAAG,CAAA,CAAC;;;;;;;;;;AAUlB,CAAC,CAiCD,SAASC,EAAYC,CAAuB,EAC1C,GAAM,CAACC,EAAMC,EAAQ,CAAGC,GAAAA,cAAY,EAAC,CAAA,GAkBrC,SAASC,IACPF,EAAQ,CAAA,EACV,CACA,IAAMG,EAAIC,GAAAA,YAAU,EAClB,CACEC,KAAM,SACNC,MAAO,GACPC,aAAc,EACdC,KAAM,OACNC,UArBJ,SAAmBC,CAAgB,EACjC,OAAQA,EAAEC,GAAG,EACX,IAAK,UACHC,EAAU,CAAEC,UAAW,EAAGC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GAC1DoB,SAASC,IAAI,CAACK,mBAAmB,CAAC,UAAWpC,EAASkC,SAAgB,CACxE,EACF,yBAGGG,SAAK,kBACCpC,qBACEqC,GAAAA,IAAE,EAAC,SAAU1C,EAAM2C,KAAK,YACrBjB,mBACL7B,EAASG,CAAAA,EAAMF,GAAG,EAAI,EAAC,KAGlC,CAEA8C,GAAAA,eAAa,EACX,iBACA,CACE,GAAGC,oBAAkB,CACrBpC,aAAc,KAAK,EACnBY,IAAK,KAAK,EACVG,IAAK,KAAK,EACVO,SAAU,KAAK,EACfZ,KAAM,KAAK,EACXC,UAAW,KAAK,CAClB,EACA,CAACf,EAAGyC,KACF,IAAMC,EAAKD,EAAIE,OAAO,CAChBhD,EAAQM,GAAAA,YAAU,EACtB,CACEyB,SAASJ,CAAqB,EAC5BoB,EAAGvC,KAAK,CAAGmB,EACXoB,EAAGE,aAAa,CACd,IAAIC,YAAY,SAAU,CACxBC,OAAQxB,CACV,GAEJ,CACF,EACAtB,GAGF,4BAAQN,EAAgBC,EAC1B,SAGF,EAAeD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: 数据展示
|
|
3
|
+
title: 数学公式
|
|
4
|
+
subtitle: n-katex
|
|
5
|
+
icon: ∛
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
export const katex = import('n-katex');
|
|
9
|
+
|
|
10
|
+
# 数学公式
|
|
11
|
+
|
|
12
|
+
> 使用该组件你需要安装 **[n-katex](https://www.npmjs.com/package/n-katex)**
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```shell
|
|
17
|
+
yarn add n-katex -S
|
|
18
|
+
# or
|
|
19
|
+
npm install n-katex
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 在 jsx 中使用
|
|
23
|
+
|
|
24
|
+
```jsx
|
|
25
|
+
import 'n-katex';
|
|
26
|
+
|
|
27
|
+
<n-katex>{'\\underbrace{a+b+\\dots+n}_{m2}'}</n-katex>;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 在 html5 中使用
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<!-- 引入 CDN 资源 -->
|
|
34
|
+
<script src="https://cdn.jsdelivr.net/npm/n-katex@1.0.5/umd/index.js"></script>
|
|
35
|
+
<!-- 使用 -->
|
|
36
|
+
<body>
|
|
37
|
+
行内公式
|
|
38
|
+
<n-katex>\underbrace{a+b+\dots+n}_{m2}</n-katex>
|
|
39
|
+
</body>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
> [点击查看 KaTex 完整配置项](https://katex.org/docs/options.html)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 块级公式
|
|
3
|
+
description: 单独使用一块区域作为公式展示
|
|
4
|
+
order: 2
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<n-katex display-mode="true" fleqn="true">
|
|
9
|
+
\begin{array}{c}
|
|
10
|
+
S= \binom{N}{n},A_{k}=\binom{M}{k}\cdot \binom{N-M}{n-k} \\
|
|
11
|
+
P\left ( A_{k}\right ) = \frac{\binom{M}{k}\cdot \binom{N-M}{n-k}}{\binom{N}{n}}
|
|
12
|
+
\end{array}
|
|
13
|
+
</n-katex>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```jsx
|
|
17
|
+
<n-katex display-mode="true" fleqn="false">
|
|
18
|
+
{`
|
|
19
|
+
\\begin{array}{c}
|
|
20
|
+
S= \\binom{N}{n},A_{k}=\\binom{M}{k}\\cdot \\binom{N-M}{n-k} \\\\
|
|
21
|
+
P\\left ( A_{k}\\right ) = \\frac{\\binom{M}{k}\\cdot \\binom{N-M}{n-k}}{\\binom{N}{n}}
|
|
22
|
+
\\end{array}
|
|
23
|
+
`}
|
|
24
|
+
</n-katex>
|
|
25
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 内联公式
|
|
3
|
+
description: 在行内与其余内容置于一处的效果
|
|
4
|
+
order: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<p>
|
|
9
|
+
行内公式
|
|
10
|
+
<n-katex>\underbrace{a+b+\dots+n}_{m2}</n-katex>
|
|
11
|
+
</p>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```jsx
|
|
15
|
+
<p>
|
|
16
|
+
行内公式
|
|
17
|
+
<n-katex>{'\\underbrace{a+b+\\dots+n}_{m2}'}</n-katex>
|
|
18
|
+
</p>
|
|
19
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 通过属性传递
|
|
3
|
+
description: 在 `text` 属性上传递 `markdown` 内容
|
|
4
|
+
order: 2
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<n-md></n-md>
|
|
9
|
+
<script>
|
|
10
|
+
const el = container.querySelector('n-md');
|
|
11
|
+
el.text = `
|
|
12
|
+
#### 第二种方式 (开启了图片查看器)
|
|
13
|
+
|
|
14
|
+
!> 写在 text 属性上
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
`;
|
|
18
|
+
</script>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
<n-md
|
|
23
|
+
picture-viewer={false}
|
|
24
|
+
text={`
|
|
25
|
+
#### 第二种方式 (关闭了图片查看器)
|
|
26
|
+
|
|
27
|
+
!> 写在 text 属性上
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
`}
|
|
31
|
+
/>
|
|
32
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 数学公式
|
|
3
|
+
description: 通过 `$` 包裹的将渲染为行内公式, 通过 `$$` 包裹的将渲染为块级公式
|
|
4
|
+
order: 3
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<n-md>
|
|
9
|
+
内联公式$\left(\LARGE{AB}\right)$
|
|
10
|
+
内联公式$\xcancel{ABC}$
|
|
11
|
+
|
|
12
|
+
$$
|
|
13
|
+
\begin{equation}
|
|
14
|
+
x = a_0 + \cfrac{1}{a_1
|
|
15
|
+
+ \cfrac{1}{a_2
|
|
16
|
+
+ \cfrac{1}{a_3 + \cfrac{1}{a_4} } } }
|
|
17
|
+
\end{equation}
|
|
18
|
+
$$
|
|
19
|
+
</n-md>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```jsx
|
|
23
|
+
<n-md
|
|
24
|
+
text={`
|
|
25
|
+
内联公式$\\left(\\LARGE{AB}\\right)$
|
|
26
|
+
内联公式$\\xcancel{ABC}$
|
|
27
|
+
|
|
28
|
+
$$
|
|
29
|
+
\\begin{equation}
|
|
30
|
+
x = a_0 + \\cfrac{1}{a_1
|
|
31
|
+
+ \\cfrac{1}{a_2
|
|
32
|
+
+ \\cfrac{1}{a_3 + \\cfrac{1}{a_4} } } }
|
|
33
|
+
\\end{equation}
|
|
34
|
+
$$`}
|
|
35
|
+
/>
|
|
36
|
+
```
|
package/lib/md/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return p}});const e=require("solid-js/web"),t=require("solid-js"),r=l(require("@moneko/common/lib/frameCallback")),n=require("@moneko/css"),o=require("solid-element")
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return p}});const e=require("solid-js/web"),t=require("solid-js"),r=l(require("@moneko/common/lib/frameCallback")),n=require("@moneko/css"),o=require("solid-element"),a=l(require("../md-style")),i=l(require("../theme"));function l(e){return e&&e.__esModule?e:{default:e}}function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(c=function(e){return e?r:t})(e)}require("../code"),require("../img");const s=(0,e.template)("<style> "),u=(0,e.template)("<style>"),d=(0,e.template)('<article class="n-md-box" part="box"><div class="n-md-body" part="body">'),f=(0,e.template)('<article part="box">');function h(o){let l,h;let{baseStyle:p}=i.default,m=(0,t.mergeProps)({webWorker:!1,pictureViewer:!0,lazyPicture:!0,text:"",tools:["copy"],getAnchorContainer:()=>window},o);function g(){return new Worker("https://cdn.jsdelivr.net/npm/neko-ui@latest/es/md/worker.js")}let b=m.webWorker?g():void 0;function v(e){h&&(h.innerHTML=e.data)}async function y(e){let{text:t,pictureViewer:r,lazyPicture:n,langToolbar:o,...a}=e,i=(await Promise.resolve().then(()=>(function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=c(void 0);if(r&&r.has(e))return r.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var i=o?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}return n.default=e,r&&r.set(e,n),n})(require("marked-completed")))).default;l||((l=new i.Renderer).katexBlock=e=>`<n-katex display-mode="true">${e}</n-katex>`,l.katexInline=e=>`<n-katex>${e}</n-katex>`),l.image=(e,t,o)=>`<n-img lazy="${n}" disabled="${!r}" role="img" src="${e}" alt="${o}" ${t?`title="${t}"`:""}></n-img>`;let s=!!o?.length;l.code=function(e,t){return"treeview"===t?`<n-tree data="${e}" />`:`<n-code class="n-code" toolbar="${s}" language="${t}" ${a.langLineNumber?'line-number="true"':""}>${encodeURIComponent(e)}</n-code>`},v({data:i(t,{renderer:l,langToolbar:o,headerPrefix:"# ",breaks:!0,pedantic:!1,smartLists:!0,smartypants:!0,xhtml:!0,...a})})}(0,t.createEffect)(()=>{m.webWorker&&(b||(b=g()),b.addEventListener("message",v))}),(0,t.createEffect)(()=>{b?b.postMessage(JSON.stringify({text:m.text,langLineNumber:m.lineNumber,langToolbar:m.tools,pictureViewer:m.pictureViewer,lazyPicture:m.lazyPicture})):(0,r.default)(()=>y({text:m.text,langLineNumber:m.lineNumber,langToolbar:m.tools,pictureViewer:m.pictureViewer,lazyPicture:m.lazyPicture}))}),(0,t.onCleanup)(()=>{b&&(b.removeEventListener("message",v),b.terminate())});let w=[],x=[],k=[];function C(e){e.preventDefault(),e.stopPropagation();let t=e.target;t.hash?(h?.querySelector(decodeURIComponent(t.hash))?.scrollIntoView({behavior:"smooth",block:"nearest"}),w.forEach(e=>{e.classList.remove("active")}),t.classList.add("active")):window.open(t.href)}function P(e){e.forEach(e=>{let t;let r=e.target.getAttribute("id"),n=e.target.querySelectorAll("a");if(w.forEach(e=>{e.hash===`#${r}`?t=e:e.hash||n.forEach(r=>{r.href===e.href&&(t=e)})}),t){let r=k.indexOf(t);k.forEach(e=>{e.classList.remove("active")}),e.isIntersecting?k.push(t):-1!==r&&k.splice(r,1),k[0]&&(k[0].classList.add("active"),k[0].offsetParent?.scrollTo({top:k[0].offsetTop}))}})}return(0,t.createEffect)(()=>{let e;h&&m.text.startsWith("[TOC]")&&(w=[...h.querySelectorAll(".n-md-toc a[href]")],x=[...h.querySelectorAll("h1, h2, h3, h4, h5, h6")],e=new IntersectionObserver(P,{rootMargin:"-50px 0px",threshold:.5}),x.forEach(t=>{e.observe(t)}),w.forEach(e=>{e.addEventListener("click",C)})),(0,t.onCleanup)(()=>{e&&(x.forEach(t=>{e.unobserve(t)}),e.disconnect()),w.forEach(e=>{e.removeEventListener("click",C)})})}),[(()=>{let t=s(),r=t.firstChild;return(0,e.effect)(()=>r.data=p()),t})(),(()=>{let e=u();return e.textContent=a.default,e})(),(0,e.createComponent)(t.Show,{get when(){return m.css},get children(){let t=s(),r=t.firstChild;return(0,e.effect)(()=>r.data=(0,n.css)(m.css)),t}}),(0,e.createComponent)(t.Switch,{get children(){return[(0,e.createComponent)(t.Match,{get when(){return(m.children||[]).length>0},get children(){let r=d(),n=r.firstChild;return(0,e.insert)(n,(0,e.createComponent)(t.For,{get each(){return m.children},children:e=>e})),r}}),(0,e.createComponent)(t.Match,{get when(){return m.text},get children(){let t=f(),r=h;return"function"==typeof r?(0,e.use)(r,t):h=t,(0,e.effect)(()=>(0,e.className)(t,(0,n.cx)("n-md-box",m.class))),t}})]}})]}(0,o.customElement)("n-md",{class:void 0,pictureViewer:void 0,lazyPicture:void 0,lineNumber:!0,text:void 0,tools:void 0,getAnchorContainer:void 0,css:void 0,children:void 0,notRender:void 0,webWorker:void 0},(r,n)=>{let o=n.element,a=(0,t.mergeProps)({text:!r.notRender&&o.textContent||o.text,css:o.css,tools:o.tools,getAnchorContainer:o.getAnchorContainer},r);return(0,t.createEffect)(()=>{o.removeAttribute("css"),o.replaceChildren()}),(0,e.createComponent)(h,a)});const p=h;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/md/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../components/md/index.tsx"],"sourcesContent":["import { For, Match, Show, Switch, createEffect, mergeProps, onCleanup } from 'solid-js';\nimport { frameCallback } from '@moneko/common';\nimport { css, cx } from '@moneko/css';\nimport { customElement } from 'solid-element';\nimport '../code';\nimport '../img';\nimport mdStyle from '../md-style';\nimport theme from '../theme';\nimport type { CustomElement } from '..';\n\nfunction MD(_props: MdProps) {\n let renderer: marked.Renderer | undefined;\n let ref: HTMLDivElement | undefined;\n const { baseStyle } = theme;\n const props = mergeProps(\n {\n webWorker: false,\n pictureViewer: true,\n lazyPicture: true,\n text: '',\n tools: ['copy'],\n getAnchorContainer: () => window as unknown as HTMLElement,\n },\n _props,\n );\n\n function initWorker() {\n return new Worker('https://cdn.jsdelivr.net/npm/neko-ui@latest/es/md/worker.js');\n }\n // eslint-disable-next-line solid/reactivity\n let worker: Worker | undefined = props.webWorker ? initWorker() : void 0;\n\n function update(e: { data: string }) {\n if (ref) {\n ref.innerHTML = e.data;\n }\n }\n async function postMessage(opt: {\n text: string;\n pictureViewer?: boolean;\n lazyPicture?: boolean;\n langToolbar?: string[];\n langLineNumber?: boolean;\n }) {\n const { text, pictureViewer, lazyPicture, langToolbar, ...options } = opt;\n const marked = (await import('marked-completed')).default;\n\n if (!renderer) {\n renderer = new marked.Renderer();\n\n renderer.katexBlock = (code: string) => {\n return `<n-katex display-mode=\"true\">${code}</n-katex>`;\n };\n renderer.katexInline = (code: string) => {\n return `<n-katex>${code}</n-katex>`;\n };\n }\n\n renderer.image = (src: string, title: string, alt: string) => {\n return `<n-img lazy=\"${lazyPicture}\" disabled=\"${!pictureViewer}\" role=\"img\" src=\"${src}\" alt=\"${alt}\" ${title ? `title=\"${title}\"` : ''}></n-img>`;\n };\n const toolbar = !!langToolbar?.length;\n\n renderer.code = function (code: string, lang: string) {\n if (lang === 'treeview') {\n return `<n-tree data=\"${code}\" />`;\n }\n\n return `<n-code class=\"n-code\" toolbar=\"${toolbar}\" language=\"${lang}\" ${\n options.langLineNumber ? 'line-number=\"true\"' : ''\n }>${encodeURIComponent(code)}</n-code>`;\n };\n\n update({\n data: marked(text, {\n renderer: renderer,\n langToolbar: langToolbar,\n headerPrefix: '# ',\n breaks: true,\n pedantic: false,\n smartLists: true,\n smartypants: true,\n xhtml: true,\n ...options,\n }),\n });\n }\n createEffect(() => {\n if (props.webWorker) {\n if (!worker) {\n worker = initWorker();\n }\n worker.addEventListener('message', update);\n }\n });\n\n createEffect(() => {\n if (worker) {\n worker.postMessage(\n JSON.stringify({\n text: props.text,\n langLineNumber: props.lineNumber,\n langToolbar: props.tools,\n pictureViewer: props.pictureViewer,\n lazyPicture: props.lazyPicture,\n }),\n );\n } else {\n const call = () =>\n postMessage({\n text: props.text,\n langLineNumber: props.lineNumber,\n langToolbar: props.tools,\n pictureViewer: props.pictureViewer,\n lazyPicture: props.lazyPicture,\n });\n\n frameCallback(call);\n }\n });\n onCleanup(() => {\n if (worker) {\n worker.removeEventListener('message', update);\n worker.terminate();\n }\n });\n let list: HTMLAnchorElement[] = [];\n let heading: HTMLHeadingElement[] = [];\n const active: HTMLAnchorElement[] = [];\n\n function handleAnchor(e: Event) {\n e.preventDefault();\n e.stopPropagation();\n const a = e.target as HTMLAnchorElement;\n\n if (a.hash) {\n ref?.querySelector(decodeURIComponent(a.hash))?.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n });\n list.forEach((item) => item.classList.remove('active'));\n a.classList.add('active');\n } else {\n window.open(a.href);\n }\n }\n function observerEntry(entries: IntersectionObserverEntry[]) {\n entries.forEach((entry) => {\n const id = entry.target.getAttribute('id');\n const all = entry.target.querySelectorAll('a');\n let a: HTMLAnchorElement | undefined;\n\n list.forEach((l) => {\n if (l.hash === `#${id}`) {\n a = l;\n } else if (!l.hash) {\n all.forEach((e) => {\n if (e.href === l.href) {\n a = l;\n }\n });\n }\n });\n if (a) {\n const idx = active.indexOf(a);\n\n active.forEach((e) => {\n e.classList.remove('active');\n });\n if (entry.isIntersecting) {\n active.push(a);\n } else if (idx !== -1) {\n active.splice(idx, 1);\n }\n if (active[0]) {\n active[0].classList.add('active');\n active[0].offsetParent?.scrollTo({\n top: active[0].offsetTop,\n });\n }\n }\n });\n }\n createEffect(() => {\n let observer: IntersectionObserver;\n\n if (ref && props.text?.startsWith('[TOC]')) {\n list = [...ref.querySelectorAll<HTMLAnchorElement>('.n-md-toc a[href]')];\n heading = [...ref.querySelectorAll<HTMLHeadingElement>('h1, h2, h3, h4, h5, h6')];\n observer = new IntersectionObserver(observerEntry, {\n rootMargin: '-50px 0px',\n threshold: 0.5,\n });\n heading.forEach((e) => observer.observe(e));\n list.forEach((e) => {\n e.addEventListener('click', handleAnchor);\n });\n }\n onCleanup(() => {\n if (observer) {\n heading.forEach((e) => observer.unobserve(e));\n observer.disconnect();\n }\n list.forEach((e) => {\n e.removeEventListener('click', handleAnchor);\n });\n });\n });\n\n return (\n <>\n <style textContent={baseStyle()} />\n <style textContent={mdStyle} />\n <Show when={props.css}>\n <style textContent={css(props.css)} />\n </Show>\n <Switch>\n <Match when={(props.children as [])?.length}>\n <article class=\"n-md-box\" part=\"box\">\n <div class=\"n-md-body\" part=\"body\">\n <For each={props.children as []}>{(e) => e}</For>\n </div>\n </article>\n </Match>\n <Match when={props.text}>\n <article ref={ref} class={cx('n-md-box', props.class)} part=\"box\" />\n </Match>\n </Switch>\n </>\n );\n}\n\nexport interface MdProps {\n /** 自定义类名 */\n class?: string;\n /** 自定义样式表 */\n css?: string;\n /** md内容 */\n text?: string;\n /** 开启图片查看器\n * @since 2.0.8\n * @default true\n */\n pictureViewer?: boolean;\n /** 开启图片懒加载\n * @since 2.8.3\n * @default true\n */\n lazyPicture?: boolean;\n /** 显示代码块行号\n * @default true\n */\n lineNumber?: boolean;\n /** 开启代码块工具条\n * @default ['copy']\n */\n tools?: 'copy'[];\n /** 指定滚动的容器\n * @default () => window\n */\n getAnchorContainer?: () => HTMLElement;\n /** 不进行解析\n * @default false\n */\n notRender?: boolean;\n children?: JSX.Element;\n /**\n * 使用 web worker\n */\n webWorker?: boolean;\n}\n\nexport type MdElement = CustomElement<MdProps>;\n\ncustomElement<MdProps>(\n 'n-md',\n {\n class: void 0,\n pictureViewer: void 0,\n lazyPicture: void 0,\n lineNumber: true,\n text: void 0,\n tools: void 0,\n getAnchorContainer: void 0,\n css: void 0,\n children: void 0,\n notRender: void 0,\n webWorker: void 0,\n },\n (_, opt) => {\n const el = opt.element;\n const props = mergeProps(\n {\n text: (!_.notRender && el.textContent) || el.text,\n css: el.css,\n tools: el.tools,\n getAnchorContainer: el.getAnchorContainer,\n },\n _,\n );\n\n createEffect(() => {\n el.removeAttribute('css');\n el.replaceChildren();\n });\n return <MD {...props} />;\n },\n);\nexport default MD;\n"],"names":["MD","_props","renderer","ref","baseStyle","theme","props","mergeProps","webWorker","pictureViewer","lazyPicture","text","tools","getAnchorContainer","window","initWorker","Worker","worker","update","e","innerHTML","data","postMessage","opt","langToolbar","options","marked","default","Renderer","katexBlock","code","katexInline","image","src","title","alt","toolbar","length","lang","langLineNumber","encodeURIComponent","headerPrefix","breaks","pedantic","smartLists","smartypants","xhtml","createEffect","addEventListener","JSON","stringify","lineNumber","frameCallback","onCleanup","removeEventListener","terminate","list","heading","active","handleAnchor","preventDefault","stopPropagation","a","target","hash","querySelector","decodeURIComponent","scrollIntoView","behavior","block","forEach","item","classList","remove","add","open","href","observerEntry","entries","entry","id","getAttribute","all","querySelectorAll","l","idx","indexOf","isIntersecting","push","splice","offsetParent","scrollTo","top","offsetTop","observer","startsWith","IntersectionObserver","rootMargin","threshold","observe","unobserve","disconnect","mdStyle","Show","css","Switch","Match","children","For","cx","class","customElement","notRender","_","el","element","textContent","removeAttribute","replaceChildren"],"mappings":"kGAoTA,+CAAA,+CApT8E,wBAChD,+CACN,yBACM,yBACvB,mBACA,4BACa,4BACF,oYAGlB,SAASA,EAAGC,CAAe,MACrBC,EACAC,EACJ,GAAM,CAAEC,UAAAA,CAAS,CAAE,CAAGC,SAAK,CACrBC,EAAQC,GAAAA,YAAU,EACtB,CACEC,UAAW,CAAA,EACXC,cAAe,CAAA,EACfC,YAAa,CAAA,EACbC,KAAM,GACNC,MAAO,CAAC,OAAO,CACfC,mBAAoB,IAAMC,MAC5B,EACAb,GAGF,SAASc,IACP,OAAO,IAAIC,OAAO,8DACpB,CAEA,IAAIC,EAA6BX,EAAME,SAAS,CAAGO,IAAe,KAAK,EAEvE,SAASG,EAAOC,CAAmB,EAC7BhB,GACFA,CAAAA,EAAIiB,SAAS,CAAGD,EAAEE,IAAI,AAAD,CAEzB,CACA,eAAeC,EAAYC,CAM1B,EACC,GAAM,CAAEZ,KAAAA,CAAI,CAAEF,cAAAA,CAAa,CAAEC,YAAAA,CAAW,CAAEc,YAAAA,CAAW,CAAE,GAAGC,EAAS,CAAGF,EAChEG,EAAS,AAAC,CAAA,MAAM,yeAAA,QAAO,qBAAkB,EAAGC,OAAO,CAEpDzB,IAGHA,AAFAA,CAAAA,EAAW,IAAIwB,EAAOE,QAAQ,AAAC,EAEtBC,UAAU,CAAG,AAACC,GACd,CAAC,6BAA6B,EAAEA,EAAK,UAAU,CA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AAI,6BACPR,4CAAAA,uCAAY0G,GAAAA,IAAE,EAAC,WAAYvG,EAAMwG,KAAK,aAK9D,CA4CAC,GAAAA,eAAa,EACX,OACA,CACED,MAAO,KAAK,EACZrG,cAAe,KAAK,EACpBC,YAAa,KAAK,EAClByC,WAAY,CAAA,EACZxC,KAAM,KAAK,EACXC,MAAO,KAAK,EACZC,mBAAoB,KAAK,EACzB2F,IAAK,KAAK,EACVG,SAAU,KAAK,EACfK,UAAW,KAAK,EAChBxG,UAAW,KAAK,CAClB,EACA,CAACyG,EAAG1F,KACF,IAAM2F,EAAK3F,EAAI4F,OAAO,CAChB7G,EAAQC,GAAAA,YAAU,EACtB,CACEI,KAAM,AAAC,CAACsG,EAAED,SAAS,EAAIE,EAAGE,WAAW,EAAKF,EAAGvG,IAAI,CACjD6F,IAAKU,EAAGV,GAAG,CACX5F,MAAOsG,EAAGtG,KAAK,CACfC,mBAAoBqG,EAAGrG,kBAAkB,AAC3C,EACAoG,GAOF,MAJAlE,GAAAA,cAAY,EAAC,KACXmE,EAAGG,eAAe,CAAC,OACnBH,EAAGI,eAAe,EACpB,yBACQtH,EAAOM,EACjB,SAEF,EAAeN"}
|
|
1
|
+
{"version":3,"sources":["../../components/md/index.tsx"],"sourcesContent":["import { createEffect, For, Match, mergeProps, onCleanup, Show, Switch } from 'solid-js';\nimport { frameCallback } from '@moneko/common';\nimport { css, cx } from '@moneko/css';\nimport { customElement } from 'solid-element';\n\nimport type { CustomElement } from '..';\nimport mdStyle from '../md-style';\nimport theme from '../theme';\n\nimport '../code';\nimport '../img';\n\nfunction MD(_props: MdProps) {\n let renderer: marked.Renderer | undefined;\n let ref: HTMLDivElement | undefined;\n const { baseStyle } = theme;\n const props = mergeProps(\n {\n webWorker: false,\n pictureViewer: true,\n lazyPicture: true,\n text: '',\n tools: ['copy'],\n getAnchorContainer: () => window as unknown as HTMLElement,\n },\n _props,\n );\n\n function initWorker() {\n return new Worker('https://cdn.jsdelivr.net/npm/neko-ui@latest/es/md/worker.js');\n }\n // eslint-disable-next-line solid/reactivity\n let worker: Worker | undefined = props.webWorker ? initWorker() : void 0;\n\n function update(e: { data: string }) {\n if (ref) {\n ref.innerHTML = e.data;\n }\n }\n async function postMessage(opt: {\n text: string;\n pictureViewer?: boolean;\n lazyPicture?: boolean;\n langToolbar?: string[];\n langLineNumber?: boolean;\n }) {\n const { text, pictureViewer, lazyPicture, langToolbar, ...options } = opt;\n const marked = (await import('marked-completed')).default;\n\n if (!renderer) {\n renderer = new marked.Renderer();\n\n renderer.katexBlock = (code: string) => {\n return `<n-katex display-mode=\"true\">${code}</n-katex>`;\n };\n renderer.katexInline = (code: string) => {\n return `<n-katex>${code}</n-katex>`;\n };\n }\n\n renderer.image = (src: string, title: string, alt: string) => {\n return `<n-img lazy=\"${lazyPicture}\" disabled=\"${!pictureViewer}\" role=\"img\" src=\"${src}\" alt=\"${alt}\" ${title ? `title=\"${title}\"` : ''}></n-img>`;\n };\n const toolbar = !!langToolbar?.length;\n\n renderer.code = function (code: string, lang: string) {\n if (lang === 'treeview') {\n return `<n-tree data=\"${code}\" />`;\n }\n\n return `<n-code class=\"n-code\" toolbar=\"${toolbar}\" language=\"${lang}\" ${\n options.langLineNumber ? 'line-number=\"true\"' : ''\n }>${encodeURIComponent(code)}</n-code>`;\n };\n\n update({\n data: marked(text, {\n renderer: renderer,\n langToolbar: langToolbar,\n headerPrefix: '# ',\n breaks: true,\n pedantic: false,\n smartLists: true,\n smartypants: true,\n xhtml: true,\n ...options,\n }),\n });\n }\n createEffect(() => {\n if (props.webWorker) {\n if (!worker) {\n worker = initWorker();\n }\n worker.addEventListener('message', update);\n }\n });\n\n createEffect(() => {\n if (worker) {\n worker.postMessage(\n JSON.stringify({\n text: props.text,\n langLineNumber: props.lineNumber,\n langToolbar: props.tools,\n pictureViewer: props.pictureViewer,\n lazyPicture: props.lazyPicture,\n }),\n );\n } else {\n const call = () =>\n postMessage({\n text: props.text,\n langLineNumber: props.lineNumber,\n langToolbar: props.tools,\n pictureViewer: props.pictureViewer,\n lazyPicture: props.lazyPicture,\n });\n\n frameCallback(call);\n }\n });\n onCleanup(() => {\n if (worker) {\n worker.removeEventListener('message', update);\n worker.terminate();\n }\n });\n let list: HTMLAnchorElement[] = [];\n let heading: HTMLHeadingElement[] = [];\n const active: HTMLAnchorElement[] = [];\n\n function handleAnchor(e: Event) {\n e.preventDefault();\n e.stopPropagation();\n const a = e.target as HTMLAnchorElement;\n\n if (a.hash) {\n ref?.querySelector(decodeURIComponent(a.hash))?.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n });\n list.forEach((item) => {\n item.classList.remove('active');\n });\n a.classList.add('active');\n } else {\n window.open(a.href);\n }\n }\n function observerEntry(entries: IntersectionObserverEntry[]) {\n entries.forEach((entry) => {\n const id = entry.target.getAttribute('id');\n const all = entry.target.querySelectorAll('a');\n let a: HTMLAnchorElement | undefined;\n\n list.forEach((l) => {\n if (l.hash === `#${id}`) {\n a = l;\n } else if (!l.hash) {\n all.forEach((e) => {\n if (e.href === l.href) {\n a = l;\n }\n });\n }\n });\n if (a) {\n const idx = active.indexOf(a);\n\n active.forEach((e) => {\n e.classList.remove('active');\n });\n if (entry.isIntersecting) {\n active.push(a);\n } else if (idx !== -1) {\n active.splice(idx, 1);\n }\n if (active[0]) {\n active[0].classList.add('active');\n active[0].offsetParent?.scrollTo({\n top: active[0].offsetTop,\n });\n }\n }\n });\n }\n createEffect(() => {\n let observer: IntersectionObserver;\n\n if (ref && props.text.startsWith('[TOC]')) {\n list = [...ref.querySelectorAll<HTMLAnchorElement>('.n-md-toc a[href]')];\n heading = [...ref.querySelectorAll<HTMLHeadingElement>('h1, h2, h3, h4, h5, h6')];\n observer = new IntersectionObserver(observerEntry, {\n rootMargin: '-50px 0px',\n threshold: 0.5,\n });\n heading.forEach((e) => {\n observer.observe(e);\n });\n list.forEach((e) => {\n e.addEventListener('click', handleAnchor);\n });\n }\n onCleanup(() => {\n if (observer) {\n heading.forEach((e) => {\n observer.unobserve(e);\n });\n observer.disconnect();\n }\n list.forEach((e) => {\n e.removeEventListener('click', handleAnchor);\n });\n });\n });\n\n return (\n <>\n <style textContent={baseStyle()} />\n <style textContent={mdStyle} />\n <Show when={props.css}>\n <style textContent={css(props.css)} />\n </Show>\n <Switch>\n <Match when={(props.children || []).length > 0}>\n <article class=\"n-md-box\" part=\"box\">\n <div class=\"n-md-body\" part=\"body\">\n <For each={props.children as []}>{(e) => e}</For>\n </div>\n </article>\n </Match>\n <Match when={props.text}>\n <article ref={ref} class={cx('n-md-box', props.class)} part=\"box\" />\n </Match>\n </Switch>\n </>\n );\n}\n\nexport interface MdProps {\n /** 自定义类名 */\n class?: string;\n /** 自定义样式表 */\n css?: string;\n /** md内容 */\n text?: string;\n /** 开启图片查看器\n * @since 2.0.8\n * @default true\n */\n pictureViewer?: boolean;\n /** 开启图片懒加载\n * @since 2.8.3\n * @default true\n */\n lazyPicture?: boolean;\n /** 显示代码块行号\n * @default true\n */\n lineNumber?: boolean;\n /** 开启代码块工具条\n * @default ['copy']\n */\n tools?: 'copy'[];\n /** 指定滚动的容器\n * @default () => window\n */\n getAnchorContainer?: () => HTMLElement;\n /** 不进行解析\n * @default false\n */\n notRender?: boolean;\n children?: JSX.Element;\n /**\n * 使用 web worker\n */\n webWorker?: boolean;\n}\n\nexport type MdElement = CustomElement<MdProps>;\n\ncustomElement<MdProps>(\n 'n-md',\n {\n class: void 0,\n pictureViewer: void 0,\n lazyPicture: void 0,\n lineNumber: true,\n text: void 0,\n tools: void 0,\n getAnchorContainer: void 0,\n css: void 0,\n children: void 0,\n notRender: void 0,\n webWorker: void 0,\n },\n (_, opt) => {\n const el = opt.element;\n const props = mergeProps(\n {\n text: (!_.notRender && el.textContent) || el.text,\n css: el.css,\n tools: el.tools,\n getAnchorContainer: el.getAnchorContainer,\n },\n _,\n );\n\n createEffect(() => {\n el.removeAttribute('css');\n el.replaceChildren();\n });\n return <MD {...props} />;\n },\n);\nexport default MD;\n"],"names":["MD","_props","renderer","ref","baseStyle","theme","props","mergeProps","webWorker","pictureViewer","lazyPicture","text","tools","getAnchorContainer","window","initWorker","Worker","worker","update","e","innerHTML","data","postMessage","opt","langToolbar","options","marked","default","Renderer","katexBlock","code","katexInline","image","src","title","alt","toolbar","length","lang","langLineNumber","encodeURIComponent","headerPrefix","breaks","pedantic","smartLists","smartypants","xhtml","createEffect","addEventListener","JSON","stringify","lineNumber","frameCallback","onCleanup","removeEventListener","terminate","list","heading","active","handleAnchor","preventDefault","stopPropagation","a","target","hash","querySelector","decodeURIComponent","scrollIntoView","behavior","block","forEach","item","classList","remove","add","open","href","observerEntry","entries","entry","id","getAttribute","all","querySelectorAll","l","idx","indexOf","isIntersecting","push","splice","offsetParent","scrollTo","top","offsetTop","observer","startsWith","IntersectionObserver","rootMargin","threshold","observe","unobserve","disconnect","mdStyle","Show","css","Switch","Match","children","For","cx","class","customElement","notRender","_","el","element","textContent","removeAttribute","replaceChildren"],"mappings":"kGA4TA,+CAAA,+CA5T8E,wBAChD,+CACN,yBACM,6BAGV,4BACF,uMAEX,mBACA,+MAEP,SAASA,EAAGC,CAAe,MACrBC,EACAC,EACJ,GAAM,CAAEC,UAAAA,CAAS,CAAE,CAAGC,SAAK,CACrBC,EAAQC,GAAAA,YAAU,EACtB,CACEC,UAAW,CAAA,EACXC,cAAe,CAAA,EACfC,YAAa,CAAA,EACbC,KAAM,GACNC,MAAO,CAAC,OAAO,CACfC,mBAAoB,IAAMC,MAC5B,EACAb,GAGF,SAASc,IACP,OAAO,IAAIC,OAAO,8DACpB,CAEA,IAAIC,EAA6BX,EAAME,SAAS,CAAGO,IAAe,KAAK,EAEvE,SAASG,EAAOC,CAAmB,EAC7BhB,GACFA,CAAAA,EAAIiB,SAAS,CAAGD,EAAEE,IAAI,AAAD,CAEzB,CACA,eAAeC,EAAYC,CAM1B,EACC,GAAM,CAAEZ,KAAAA,CAAI,CAAEF,cAAAA,CAAa,CAAEC,YAAAA,CAAW,CAAEc,YAAAA,CAAW,CAAE,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C1BC,MAAI,oBAAOjG,EAAMkG,GAAG,wEACCA,GAAAA,KAAG,EAAClG,EAAMkG,GAAG,8BAElCC,QAAM,8CACJC,OAAK,mBAAO,AAACpG,CAAAA,EAAMqG,QAAQ,EAAI,EAAE,AAAD,EAAGtE,MAAM,CAAG,sFAGtCuE,KAAG,oBAAOtG,EAAMqG,QAAQ,WAAS,AAACxF,GAAMA,gCAI9CuF,OAAK,oBAAOpG,EAAMK,IAAI,6BACPR,4CAAAA,uCAAY0G,GAAAA,IAAE,EAAC,WAAYvG,EAAMwG,KAAK,aAK9D,CA4CAC,GAAAA,eAAa,EACX,OACA,CACED,MAAO,KAAK,EACZrG,cAAe,KAAK,EACpBC,YAAa,KAAK,EAClByC,WAAY,CAAA,EACZxC,KAAM,KAAK,EACXC,MAAO,KAAK,EACZC,mBAAoB,KAAK,EACzB2F,IAAK,KAAK,EACVG,SAAU,KAAK,EACfK,UAAW,KAAK,EAChBxG,UAAW,KAAK,CAClB,EACA,CAACyG,EAAG1F,KACF,IAAM2F,EAAK3F,EAAI4F,OAAO,CAChB7G,EAAQC,GAAAA,YAAU,EACtB,CACEI,KAAM,AAAC,CAACsG,EAAED,SAAS,EAAIE,EAAGE,WAAW,EAAKF,EAAGvG,IAAI,CACjD6F,IAAKU,EAAGV,GAAG,CACX5F,MAAOsG,EAAGtG,KAAK,CACfC,mBAAoBqG,EAAGrG,kBAAkB,AAC3C,EACAoG,GAOF,MAJAlE,GAAAA,cAAY,EAAC,KACXmE,EAAGG,eAAe,CAAC,OACnBH,EAAGI,eAAe,EACpB,yBACQtH,EAAOM,EACjB,SAEF,EAAeN"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 最简单的用法
|
|
3
|
+
order: 1
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
```html
|
|
7
|
+
<n-menu></n-menu>
|
|
8
|
+
<script>
|
|
9
|
+
const el = container.querySelector('n-menu');
|
|
10
|
+
|
|
11
|
+
el.items = ['A', 'B', { value: 'C', disabled: true }, 'D'];
|
|
12
|
+
</script>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
<n-menu items={['A', 'B', { value: 'C', disabled: true }, 'D']} />
|
|
17
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 自定义字段名
|
|
3
|
+
description: 自定义节点 'label'、'value'、'options' 的字段
|
|
4
|
+
order: 4
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<n-menu></n-menu>
|
|
9
|
+
<script>
|
|
10
|
+
const el = container.querySelector('n-menu');
|
|
11
|
+
|
|
12
|
+
el.fieldNames = {
|
|
13
|
+
label: 'name',
|
|
14
|
+
options: 'children',
|
|
15
|
+
children: 'options',
|
|
16
|
+
};
|
|
17
|
+
el.items = [
|
|
18
|
+
{
|
|
19
|
+
value: '1',
|
|
20
|
+
name: '动物',
|
|
21
|
+
children: ['牛', '马'],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
</script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```jsx
|
|
28
|
+
<n-menu
|
|
29
|
+
field-names={{
|
|
30
|
+
label: 'name',
|
|
31
|
+
options: 'children',
|
|
32
|
+
children: 'options',
|
|
33
|
+
}}
|
|
34
|
+
items={[
|
|
35
|
+
{
|
|
36
|
+
value: '1',
|
|
37
|
+
name: '动物',
|
|
38
|
+
children: ['牛', '马'],
|
|
39
|
+
},
|
|
40
|
+
]}
|
|
41
|
+
/>
|
|
42
|
+
```
|