@daisu-ui/ui 0.0.0-stage → 0.1.0-beta.3
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/CHANGELOG.md +58 -0
- package/LICENSE +21 -0
- package/README.md +93 -2
- package/THIRD_PARTY_NOTICES.md +19 -0
- package/dist/ActionSheet.d.ts +45 -0
- package/dist/ActionSheet.jsx +37 -0
- package/dist/AnchoredBubble.d.ts +36 -0
- package/dist/AnchoredBubble.jsx +120 -0
- package/dist/Avatar.d.ts +35 -0
- package/dist/Avatar.jsx +29 -0
- package/dist/Backtop.d.ts +22 -0
- package/dist/Backtop.jsx +18 -0
- package/dist/Badge.d.ts +19 -0
- package/dist/Badge.jsx +11 -0
- package/dist/BarCode.d.ts +20 -0
- package/dist/BarCode.jsx +38 -0
- package/dist/Button.d.ts +21 -0
- package/dist/Button.jsx +19 -0
- package/dist/Calendar.d.ts +90 -0
- package/dist/Calendar.jsx +164 -0
- package/dist/CalendarView.d.ts +51 -0
- package/dist/CalendarView.jsx +136 -0
- package/dist/Card.d.ts +21 -0
- package/dist/Card.jsx +21 -0
- package/dist/Cascader.d.ts +75 -0
- package/dist/Cascader.jsx +212 -0
- package/dist/Cell.d.ts +34 -0
- package/dist/Cell.jsx +37 -0
- package/dist/Checkbox.d.ts +50 -0
- package/dist/Checkbox.jsx +74 -0
- package/dist/Circle.d.ts +19 -0
- package/dist/Circle.jsx +35 -0
- package/dist/Collapse.d.ts +31 -0
- package/dist/Collapse.jsx +61 -0
- package/dist/ConfigProvider.d.ts +15 -0
- package/dist/ConfigProvider.jsx +20 -0
- package/dist/CountDown.d.ts +20 -0
- package/dist/CountDown.jsx +15 -0
- package/dist/CountTo.d.ts +28 -0
- package/dist/CountTo.jsx +27 -0
- package/dist/Curtain.d.ts +29 -0
- package/dist/Curtain.jsx +51 -0
- package/dist/DatetimePicker.d.ts +46 -0
- package/dist/DatetimePicker.jsx +138 -0
- package/dist/DatetimePickerView.d.ts +38 -0
- package/dist/DatetimePickerView.jsx +36 -0
- package/dist/Dialog.d.ts +64 -0
- package/dist/Dialog.jsx +105 -0
- package/dist/Divider.d.ts +16 -0
- package/dist/Divider.jsx +9 -0
- package/dist/DropMenu.d.ts +55 -0
- package/dist/DropMenu.jsx +210 -0
- package/dist/Empty.d.ts +14 -0
- package/dist/Empty.jsx +14 -0
- package/dist/EmptyState.d.ts +6 -0
- package/dist/EmptyState.jsx +9 -0
- package/dist/Fab.d.ts +30 -0
- package/dist/Fab.jsx +127 -0
- package/dist/FloatingPanel.d.ts +21 -0
- package/dist/FloatingPanel.jsx +102 -0
- package/dist/Form.d.ts +63 -0
- package/dist/Form.jsx +108 -0
- package/dist/FormFieldRow.d.ts +56 -0
- package/dist/FormFieldRow.jsx +63 -0
- package/dist/Gap.d.ts +10 -0
- package/dist/Gap.jsx +14 -0
- package/dist/Grid.d.ts +47 -0
- package/dist/Grid.jsx +31 -0
- package/dist/Icon.d.ts +11 -0
- package/dist/Icon.jsx +12 -0
- package/dist/ImagePreview.d.ts +62 -0
- package/dist/ImagePreview.jsx +78 -0
- package/dist/Img.d.ts +28 -0
- package/dist/Img.jsx +59 -0
- package/dist/ImgCropper.d.ts +74 -0
- package/dist/ImgCropper.jsx +114 -0
- package/dist/IndexBar.d.ts +36 -0
- package/dist/IndexBar.jsx +149 -0
- package/dist/Input.d.ts +11 -0
- package/dist/Input.jsx +3 -0
- package/dist/InputNumber.d.ts +32 -0
- package/dist/InputNumber.jsx +165 -0
- package/dist/Keyboard.d.ts +37 -0
- package/dist/Keyboard.jsx +130 -0
- package/dist/Layout.d.ts +31 -0
- package/dist/Layout.jsx +14 -0
- package/dist/Loading.d.ts +18 -0
- package/dist/Loading.jsx +15 -0
- package/dist/Loadmore.d.ts +18 -0
- package/dist/Loadmore.jsx +16 -0
- package/dist/Navbar.d.ts +35 -0
- package/dist/Navbar.jsx +50 -0
- package/dist/NoticeBar.d.ts +30 -0
- package/dist/NoticeBar.jsx +86 -0
- package/dist/Notify.d.ts +34 -0
- package/dist/Notify.jsx +52 -0
- package/dist/NumberStepper.d.ts +11 -0
- package/dist/NumberStepper.jsx +41 -0
- package/dist/Overlay.d.ts +16 -0
- package/dist/Overlay.jsx +12 -0
- package/dist/PagedList.d.ts +13 -0
- package/dist/PagedList.jsx +36 -0
- package/dist/Pagination.d.ts +29 -0
- package/dist/Pagination.jsx +33 -0
- package/dist/PasswordInput.d.ts +16 -0
- package/dist/PasswordInput.jsx +20 -0
- package/dist/Picker.d.ts +61 -0
- package/dist/Picker.jsx +80 -0
- package/dist/PickerView.d.ts +43 -0
- package/dist/PickerView.jsx +142 -0
- package/dist/Popover.d.ts +23 -0
- package/dist/Popover.jsx +35 -0
- package/dist/Popup.d.ts +30 -0
- package/dist/Popup.jsx +32 -0
- package/dist/Progress.d.ts +17 -0
- package/dist/Progress.jsx +45 -0
- package/dist/QrCode.d.ts +46 -0
- package/dist/QrCode.jsx +67 -0
- package/dist/Radio.d.ts +21 -0
- package/dist/Radio.jsx +34 -0
- package/dist/Rate.d.ts +25 -0
- package/dist/Rate.jsx +39 -0
- package/dist/Resize.d.ts +17 -0
- package/dist/Resize.jsx +17 -0
- package/dist/RichText.d.ts +133 -0
- package/dist/RichText.jsx +288 -0
- package/dist/RootPortal.d.ts +11 -0
- package/dist/RootPortal.jsx +19 -0
- package/dist/Search.d.ts +39 -0
- package/dist/Search.jsx +94 -0
- package/dist/Segmented.d.ts +18 -0
- package/dist/Segmented.jsx +35 -0
- package/dist/SelectPicker.d.ts +54 -0
- package/dist/SelectPicker.jsx +136 -0
- package/dist/Sidebar.d.ts +34 -0
- package/dist/Sidebar.jsx +43 -0
- package/dist/Signature.d.ts +46 -0
- package/dist/Signature.jsx +203 -0
- package/dist/Skeleton.d.ts +27 -0
- package/dist/Skeleton.jsx +29 -0
- package/dist/SlideVerify.d.ts +27 -0
- package/dist/SlideVerify.jsx +138 -0
- package/dist/Slider.d.ts +21 -0
- package/dist/Slider.jsx +131 -0
- package/dist/SortButton.d.ts +16 -0
- package/dist/SortButton.jsx +19 -0
- package/dist/Steps.d.ts +23 -0
- package/dist/Steps.jsx +25 -0
- package/dist/Sticky.d.ts +17 -0
- package/dist/Sticky.jsx +69 -0
- package/dist/SwipeAction.d.ts +27 -0
- package/dist/SwipeAction.jsx +187 -0
- package/dist/Swiper.d.ts +54 -0
- package/dist/Swiper.jsx +94 -0
- package/dist/SwiperNav.d.ts +18 -0
- package/dist/SwiperNav.jsx +10 -0
- package/dist/Switch.d.ts +31 -0
- package/dist/Switch.jsx +46 -0
- package/dist/SyncedInput.d.ts +12 -0
- package/dist/SyncedInput.jsx +18 -0
- package/dist/SyncedTextarea.d.ts +11 -0
- package/dist/SyncedTextarea.jsx +18 -0
- package/dist/Tabbar.d.ts +37 -0
- package/dist/Tabbar.jsx +46 -0
- package/dist/Table.d.ts +51 -0
- package/dist/Table.jsx +125 -0
- package/dist/Tabs.d.ts +65 -0
- package/dist/Tabs.jsx +132 -0
- package/dist/Tag.d.ts +33 -0
- package/dist/Tag.jsx +63 -0
- package/dist/Text.d.ts +19 -0
- package/dist/Text.jsx +7 -0
- package/dist/TextField.d.ts +89 -0
- package/dist/TextField.jsx +149 -0
- package/dist/Textarea.d.ts +22 -0
- package/dist/Textarea.jsx +3 -0
- package/dist/Toast.d.ts +36 -0
- package/dist/Toast.jsx +30 -0
- package/dist/Tooltip.d.ts +8 -0
- package/dist/Tooltip.jsx +5 -0
- package/dist/Tour.d.ts +85 -0
- package/dist/Tour.jsx +150 -0
- package/dist/Transition.d.ts +32 -0
- package/dist/Transition.jsx +43 -0
- package/dist/Upload.d.ts +64 -0
- package/dist/Upload.jsx +163 -0
- package/dist/VideoPreview.d.ts +47 -0
- package/dist/VideoPreview.jsx +59 -0
- package/dist/Watermark.d.ts +36 -0
- package/dist/Watermark.jsx +18 -0
- package/dist/action-sheet.css +19 -0
- package/dist/avatar.css +23 -0
- package/dist/avatarModel.d.ts +8 -0
- package/dist/avatarModel.js +17 -0
- package/dist/backtop.css +6 -0
- package/dist/badge.css +15 -0
- package/dist/badgeModel.d.ts +2 -0
- package/dist/badgeModel.js +18 -0
- package/dist/bar-code.css +5 -0
- package/dist/barCodeModel.d.ts +80 -0
- package/dist/barCodeModel.js +99 -0
- package/dist/bubble.css +14 -0
- package/dist/bubblePosition.d.ts +19 -0
- package/dist/bubblePosition.js +41 -0
- package/dist/button.css +56 -0
- package/dist/calendar.css +56 -0
- package/dist/calendarModel.d.ts +62 -0
- package/dist/calendarModel.js +141 -0
- package/dist/card.css +8 -0
- package/dist/cascader.css +16 -0
- package/dist/cascaderModel.d.ts +21 -0
- package/dist/cascaderModel.js +32 -0
- package/dist/cell.css +41 -0
- package/dist/choice.css +27 -0
- package/dist/choice.d.ts +28 -0
- package/dist/choice.jsx +16 -0
- package/dist/circle.css +4 -0
- package/dist/circleModel.d.ts +15 -0
- package/dist/circleModel.js +31 -0
- package/dist/config-provider.css +2 -0
- package/dist/configContext.d.ts +23 -0
- package/dist/configContext.js +24 -0
- package/dist/configTheme.d.ts +3 -0
- package/dist/configTheme.js +22 -0
- package/dist/count-down.css +2 -0
- package/dist/count-to.css +8 -0
- package/dist/countDownModel.d.ts +11 -0
- package/dist/countDownModel.js +7 -0
- package/dist/countToModel.d.ts +3 -0
- package/dist/countToModel.js +3 -0
- package/dist/curtain.css +10 -0
- package/dist/datetime-picker.css +11 -0
- package/dist/datetimePickerModel.d.ts +47 -0
- package/dist/datetimePickerModel.js +128 -0
- package/dist/dialog.css +23 -0
- package/dist/divider.css +14 -0
- package/dist/drop-menu.css +28 -0
- package/dist/empty.css +7 -0
- package/dist/fab.css +23 -0
- package/dist/fabModel.d.ts +26 -0
- package/dist/fabModel.js +16 -0
- package/dist/floating-panel.css +6 -0
- package/dist/floatingPanelModel.d.ts +3 -0
- package/dist/floatingPanelModel.js +10 -0
- package/dist/form.css +10 -0
- package/dist/formContext.d.ts +7 -0
- package/dist/formContext.js +2 -0
- package/dist/formModel.d.ts +38 -0
- package/dist/formModel.js +16 -0
- package/dist/gap.css +1 -0
- package/dist/grid.css +17 -0
- package/dist/icon.css +8 -0
- package/dist/icons/LICENSE.tabler +21 -0
- package/dist/icons/paths.d.ts +309 -0
- package/dist/icons/paths.js +310 -0
- package/dist/icons/render.d.ts +2 -0
- package/dist/icons/render.js +5 -0
- package/dist/image-preview.css +8 -0
- package/dist/img-cropper.css +1 -0
- package/dist/img.css +5 -0
- package/dist/imgCropperModel.d.ts +55 -0
- package/dist/imgCropperModel.js +41 -0
- package/dist/imgModel.d.ts +13 -0
- package/dist/imgModel.js +22 -0
- package/dist/index-bar.css +12 -0
- package/dist/index.d.ts +200 -0
- package/dist/index.js +99 -0
- package/dist/indexBarModel.d.ts +19 -0
- package/dist/indexBarModel.js +37 -0
- package/dist/input-number.css +24 -0
- package/dist/inputNumberModel.d.ts +23 -0
- package/dist/inputNumberModel.js +40 -0
- package/dist/keyboard.css +26 -0
- package/dist/keyboardModel.d.ts +11 -0
- package/dist/keyboardModel.js +34 -0
- package/dist/layout.css +2 -0
- package/dist/legacy/RadioGroup.d.ts +13 -0
- package/dist/legacy/RadioGroup.jsx +13 -0
- package/dist/legacy-controls.css +87 -0
- package/dist/loading.css +31 -0
- package/dist/loadingModel.d.ts +2 -0
- package/dist/loadingModel.js +21 -0
- package/dist/loadmore.css +5 -0
- package/dist/navbar.css +16 -0
- package/dist/notice-bar.css +19 -0
- package/dist/notify.css +14 -0
- package/dist/overlay.css +2 -0
- package/dist/pagination.css +12 -0
- package/dist/paginationModel.d.ts +6 -0
- package/dist/paginationModel.js +7 -0
- package/dist/password-input.css +14 -0
- package/dist/passwordInputModel.d.ts +6 -0
- package/dist/passwordInputModel.js +11 -0
- package/dist/picker.css +42 -0
- package/dist/pickerModel.d.ts +32 -0
- package/dist/pickerModel.js +49 -0
- package/dist/popover.css +5 -0
- package/dist/popup.css +17 -0
- package/dist/progress.css +16 -0
- package/dist/progressModel.d.ts +12 -0
- package/dist/progressModel.js +19 -0
- package/dist/qr-code.css +4 -0
- package/dist/qrCodeModel.d.ts +36 -0
- package/dist/qrCodeModel.js +61 -0
- package/dist/rate.css +20 -0
- package/dist/rateModel.d.ts +4 -0
- package/dist/rateModel.js +38 -0
- package/dist/resize.css +2 -0
- package/dist/rich-text.css +19 -0
- package/dist/richTextMedia.d.ts +28 -0
- package/dist/richTextMedia.js +3 -0
- package/dist/richTextModel.d.ts +52 -0
- package/dist/richTextModel.js +195 -0
- package/dist/root-portal.css +1 -0
- package/dist/router/RouterView.d.ts +21 -0
- package/dist/router/RouterView.jsx +120 -0
- package/dist/router/core.d.ts +85 -0
- package/dist/router/core.js +255 -0
- package/dist/router/hooks.d.ts +17 -0
- package/dist/router/hooks.jsx +71 -0
- package/dist/router/index.d.ts +5 -0
- package/dist/router/index.js +3 -0
- package/dist/router/location.d.ts +8 -0
- package/dist/router/location.js +46 -0
- package/dist/router/router.css +7 -0
- package/dist/router/runtime.d.ts +1 -0
- package/dist/router/runtime.js +25 -0
- package/dist/search.css +23 -0
- package/dist/segmented.css +19 -0
- package/dist/segmentedModel.d.ts +10 -0
- package/dist/segmentedModel.js +8 -0
- package/dist/sidebar.css +18 -0
- package/dist/sidebarModel.d.ts +8 -0
- package/dist/sidebarModel.js +27 -0
- package/dist/signature.css +5 -0
- package/dist/signatureModel.d.ts +23 -0
- package/dist/signatureModel.js +80 -0
- package/dist/skeleton.css +16 -0
- package/dist/slide-verify.css +7 -0
- package/dist/slider.css +49 -0
- package/dist/sliderModel.d.ts +10 -0
- package/dist/sliderModel.js +27 -0
- package/dist/sort-button.css +12 -0
- package/dist/steps.css +35 -0
- package/dist/sticky.css +7 -0
- package/dist/styles.css +136 -0
- package/dist/styles.d.ts +1 -0
- package/dist/swipe-action.css +6 -0
- package/dist/swiper.css +27 -0
- package/dist/swiperAnimation.d.ts +3 -0
- package/dist/swiperAnimation.js +6 -0
- package/dist/swiperModel.d.ts +2 -0
- package/dist/swiperModel.js +3 -0
- package/dist/switch.css +12 -0
- package/dist/tabbar.css +17 -0
- package/dist/tabbarModel.d.ts +8 -0
- package/dist/tabbarModel.js +27 -0
- package/dist/table.css +21 -0
- package/dist/tableModel.d.ts +10 -0
- package/dist/tableModel.js +17 -0
- package/dist/tabs.css +31 -0
- package/dist/tabsModel.d.ts +7 -0
- package/dist/tabsModel.js +14 -0
- package/dist/tag.css +66 -0
- package/dist/text-field.css +15 -0
- package/dist/text.css +7 -0
- package/dist/textModel.d.ts +3 -0
- package/dist/textModel.js +24 -0
- package/dist/toast.css +13 -0
- package/dist/tokens.d.ts +34 -0
- package/dist/tokens.js +10 -0
- package/dist/tour.css +8 -0
- package/dist/transition.css +12 -0
- package/dist/upload.css +11 -0
- package/dist/useCountDown.d.ts +14 -0
- package/dist/useCountDown.js +73 -0
- package/dist/useDialog.d.ts +9 -0
- package/dist/useDialog.js +33 -0
- package/dist/useImagePreview.d.ts +7 -0
- package/dist/useImagePreview.js +17 -0
- package/dist/useNotify.d.ts +9 -0
- package/dist/useNotify.js +26 -0
- package/dist/usePressState.d.ts +6 -0
- package/dist/usePressState.js +17 -0
- package/dist/useToast.d.ts +11 -0
- package/dist/useToast.js +23 -0
- package/dist/useVideoPreview.d.ts +7 -0
- package/dist/useVideoPreview.js +17 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +4 -0
- package/dist/video-preview.css +7 -0
- package/dist/watermark.css +6 -0
- package/dist/web/imgCropperElement.d.ts +2 -0
- package/dist/web/imgCropperElement.js +309 -0
- package/dist/web/index.d.ts +6 -0
- package/dist/web/index.js +6 -0
- package/dist/web/qrCodeExportElement.d.ts +4 -0
- package/dist/web/qrCodeExportElement.js +70 -0
- package/dist/web/richTextMediaElement.d.ts +2 -0
- package/dist/web/richTextMediaElement.js +276 -0
- package/package.json +98 -4
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { progressPercentage } from './progressModel.js';
|
|
2
|
+
const escape = (value) => value.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
|
3
|
+
export function circleStops(color) {
|
|
4
|
+
if (typeof color === 'string')
|
|
5
|
+
return [];
|
|
6
|
+
return Object.entries(color).flatMap(([key, value]) => {
|
|
7
|
+
const number = /^(?:\d+(?:\.\d+)?|\.\d+)%?$/.test(key) ? Number.parseFloat(key) : NaN;
|
|
8
|
+
return Number.isFinite(number) ? [{ offset: progressPercentage(number), color: value }] : [];
|
|
9
|
+
}).sort((a, b) => a.offset - b.offset);
|
|
10
|
+
}
|
|
11
|
+
export function circleSvg({ value, size, color, layerColor, fill, strokeWidth, strokeLinecap, clockwise }) {
|
|
12
|
+
const diameter = Number.isFinite(size) ? Math.max(0, size) : 120;
|
|
13
|
+
if (!diameter)
|
|
14
|
+
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"/>';
|
|
15
|
+
const width = Number.isFinite(strokeWidth) ? Math.min(diameter, Math.max(0, strokeWidth)) : 18;
|
|
16
|
+
const center = diameter / 2, stroke = width / 2, radius = center - stroke / 2, rate = progressPercentage(value);
|
|
17
|
+
const stops = circleStops(color), paint = typeof color === 'string' ? escape(color) : stops.length ? 'url(#circle-gradient)' : '#1c64fd';
|
|
18
|
+
const definitions = stops.length ? `<defs><linearGradient id="circle-gradient" gradientUnits="userSpaceOnUse" x1="${diameter}" y1="0" x2="0" y2="0">${stops.map(stop => `<stop offset="${stop.offset}%" stop-color="${escape(stop.color)}"/>`).join('')}</linearGradient></defs>` : '';
|
|
19
|
+
const trackStroke = fill ? width : stroke, track = `<circle cx="${center}" cy="${center}" r="${center - trackStroke / 2}" fill="${fill ? escape(fill) : 'none'}" stroke="${escape(layerColor)}" stroke-width="${trackStroke}"/>`;
|
|
20
|
+
const attributes = `fill="none" stroke="${paint}" stroke-width="${stroke}" stroke-linecap="${strokeLinecap}"`;
|
|
21
|
+
let path = '';
|
|
22
|
+
if (stroke > 0 && rate === 0 && strokeLinecap === 'round')
|
|
23
|
+
path = `<circle cx="${center}" cy="${stroke / 2}" r="${stroke / 2}" fill="${paint}"/>`;
|
|
24
|
+
else if (stroke > 0 && rate === 100)
|
|
25
|
+
path = `<circle cx="${center}" cy="${center}" r="${radius}" ${attributes}/>`;
|
|
26
|
+
else if (stroke > 0 && rate > 0) {
|
|
27
|
+
const angle = rate / 100 * Math.PI * 2 * (clockwise ? 1 : -1), x = center + radius * Math.sin(angle), y = center - radius * Math.cos(angle);
|
|
28
|
+
path = `<path d="M${center} ${stroke / 2}A${radius} ${radius} 0 ${rate > 50 ? 1 : 0} ${clockwise ? 1 : 0} ${x.toFixed(5)} ${y.toFixed(5)}" ${attributes}/>`;
|
|
29
|
+
}
|
|
30
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${diameter} ${diameter}">${definitions}${track}${path}</svg>`;
|
|
31
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.ui-config-portal{position:relative;width:0;height:0;overflow:visible;}
|
|
2
|
+
.theme-dark{--cso-ui-light-display:none;--cso-ui-dark-display:flex;--cso-ui-disabled-text:#58585b;--cso-ui-avatar-bg:var(--cso-ui-surface-muted);--cso-ui-avatar-text:var(--cso-ui-text);--cso-ui-avatar-collapse-bg:var(--cso-ui-surface-muted);--cso-ui-avatar-collapse-color:var(--cso-ui-text-auxiliary,var(--cso-ui-text-muted));--cso-ui-tag-default-color:#e5e6eb;--cso-ui-tag-light-default-bg:var(--cso-ui-surface-muted);--cso-ui-tag-light-primary-bg:var(--cso-ui-surface-muted);--cso-ui-tag-light-danger-bg:var(--cso-ui-surface-muted);--cso-ui-tag-light-warning-bg:var(--cso-ui-surface-muted);--cso-ui-tag-light-success-bg:var(--cso-ui-surface-muted);--cso-ui-tag-light-volcano-bg:var(--cso-ui-surface-muted);--cso-ui-tag-light-lightblue-bg:var(--cso-ui-surface-muted);--cso-ui-tag-light-cyan-bg:var(--cso-ui-surface-muted);--cso-ui-tag-light-pink-bg:var(--cso-ui-surface-muted);--cso-ui-tag-light-purple-bg:var(--cso-ui-surface-muted);--cso-ui-picker-fade-top:linear-gradient(0deg,rgba(0,0,0,.2),rgba(0,0,0,.85));--cso-ui-picker-fade-bottom:linear-gradient(180deg,rgba(0,0,0,.2),rgba(0,0,0,.85));}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ButtonProps } from "./Button.jsx";
|
|
2
|
+
import type { TagProps } from "./Tag.jsx";
|
|
3
|
+
export type ConfigProviderTheme = 'light' | 'dark';
|
|
4
|
+
export type ConfigButtonDefaults = Pick<ButtonProps, 'size' | 'tone' | 'round'> & {
|
|
5
|
+
variant?: ButtonProps['variant'] | 'base';
|
|
6
|
+
type?: ButtonProps['tone'];
|
|
7
|
+
};
|
|
8
|
+
export type ConfigTagDefaults = Pick<TagProps, 'size' | 'variant' | 'round'>;
|
|
9
|
+
export type ConfigProviderThemeVars = Partial<Record<'primary' | 'onPrimary' | 'success' | 'warning' | 'danger' | 'info' | 'canvas' | 'surface' | 'surfaceMuted' | 'text' | 'textMuted' | 'line' | 'colorTheme' | 'buttonPrimaryBg' | 'buttonPrimaryBgColor' | 'buttonPrimaryColor' | 'buttonHeight' | 'buttonRadius' | 'buttonFontSize' | 'cellTitleColor', string | number>> & {
|
|
10
|
+
[key: `--cso-ui-${string}`]: string | number | undefined;
|
|
11
|
+
};
|
|
12
|
+
export type ConfigProviderValue = {
|
|
13
|
+
theme: ConfigProviderTheme;
|
|
14
|
+
themeVars: Record<string, string>;
|
|
15
|
+
button: ConfigButtonDefaults;
|
|
16
|
+
tag: ConfigTagDefaults;
|
|
17
|
+
/** Effective explicit tokens captured at the source of a native portal. */
|
|
18
|
+
tokens: Record<string, string>;
|
|
19
|
+
};
|
|
20
|
+
export declare const ConfigContext: import("react").Context<ConfigProviderValue | undefined>;
|
|
21
|
+
/** Reads the nearest scoped configuration; updates are driven by Provider props. */
|
|
22
|
+
export declare function useConfigProvider(): ConfigProviderValue;
|
|
23
|
+
export declare function configThemeVars(input: ConfigProviderThemeVars | undefined): Record<string, string>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createContext, useContext } from '@lynx-js/react';
|
|
2
|
+
export const ConfigContext = createContext(undefined);
|
|
3
|
+
const defaults = { theme: 'light', themeVars: {}, button: {}, tag: {}, tokens: {} };
|
|
4
|
+
/** Reads the nearest scoped configuration; updates are driven by Provider props. */
|
|
5
|
+
export function useConfigProvider() {
|
|
6
|
+
return useContext(ConfigContext) ?? defaults;
|
|
7
|
+
}
|
|
8
|
+
const aliases = {
|
|
9
|
+
colorTheme: 'primary', buttonPrimaryBg: 'button-primary-bg', buttonPrimaryBgColor: 'button-primary-bg', buttonPrimaryColor: 'button-primary-color',
|
|
10
|
+
buttonHeight: 'button-height', buttonRadius: 'button-radius', buttonFontSize: 'button-font-size', cellTitleColor: 'cell-title-color',
|
|
11
|
+
};
|
|
12
|
+
const semantics = new Set(['primary', 'onPrimary', 'success', 'warning', 'danger', 'info', 'canvas', 'surface', 'surfaceMuted', 'text', 'textMuted', 'line']);
|
|
13
|
+
export function configThemeVars(input) {
|
|
14
|
+
const output = {};
|
|
15
|
+
for (const [name, value] of Object.entries(input ?? {})) {
|
|
16
|
+
if (value === undefined || typeof value === 'number' && !Number.isFinite(value))
|
|
17
|
+
continue;
|
|
18
|
+
const key = name.startsWith('--cso-ui-') ? name : aliases[name] ? `--cso-ui-${aliases[name]}` : semantics.has(name) ? `--cso-ui-${name.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`)}` : undefined;
|
|
19
|
+
if (!key)
|
|
20
|
+
continue;
|
|
21
|
+
output[key] = typeof value === 'number' && ['buttonHeight', 'buttonRadius', 'buttonFontSize'].includes(name) ? `${value}px` : String(value);
|
|
22
|
+
}
|
|
23
|
+
return output;
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** These palettes preserve the existing business theme; CSS variables remain public. */
|
|
2
|
+
const colors = {
|
|
3
|
+
light: { canvas: '#f5f7fa', surface: '#fff', 'surface-muted': '#f8fafc', text: '#17212e', 'text-muted': '#697586', line: '#e6eaf0', primary: '#f86100', 'on-primary': '#fff', success: '#1f9d67', info: '#236fd4', warning: '#b86b00', danger: '#d63b47', hero: '#17212e', 'hero-text': '#fff', 'hero-muted': '#d5dbe4' },
|
|
4
|
+
dark: { canvas: '#10151c', surface: '#171e27', 'surface-muted': '#202936', text: '#f3f6fa', 'text-muted': '#aeb9c8', line: '#303b4a', primary: '#ff812e', 'on-primary': '#16110d', success: '#56c891', info: '#78aeff', warning: '#f0b450', danger: '#ff7f8a', hero: '#0c1117', 'hero-text': '#f7f9fc', 'hero-muted': '#b4c0d0' },
|
|
5
|
+
};
|
|
6
|
+
export function configThemeTokens(theme) {
|
|
7
|
+
return { ...Object.fromEntries(Object.entries(colors[theme]).map(([key, value]) => [`--cso-ui-${key}`, value])), ...configThemeAppearance(theme) };
|
|
8
|
+
}
|
|
9
|
+
export function configThemeAppearance(theme) {
|
|
10
|
+
return {
|
|
11
|
+
'--cso-ui-light-display': theme === 'light' ? 'flex' : 'none', '--cso-ui-dark-display': theme === 'dark' ? 'flex' : 'none',
|
|
12
|
+
'--cso-ui-disabled-text': theme === 'dark' ? '#58585b' : '#c9cbd4',
|
|
13
|
+
'--cso-ui-avatar-bg': theme === 'dark' ? 'var(--cso-ui-surface-muted)' : 'var(--cso-ui-line)',
|
|
14
|
+
'--cso-ui-avatar-text': theme === 'dark' ? 'var(--cso-ui-text)' : 'var(--cso-ui-text-auxiliary,var(--cso-ui-text-muted))',
|
|
15
|
+
'--cso-ui-avatar-collapse-bg': theme === 'dark' ? 'var(--cso-ui-surface-muted)' : '#ebedf0',
|
|
16
|
+
'--cso-ui-avatar-collapse-color': theme === 'dark' ? 'var(--cso-ui-text-auxiliary,var(--cso-ui-text-muted))' : '#969799',
|
|
17
|
+
'--cso-ui-tag-default-color': theme === 'dark' ? '#e5e6eb' : '#4e5369',
|
|
18
|
+
...Object.fromEntries(Object.entries({ 'default': '#f2f3f5', 'primary': '#f5f8ff', 'danger': '#fff5f5', 'warning': '#fff6eb', 'success': '#f3fbf9', 'volcano': '#fff2e8', 'lightblue': '#e8fbff', 'cyan': '#f4fbfd', 'pink': '#fff0f5', 'purple': '#f9f5ff' }).map(([key, value]) => [`--cso-ui-tag-light-${key}-bg`, theme === 'dark' ? 'var(--cso-ui-surface-muted)' : value])),
|
|
19
|
+
'--cso-ui-picker-fade-top': theme === 'dark' ? 'linear-gradient(0deg,rgba(0,0,0,.2),rgba(0,0,0,.85))' : 'linear-gradient(0deg,rgba(255,255,255,.2),rgba(255,255,255,.85))',
|
|
20
|
+
'--cso-ui-picker-fade-bottom': theme === 'dark' ? 'linear-gradient(180deg,rgba(0,0,0,.2),rgba(0,0,0,.85))' : 'linear-gradient(180deg,rgba(255,255,255,.2),rgba(255,255,255,.85))',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
.ui-count-to{display:flex;flex-direction:row;align-items:baseline;color:var(--cso-ui-text);}
|
|
2
|
+
.ui-count-to-value{font-size:var(--cso-ui-count-to-font-size,18px);line-height:var(--cso-ui-count-to-line-height,26px);color:inherit;}
|
|
3
|
+
.ui-count-to-affix{font-size:12px;line-height:18px;color:inherit;}
|
|
4
|
+
.ui-count-to-primary{color:var(--cso-ui-primary);}
|
|
5
|
+
.ui-count-to-error{color:var(--cso-ui-danger);}
|
|
6
|
+
.ui-count-to-warning{color:var(--cso-ui-warning);}
|
|
7
|
+
.ui-count-to-success{color:var(--cso-ui-success);}
|
|
8
|
+
.ui-count-to-info{color:var(--cso-ui-info);}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type TimeData = {
|
|
2
|
+
total: number;
|
|
3
|
+
days: number;
|
|
4
|
+
hours: number;
|
|
5
|
+
minutes: number;
|
|
6
|
+
seconds: number;
|
|
7
|
+
milliseconds: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const countDownTime: (time: number) => number;
|
|
10
|
+
export declare function parseCountDown(time: number): TimeData;
|
|
11
|
+
export declare function formatCountDown(format: string, data: TimeData): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const countDownTime = (time) => Number.isFinite(time) ? Math.max(0, Math.floor(time)) : 0;
|
|
2
|
+
export function parseCountDown(time) { const total = countDownTime(time); return { total, days: Math.floor(total / 86400000), hours: Math.floor(total / 3600000) % 24, minutes: Math.floor(total / 60000) % 60, seconds: Math.floor(total / 1000) % 60, milliseconds: total % 1000 }; }
|
|
3
|
+
export function formatCountDown(format, data) { let { hours, minutes, seconds, milliseconds } = data; const pad = (n, digits = 2) => String(n).padStart(digits, '0'); if (!format.includes('DD'))
|
|
4
|
+
hours += data.days * 24; if (!format.includes('HH'))
|
|
5
|
+
minutes += hours * 60; if (!format.includes('mm'))
|
|
6
|
+
seconds += minutes * 60; if (!format.includes('ss'))
|
|
7
|
+
milliseconds += seconds * 1000; return format.replace(/DD|HH|mm|ss|SSS|SS|S/g, token => token === 'DD' ? pad(data.days) : token === 'HH' ? pad(hours) : token === 'mm' ? pad(minutes) : token === 'ss' ? pad(seconds) : pad(milliseconds, 3).slice(0, token.length)); }
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const countToNumber: (value: number, fallback?: number) => number;
|
|
2
|
+
export declare function countToValue(start: number, end: number, progress: number, easing?: boolean): number;
|
|
3
|
+
export declare function formatCountTo(value: number, decimals?: number, decimal?: string, separator?: string): string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export const countToNumber = (value, fallback = 0) => Number.isFinite(value) ? value : fallback;
|
|
2
|
+
export function countToValue(start, end, progress, easing = true) { const p = Math.max(0, Math.min(1, progress)), ratio = p === 1 ? 1 : easing ? 1 - Math.pow(2, -10 * p) : p; return start + (end - start) * ratio; }
|
|
3
|
+
export function formatCountTo(value, decimals = 0, decimal = '.', separator = ',') { const digits = Number.isFinite(decimals) ? Math.max(0, Math.min(20, Math.floor(decimals))) : 0; const [integer, fraction] = countToNumber(value).toFixed(digits).split('.'); return integer.replace(/\B(?=(\d{3})+(?!\d))/g, () => separator) + (fraction === undefined ? '' : decimal + fraction); }
|
package/dist/curtain.css
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
.ui-popup.ui-curtain{background:transparent;overflow:visible;border-radius:var(--cso-ui-curtain-radius,8px);}
|
|
2
|
+
.ui-curtain-content{position:relative;overflow:visible;}
|
|
3
|
+
.ui-curtain-image{border-radius:var(--cso-ui-curtain-radius,8px);}
|
|
4
|
+
.ui-curtain-close{position:absolute;top:16px;right:16px;width:32px;height:32px;display:flex;align-items:center;justify-content:center;}
|
|
5
|
+
.ui-curtain-close-top{top:-16px;left:50%;right:auto;transform:translate(-50%,-100%);}
|
|
6
|
+
.ui-curtain-close-top-left{top:-16px;left:0;right:auto;transform:translateY(-100%);}
|
|
7
|
+
.ui-curtain-close-top-right{top:-16px;right:0;transform:translateY(-100%);}
|
|
8
|
+
.ui-curtain-close-bottom{top:auto;bottom:-16px;left:50%;right:auto;transform:translate(-50%,100%);}
|
|
9
|
+
.ui-curtain-close-bottom-left{top:auto;bottom:-16px;left:0;right:auto;transform:translateY(100%);}
|
|
10
|
+
.ui-curtain-close-bottom-right{top:auto;bottom:-16px;right:0;transform:translateY(100%);}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
.ui-popup.ui-datetime-picker{border-radius:8px 8px 0 0;}
|
|
2
|
+
.ui-datetime-picker-toolbar{height:56px;padding:0 12px;display:flex;flex-direction:row;align-items:center;justify-content:space-between;}
|
|
3
|
+
.ui-datetime-picker-cancel,.ui-datetime-picker-confirm text{font-size:15px;line-height:22px;color:var(--cso-ui-primary);}
|
|
4
|
+
.ui-datetime-picker-title{font-size:18px;line-height:26px;font-weight:600;color:var(--cso-ui-text);}
|
|
5
|
+
.ui-datetime-picker-range{padding:0 12px 16px;display:flex;flex-direction:row;align-items:center;}
|
|
6
|
+
.ui-datetime-picker-range-item{position:relative;flex:1;min-width:0;padding:12px 0;}
|
|
7
|
+
.ui-datetime-picker-range-item text{font-family:"San Francisco",Roboto,Arial,"PingFang SC","Microsoft YaHei",sans-serif;font-size:16px;line-height:24px;font-weight:600;text-align:center;color:var(--cso-ui-text-placeholder,#a9acb8);}
|
|
8
|
+
.ui-datetime-picker-range-active text{color:var(--cso-ui-primary);}
|
|
9
|
+
.ui-datetime-picker-range-line{position:absolute;left:0;right:0;bottom:0;height:1px;background-color:var(--cso-ui-line);}
|
|
10
|
+
.ui-datetime-picker-range-active .ui-datetime-picker-range-line{background-color:var(--cso-ui-primary);}
|
|
11
|
+
.ui-datetime-picker-range-separator{width:8px;height:1px;margin:0 8px;background-color:var(--cso-ui-text-auxiliary,var(--cso-ui-text-muted));}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { PickerOption, PickerValue } from './pickerModel.js';
|
|
2
|
+
export type DatetimePickerType = 'datetime' | 'date' | 'year-month' | 'time' | 'year';
|
|
3
|
+
export type DatetimePickerValue = number | string;
|
|
4
|
+
export type DatetimeColumnType = 'year' | 'month' | 'date' | 'hour' | 'minute' | 'second';
|
|
5
|
+
export type DatetimeColumn = {
|
|
6
|
+
type: DatetimeColumnType;
|
|
7
|
+
values: number[];
|
|
8
|
+
};
|
|
9
|
+
export type DatetimeFilterParams = {
|
|
10
|
+
type: DatetimeColumnType;
|
|
11
|
+
values: number[];
|
|
12
|
+
};
|
|
13
|
+
export type DatetimeFilter = ((params: DatetimeFilterParams) => number[]) | ((type: string, values: number[]) => number[]);
|
|
14
|
+
export type DatetimeModelProps = {
|
|
15
|
+
value?: DatetimePickerValue;
|
|
16
|
+
type?: DatetimePickerType;
|
|
17
|
+
minDate?: number;
|
|
18
|
+
maxDate?: number;
|
|
19
|
+
minHour?: number;
|
|
20
|
+
maxHour?: number;
|
|
21
|
+
minMinute?: number;
|
|
22
|
+
maxMinute?: number;
|
|
23
|
+
useSecond?: boolean;
|
|
24
|
+
minSecond?: number;
|
|
25
|
+
maxSecond?: number;
|
|
26
|
+
boundaryMinDate?: number;
|
|
27
|
+
boundaryMaxDate?: number;
|
|
28
|
+
formatter?: (type: DatetimeColumnType, value: number) => string;
|
|
29
|
+
filter?: DatetimeFilter;
|
|
30
|
+
columnFormatter?: (columns: PickerOption[][]) => PickerOption[][];
|
|
31
|
+
};
|
|
32
|
+
export declare const datetimeDefaults: {
|
|
33
|
+
minDate: number;
|
|
34
|
+
maxDate: number;
|
|
35
|
+
};
|
|
36
|
+
export declare const datetimePad: (value: number, width?: number) => string;
|
|
37
|
+
export declare function datetimeParts(type?: DatetimePickerType, useSecond?: boolean): DatetimeColumnType[];
|
|
38
|
+
export declare function datetimeModel(props: DatetimeModelProps, selection?: readonly PickerValue[]): {
|
|
39
|
+
value: DatetimePickerValue;
|
|
40
|
+
columns: PickerOption[][];
|
|
41
|
+
origin: DatetimeColumn[];
|
|
42
|
+
parts: DatetimeColumnType[];
|
|
43
|
+
values: number[];
|
|
44
|
+
selectedOptions: PickerOption[];
|
|
45
|
+
valid: boolean;
|
|
46
|
+
};
|
|
47
|
+
export declare function datetimeLabel(value: DatetimePickerValue, type?: DatetimePickerType, useSecond?: boolean): string;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const year = new Date().getFullYear();
|
|
2
|
+
export const datetimeDefaults = { minDate: new Date(year - 10, 0, 1).getTime(), maxDate: new Date(year + 10, 11, 31, 23, 59, 59).getTime() };
|
|
3
|
+
const clamp = (value, low, high) => Math.max(low, Math.min(high, value));
|
|
4
|
+
export const datetimePad = (value, width = 2) => String(value).padStart(width, '0');
|
|
5
|
+
export function datetimeParts(type = 'datetime', useSecond = false) {
|
|
6
|
+
return type === 'year' ? ['year'] : type === 'year-month' ? ['year', 'month'] : type === 'date' ? ['year', 'month', 'date'] : [...(type === 'time' ? [] : ['year', 'month', 'date']), 'hour', 'minute', ...(useSecond ? ['second'] : [])];
|
|
7
|
+
}
|
|
8
|
+
function dateParts(value) {
|
|
9
|
+
const date = new Date(value);
|
|
10
|
+
return { year: date.getFullYear(), month: date.getMonth() + 1, date: date.getDate(), hour: date.getHours(), minute: date.getMinutes(), second: date.getSeconds() };
|
|
11
|
+
}
|
|
12
|
+
function timestamp(parts) {
|
|
13
|
+
const date = new Date(0);
|
|
14
|
+
date.setFullYear(parts.year, parts.month - 1, Math.min(parts.date, new Date(parts.year, parts.month, 0).getDate()));
|
|
15
|
+
date.setHours(parts.hour, parts.minute, parts.second, 0);
|
|
16
|
+
return date.getTime();
|
|
17
|
+
}
|
|
18
|
+
const matchesPrefix = (parts, boundary, keys, index) => keys.slice(0, index).every(key => parts[key] === boundary[key]);
|
|
19
|
+
export function datetimeModel(props, selection) {
|
|
20
|
+
const type = props.type ?? 'datetime', parts = datetimeParts(type, props.useSecond), minDate = props.minDate ?? datetimeDefaults.minDate, maxDate = props.maxDate ?? datetimeDefaults.maxDate;
|
|
21
|
+
if (!Number.isFinite(minDate) || !Number.isFinite(maxDate) || !Number.isFinite(new Date(minDate).getTime()) || !Number.isFinite(new Date(maxDate).getTime()) || minDate > maxDate)
|
|
22
|
+
throw new Error('Invalid DatetimePicker bounds');
|
|
23
|
+
const min = dateParts(minDate), max = dateParts(maxDate), validDate = typeof props.value === 'number' && Number.isFinite(props.value), requested = dateParts(validDate ? clamp(props.value, minDate, maxDate) : minDate);
|
|
24
|
+
if (type === 'time') {
|
|
25
|
+
const parsed = typeof props.value === 'string' && /^\d{1,2}:\d{2}(:\d{2})?$/.test(props.value) ? props.value.split(':').map(Number) : [];
|
|
26
|
+
requested.hour = parsed[0] ?? props.minHour ?? 0;
|
|
27
|
+
requested.minute = parsed[1] ?? props.minMinute ?? 0;
|
|
28
|
+
requested.second = parsed[2] ?? props.minSecond ?? 0;
|
|
29
|
+
}
|
|
30
|
+
parts.forEach((key, index) => { if (selection?.[index] !== undefined && Number.isFinite(Number(selection[index])))
|
|
31
|
+
requested[key] = Number(selection[index]); });
|
|
32
|
+
if (type !== 'time') {
|
|
33
|
+
const lower = Math.max(minDate, props.boundaryMinDate ?? minDate), upper = Math.min(maxDate, props.boundaryMaxDate ?? maxDate);
|
|
34
|
+
if (!Number.isFinite(lower) || !Number.isFinite(upper) || lower > upper)
|
|
35
|
+
throw new Error('Invalid DatetimePicker boundary');
|
|
36
|
+
Object.assign(requested, dateParts(clamp(timestamp(requested), lower, upper)));
|
|
37
|
+
}
|
|
38
|
+
const chosen = { ...requested }, rangeLow = props.boundaryMinDate === undefined ? undefined : dateParts(props.boundaryMinDate), rangeHigh = props.boundaryMaxDate === undefined ? undefined : dateParts(props.boundaryMaxDate);
|
|
39
|
+
if (rangeLow && !Number.isFinite(rangeLow.year) || rangeHigh && !Number.isFinite(rangeHigh.year))
|
|
40
|
+
throw new Error('Invalid DatetimePicker boundary');
|
|
41
|
+
let columns = [], origin = [], valid = true;
|
|
42
|
+
// Rebuild dependent columns when a formatter disables a parent option.
|
|
43
|
+
for (let pass = 0; pass <= parts.length; pass++) {
|
|
44
|
+
columns = [];
|
|
45
|
+
origin = [];
|
|
46
|
+
valid = true;
|
|
47
|
+
for (const [index, key] of parts.entries()) {
|
|
48
|
+
let low = 0, high = 59;
|
|
49
|
+
if (key === 'year') {
|
|
50
|
+
low = min.year;
|
|
51
|
+
high = max.year;
|
|
52
|
+
}
|
|
53
|
+
else if (key === 'month') {
|
|
54
|
+
low = matchesPrefix(chosen, min, parts, index) ? min.month : 1;
|
|
55
|
+
high = matchesPrefix(chosen, max, parts, index) ? max.month : 12;
|
|
56
|
+
}
|
|
57
|
+
else if (key === 'date') {
|
|
58
|
+
low = matchesPrefix(chosen, min, parts, index) ? min.date : 1;
|
|
59
|
+
high = Math.min(new Date(chosen.year, chosen.month, 0).getDate(), matchesPrefix(chosen, max, parts, index) ? max.date : 31);
|
|
60
|
+
}
|
|
61
|
+
else if (type === 'time') {
|
|
62
|
+
low = clamp(Math.trunc((key === 'hour' ? props.minHour : key === 'minute' ? props.minMinute : props.minSecond) ?? 0), 0, key === 'hour' ? 23 : 59);
|
|
63
|
+
high = clamp(Math.trunc((key === 'hour' ? props.maxHour : key === 'minute' ? props.maxMinute : props.maxSecond) ?? (key === 'hour' ? 23 : 59)), 0, key === 'hour' ? 23 : 59);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
low = matchesPrefix(chosen, min, parts, index) ? min[key] : 0;
|
|
67
|
+
high = matchesPrefix(chosen, max, parts, index) ? max[key] : key === 'hour' ? 23 : 59;
|
|
68
|
+
if (key === 'second') {
|
|
69
|
+
low = Math.max(low, props.minSecond ?? 0);
|
|
70
|
+
high = Math.min(high, props.maxSecond ?? 59);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (!Number.isFinite(low) || !Number.isFinite(high) || low > high)
|
|
74
|
+
throw new Error('Invalid DatetimePicker column bounds');
|
|
75
|
+
let values = Array.from({ length: high - low + 1 }, (_, index) => low + index);
|
|
76
|
+
if (props.filter) {
|
|
77
|
+
const filter = props.filter;
|
|
78
|
+
values = filter.length >= 2 ? filter(key, [...values]) : filter({ type: key, values: [...values] });
|
|
79
|
+
}
|
|
80
|
+
values = [...new Set(values.filter(value => Number.isInteger(value) && value >= low && value <= high))];
|
|
81
|
+
const items = values.map(value => ({ value, label: props.formatter?.(key, value) ?? datetimePad(value, key === 'year' ? 4 : 2), disabled: !!(rangeLow && matchesPrefix(chosen, rangeLow, parts, index) && value < rangeLow[key] || rangeHigh && matchesPrefix(chosen, rangeHigh, parts, index) && value > rangeHigh[key]) }));
|
|
82
|
+
const enabled = items.filter(item => !item.disabled), nearest = enabled.reduce((best, item) => !best || Math.abs(Number(item.value) - requested[key]) < Math.abs(Number(best.value) - requested[key]) ? item : best, undefined);
|
|
83
|
+
if (nearest)
|
|
84
|
+
chosen[key] = Number(nearest.value);
|
|
85
|
+
else
|
|
86
|
+
valid = false;
|
|
87
|
+
origin.push({ type: key, values });
|
|
88
|
+
columns.push(items);
|
|
89
|
+
}
|
|
90
|
+
if (!props.columnFormatter)
|
|
91
|
+
break;
|
|
92
|
+
const formatted = props.columnFormatter(columns.map(items => items.map(item => ({ ...item }))));
|
|
93
|
+
columns = columns.map((items, index) => (formatted[index] ?? []).flatMap(item => { const original = items.find(option => option.value === item.value); return original ? [{ ...original, ...item, disabled: original.disabled || item.disabled }] : []; }));
|
|
94
|
+
let changed = false;
|
|
95
|
+
columns.forEach((items, index) => {
|
|
96
|
+
const key = parts[index], enabled = items.filter(item => !item.disabled), nearest = enabled.reduce((best, item) => !best || Math.abs(Number(item.value) - chosen[key]) < Math.abs(Number(best.value) - chosen[key]) ? item : best, undefined);
|
|
97
|
+
if (!nearest) {
|
|
98
|
+
valid = false;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (chosen[key] !== Number(nearest.value)) {
|
|
102
|
+
chosen[key] = Number(nearest.value);
|
|
103
|
+
requested[key] = chosen[key];
|
|
104
|
+
changed = true;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
if (!changed)
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
const selectedOptions = columns.flatMap((items, index) => { const item = items.find(item => item.value === chosen[parts[index]] && !item.disabled); return item ? [item] : []; });
|
|
111
|
+
valid = valid && selectedOptions.length === parts.length;
|
|
112
|
+
let value = '';
|
|
113
|
+
if (valid && type === 'time')
|
|
114
|
+
value = ['hour', 'minute', ...(props.useSecond ? ['second'] : [])].map(key => datetimePad(chosen[key])).join(':');
|
|
115
|
+
else if (valid) {
|
|
116
|
+
const normalized = { ...chosen, month: type === 'year' ? 1 : chosen.month, date: type === 'year' || type === 'year-month' ? 1 : chosen.date, hour: type === 'datetime' ? chosen.hour : 0, minute: type === 'datetime' ? chosen.minute : 0, second: type === 'datetime' && props.useSecond ? chosen.second : 0 };
|
|
117
|
+
value = clamp(timestamp(normalized), Math.max(minDate, props.boundaryMinDate ?? minDate), Math.min(maxDate, props.boundaryMaxDate ?? maxDate));
|
|
118
|
+
}
|
|
119
|
+
return { value, columns, origin, parts, values: parts.map(key => chosen[key]), selectedOptions, valid };
|
|
120
|
+
}
|
|
121
|
+
export function datetimeLabel(value, type = 'datetime', useSecond = false) {
|
|
122
|
+
if (value === '')
|
|
123
|
+
return '';
|
|
124
|
+
if (type === 'time')
|
|
125
|
+
return String(value);
|
|
126
|
+
const parts = dateParts(Number(value)), date = `${datetimePad(parts.year, 4)}-${datetimePad(parts.month)}-${datetimePad(parts.date)}`;
|
|
127
|
+
return type === 'year' ? datetimePad(parts.year, 4) : type === 'year-month' ? date.slice(0, 7) : type === 'date' ? date : `${date} ${datetimePad(parts.hour)}:${datetimePad(parts.minute)}${useSecond ? `:${datetimePad(parts.second)}` : ''}`;
|
|
128
|
+
}
|
package/dist/dialog.css
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.ui-dialog { width: 280px; background-color: transparent; }
|
|
2
|
+
.ui-dialog-container { width: 100%; border-radius: 8px; overflow: hidden; background-color: var(--cso-ui-surface); }
|
|
3
|
+
.ui-dialog-body { padding: 20px 20px 0; }
|
|
4
|
+
.ui-dialog-title { width: 100%; color: var(--cso-ui-text); font-size: 16px; font-weight: 600; line-height: 24px; text-align: center; }
|
|
5
|
+
.ui-dialog-message { color: var(--cso-ui-text-muted); font-size: 14px; line-height: 20px; text-align: center; }
|
|
6
|
+
.ui-dialog-message-titled { margin-top: 8px; }
|
|
7
|
+
.ui-dialog-actions { padding: 20px; display: flex; gap: 12px; }
|
|
8
|
+
.ui-dialog-actions-horizontal { flex-direction: row; }
|
|
9
|
+
.ui-dialog-action { flex: 1; min-width: 0; }
|
|
10
|
+
.ui-dialog-actions-vertical { flex-direction: column; }
|
|
11
|
+
.ui-dialog-actions-vertical .ui-dialog-action { flex: none; width: 100%; }
|
|
12
|
+
.ui-dialog-theme-text .ui-dialog-body { padding-bottom: 20px; }
|
|
13
|
+
.ui-dialog-theme-text .ui-dialog-actions { padding: 0; gap: 0; border-top: .5px solid var(--cso-ui-line); }
|
|
14
|
+
.ui-dialog-theme-text .ui-dialog-action + .ui-dialog-action { border-left: .5px solid var(--cso-ui-line); }
|
|
15
|
+
.ui-dialog-theme-text .ui-dialog-actions-vertical .ui-dialog-action + .ui-dialog-action { border-left: 0; border-top: .5px solid var(--cso-ui-line); }
|
|
16
|
+
.ui-dialog-theme-text .ui-button { height: 48px; border-radius: 0; }
|
|
17
|
+
.ui-dialog-input-wrap { margin-top: 16px; padding: 12px; background-color: var(--cso-ui-canvas); }
|
|
18
|
+
.ui-dialog-input { width: 100%; height: 20px; font-size: 14px; color: var(--cso-ui-text); background-color: transparent; }
|
|
19
|
+
textarea.ui-dialog-input { height: 80px; }
|
|
20
|
+
.ui-dialog-input-error { border-color: var(--cso-ui-danger); }
|
|
21
|
+
.ui-dialog-error { margin-top: 8px; color: var(--cso-ui-danger); font-size: 12px; line-height: 18px; }
|
|
22
|
+
.ui-dialog-header-image { width: 280px; height: 140px; }
|
|
23
|
+
.ui-dialog-icon { display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
|
package/dist/divider.css
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.ui-divider { margin: 16px 0; padding: 0 16px; display: flex; flex-direction: row; align-items: center; }
|
|
2
|
+
.ui-divider-line { flex: 1; height: var(--cso-ui-divider-line-width, 1px); border-top-width: var(--cso-ui-divider-line-width, 1px); border-top-style: solid; border-color: var(--cso-ui-divider-line-color, var(--cso-ui-line)); }
|
|
3
|
+
.ui-divider-hairline .ui-divider-line { transform: scaleY(.5); }
|
|
4
|
+
.ui-divider-with-content .ui-divider-line:first-child { margin-right: 12px; }
|
|
5
|
+
.ui-divider-with-content .ui-divider-line:last-child { margin-left: 12px; }
|
|
6
|
+
.ui-divider-content { flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
|
|
7
|
+
.ui-divider-label { font-size: 14px; line-height: 20px; color: var(--cso-ui-text-auxiliary, var(--cso-ui-text-muted)); }
|
|
8
|
+
.ui-divider-left.ui-divider-with-content .ui-divider-line:first-child { max-width: 10%; }
|
|
9
|
+
.ui-divider-right.ui-divider-with-content .ui-divider-line:last-child { max-width: 10%; }
|
|
10
|
+
.ui-divider-dashed .ui-divider-line { border-top-style: dashed; }
|
|
11
|
+
.ui-divider-vertical { width: var(--cso-ui-divider-line-width, 1px); height: 16px; margin: 0 8px; padding: 0; flex-shrink: 0; }
|
|
12
|
+
.ui-divider-vertical .ui-divider-line { width: 100%; height: 100%; flex: none; border-top-width: 0; border-left-width: var(--cso-ui-divider-line-width, 1px); border-left-style: solid; }
|
|
13
|
+
.ui-divider-vertical.ui-divider-hairline .ui-divider-line { transform: scaleX(.5); }
|
|
14
|
+
.ui-divider-vertical.ui-divider-dashed .ui-divider-line { border-left-style: dashed; }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.ui-drop-menu { position: relative; height: 48px; min-width: 0; display: flex; flex-direction: row; background-color: var(--cso-ui-surface); }
|
|
2
|
+
.ui-drop-menu-item { flex: 1; min-width: 0; padding: 12px; display: flex; flex-direction: row; justify-content: center; align-items: center; }
|
|
3
|
+
.ui-drop-menu-title { min-width: 0; max-width: 100%; display: flex; flex-direction: row; align-items: center; }
|
|
4
|
+
.ui-drop-menu-title-text { min-width: 0; flex-shrink: 1; font-size: 16px; line-height: 24px; color: var(--cso-ui-text); }
|
|
5
|
+
.ui-drop-menu-arrow { margin-left: 4px; flex-shrink: 0; transition-property: transform; transition-timing-function: ease; }
|
|
6
|
+
.ui-drop-menu-item-open .ui-drop-menu-title-text { color: var(--cso-ui-primary); }
|
|
7
|
+
.ui-drop-menu-item-disabled { opacity: .4; }
|
|
8
|
+
.ui-drop-menu-layer { position: fixed; left: 0; right: 0; overflow: hidden; display: flex; flex-direction: column; }
|
|
9
|
+
.ui-drop-menu-layer-down { justify-content: flex-start; }
|
|
10
|
+
.ui-drop-menu-layer-up { justify-content: flex-end; }
|
|
11
|
+
.ui-drop-menu-popup { display: flex; flex-direction: column; max-height: 100%; flex-shrink: 1; background-color: var(--cso-ui-surface); }
|
|
12
|
+
.ui-drop-menu-scroll { width: 100%; max-height: 80vh; flex-shrink: 1; min-height: 0; }
|
|
13
|
+
.ui-drop-menu-content { border-top: 1px solid var(--cso-ui-line); display: flex; flex-direction: column; width: 100%; flex-shrink: 0; }
|
|
14
|
+
.ui-drop-menu-options { width: 100%; display: flex; flex-direction: column; }
|
|
15
|
+
.ui-drop-menu-option { min-height: 48px; padding: 12px; display: flex; flex-direction: row; justify-content: space-between; align-items: center; }
|
|
16
|
+
.ui-drop-menu-option-copy { min-width: 0; flex: 1; display: flex; flex-direction: row; align-items: center; }
|
|
17
|
+
.ui-drop-menu-option-label { min-width: 0; flex-shrink: 1; color: var(--cso-ui-text); font-size: 16px; line-height: 24px; }
|
|
18
|
+
.ui-drop-menu-option-tip { min-width: 0; flex-shrink: 1; margin-left: 8px; color: var(--cso-ui-text-auxiliary, var(--cso-ui-text-muted)); font-size: 14px; line-height: 20px; }
|
|
19
|
+
.ui-drop-menu-option-selected .ui-drop-menu-option-label, .ui-drop-menu-option-selected .ui-drop-menu-option-tip { color: var(--cso-ui-primary); }
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/* The clip wrapper has no hit target; the panel and the separate Overlay do. */
|
|
24
|
+
.ui-drop-menu-layer { pointer-events: none; }
|
|
25
|
+
.ui-drop-menu-popup { pointer-events: auto; }
|
|
26
|
+
|
|
27
|
+
.ui-drop-menu-primary-light{display:var(--cso-ui-light-display,flex);}
|
|
28
|
+
.ui-drop-menu-primary-dark{display:var(--cso-ui-dark-display,none);}
|
package/dist/empty.css
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
.ui-empty{width:100%;display:flex;flex-direction:column;align-items:center;box-sizing:border-box;padding-bottom:var(--cso-ui-empty-padding-bottom,24px);}
|
|
2
|
+
.ui-empty-icon{position:relative;flex-shrink:0;}
|
|
3
|
+
.ui-empty .ui-empty-glyph{position:absolute;left:0;top:0;width:100%!important;height:100%!important;}
|
|
4
|
+
.ui-empty-glyph-dark{display:none;}
|
|
5
|
+
.theme-dark .ui-empty-glyph-light{display:none;}
|
|
6
|
+
.theme-dark .ui-empty-glyph-dark{display:flex;}
|
|
7
|
+
.ui-empty-tip{margin-top:12px;font-size:16px;line-height:24px;font-weight:600;color:var(--cso-ui-text);text-align:center;word-break:break-all;}
|
package/dist/fab.css
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.ui-fab-viewport { position: fixed; left: 0; top: 0; width: 100%; height: 0; }
|
|
2
|
+
.ui-fab-viewport-vertical { width: 0; height: 100%; }
|
|
3
|
+
.ui-fab { position: fixed; display: flex; flex-direction: column; align-items: flex-start; transition-property: left, top; transition-timing-function: ease; }
|
|
4
|
+
.ui-fab-trigger { display: flex; flex-direction: column; align-items: flex-start; }
|
|
5
|
+
.ui-fab .ui-fab-default-trigger { width: 60px; height: 60px; padding: 0; border-radius: 50%; }
|
|
6
|
+
.ui-fab-default-trigger .ui-button-icon { width: 32px; height: 32px; }
|
|
7
|
+
.ui-fab-actions { position: absolute; display: flex; align-items: center; justify-content: center; padding: 20px 0; }
|
|
8
|
+
.ui-fab-actions-top, .ui-fab-actions-bottom { width: 100%; left: 0; }
|
|
9
|
+
.ui-fab-actions-top { bottom: 100%; }
|
|
10
|
+
.ui-fab-actions-bottom { top: 100%; }
|
|
11
|
+
.ui-fab-action-content { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
|
|
12
|
+
.ui-fab-actions-top .ui-fab-action-content { flex-direction: column-reverse; }
|
|
13
|
+
.ui-fab-actions-bottom .ui-fab-action-content { flex-direction: column; }
|
|
14
|
+
.ui-fab-actions-left, .ui-fab-actions-right { height: 100%; top: 0; padding: 0 20px; }
|
|
15
|
+
.ui-fab-actions-left { right: 100%; }
|
|
16
|
+
.ui-fab-actions-right { left: 100%; }
|
|
17
|
+
.ui-fab-actions-left .ui-fab-action-content { flex-direction: row-reverse; }
|
|
18
|
+
.ui-fab-actions-right .ui-fab-action-content { flex-direction: row; }
|
|
19
|
+
.ui-fab-offset-top { opacity: 0; transform: translateY(40px); }
|
|
20
|
+
.ui-fab-offset-bottom { opacity: 0; transform: translateY(-40px); }
|
|
21
|
+
.ui-fab-offset-left { opacity: 0; transform: translateX(40px); }
|
|
22
|
+
.ui-fab-offset-right { opacity: 0; transform: translateX(-40px); }
|
|
23
|
+
.ui-fab-actions-animating { transition-timing-function: cubic-bezier(.4,0,.2,1); }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type FabPosition = 'left-top' | 'right-top' | 'left-bottom' | 'right-bottom' | 'left-center' | 'right-center' | 'top-center' | 'bottom-center';
|
|
2
|
+
export type FabDirection = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
export type FabGap = {
|
|
4
|
+
top?: number;
|
|
5
|
+
left?: number;
|
|
6
|
+
right?: number;
|
|
7
|
+
bottom?: number;
|
|
8
|
+
};
|
|
9
|
+
export type FabPoint = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
export type FabBounds = {
|
|
14
|
+
minX: number;
|
|
15
|
+
minY: number;
|
|
16
|
+
maxX: number;
|
|
17
|
+
maxY: number;
|
|
18
|
+
};
|
|
19
|
+
export declare function fabBounds(width: number, height: number, triggerWidth: number, triggerHeight: number, gap: FabGap): FabBounds;
|
|
20
|
+
export declare function fabPosition(position: FabPosition, bounds: FabBounds): FabPoint;
|
|
21
|
+
export declare function clampFab(point: FabPoint, bounds: FabBounds): FabPoint;
|
|
22
|
+
export declare function snapFab(point: FabPoint, bounds: FabBounds): {
|
|
23
|
+
x: number;
|
|
24
|
+
direction: FabDirection;
|
|
25
|
+
y: number;
|
|
26
|
+
};
|
package/dist/fabModel.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function fabBounds(width, height, triggerWidth, triggerHeight, gap) {
|
|
2
|
+
const edge = (value) => Number.isFinite(value) ? Math.max(0, value) : 16;
|
|
3
|
+
const minX = Math.min(edge(gap.left), Math.max(0, width - triggerWidth));
|
|
4
|
+
const minY = Math.min(edge(gap.top), Math.max(0, height - triggerHeight));
|
|
5
|
+
return { minX, minY, maxX: Math.max(minX, width - triggerWidth - edge(gap.right)), maxY: Math.max(minY, height - triggerHeight - edge(gap.bottom)) };
|
|
6
|
+
}
|
|
7
|
+
export function fabPosition(position, bounds) {
|
|
8
|
+
return { x: position.startsWith('left-') ? bounds.minX : position.startsWith('right-') ? bounds.maxX : (bounds.minX + bounds.maxX) / 2, y: position.endsWith('-top') || position === 'top-center' ? bounds.minY : position.endsWith('-bottom') || position === 'bottom-center' ? bounds.maxY : (bounds.minY + bounds.maxY) / 2 };
|
|
9
|
+
}
|
|
10
|
+
export function clampFab(point, bounds) {
|
|
11
|
+
return { x: Math.min(bounds.maxX, Math.max(bounds.minX, point.x)), y: Math.min(bounds.maxY, Math.max(bounds.minY, point.y)) };
|
|
12
|
+
}
|
|
13
|
+
export function snapFab(point, bounds) {
|
|
14
|
+
const left = point.x <= (bounds.minX + bounds.maxX) / 2;
|
|
15
|
+
return { ...clampFab(point, bounds), x: left ? bounds.minX : bounds.maxX, direction: (left ? 'right' : 'left') };
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
.ui-floating-panel-viewport { position: fixed; width: 100vw; height: 100vh; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; }
|
|
2
|
+
.ui-floating-panel { position: fixed; bottom: 0; left: 0; right: 0; border-radius: 8px 8px 0 0; background-color: var(--cso-ui-surface); display: flex; flex-direction: column; overflow: hidden; box-sizing: border-box; transition-property: transform; transition-timing-function: cubic-bezier(.18,.89,.32,1.28); }
|
|
3
|
+
.ui-floating-panel-header { height: 32px; flex-shrink: 0; display: flex; flex-direction: row; align-items: center; justify-content: center; }
|
|
4
|
+
.ui-floating-panel-bar { width: 36px; height: 4px; border-radius: 4px; background-color: var(--cso-ui-line); }
|
|
5
|
+
.ui-floating-panel-scroll { width: 100%; flex: 1; min-height: 0; }
|
|
6
|
+
.ui-floating-panel-content { width: 100%; display: flex; flex-direction: column; }
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function panelAnchors(input: readonly number[] | undefined, viewport: number): number[];
|
|
2
|
+
export declare function panelHeight(value: number | undefined, anchors: readonly number[]): number;
|
|
3
|
+
export declare function nearestPanelAnchor(height: number, anchors: readonly number[]): number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function panelAnchors(input, viewport) {
|
|
2
|
+
const values = (input ?? [100, viewport * .6]).filter(value => Number.isFinite(value) && value > 0).map(value => viewport > 0 ? Math.min(value, viewport) : value);
|
|
3
|
+
return [...new Set(values.length ? values : [viewport > 0 ? Math.min(100, viewport) : 100])].sort((a, b) => a - b);
|
|
4
|
+
}
|
|
5
|
+
export function panelHeight(value, anchors) {
|
|
6
|
+
return Math.min(anchors[anchors.length - 1], Math.max(anchors[0], value && Number.isFinite(value) ? value : anchors[0]));
|
|
7
|
+
}
|
|
8
|
+
export function nearestPanelAnchor(height, anchors) {
|
|
9
|
+
return anchors.reduce((nearest, value) => Math.abs(value - height) < Math.abs(nearest - height) ? value : nearest, anchors[0]);
|
|
10
|
+
}
|
package/dist/form.css
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
.ui-form,.ui-form-item,.ui-form-item-content{display:flex;flex-direction:column;}
|
|
2
|
+
.ui-form-item-content{width:100%;min-width:0;}
|
|
3
|
+
.ui-form-item-error{margin-top:4px;color:var(--cso-ui-danger);font-size:12px;line-height:16px;}
|
|
4
|
+
.ui-form-item-value{font-size:14px;line-height:20px;color:var(--cso-ui-text);}
|
|
5
|
+
.ui-form-item-placeholder{font-size:14px;line-height:20px;color:var(--cso-ui-text-placeholder,var(--cso-ui-text-muted));}
|
|
6
|
+
.ui-form-item-disabled .ui-cell-title,.ui-form-item-disabled .ui-form-item-value,.ui-form-item-disabled .ui-form-item-placeholder{color:var(--cso-ui-text-disabled,#c9cbd4);}
|
|
7
|
+
|
|
8
|
+
.ui-form>.ui-form-item:first-child .ui-cell-border{display:none;}
|
|
9
|
+
|
|
10
|
+
.ui-form>.ui-cell-group:first-child .ui-form-item:first-child .ui-cell-border{display:none;}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type FormModel = Record<string, unknown>;
|
|
2
|
+
export type FormSchemaIssue = {
|
|
3
|
+
path: string | readonly (string | number)[];
|
|
4
|
+
message: string;
|
|
5
|
+
};
|
|
6
|
+
export type FormSchema = {
|
|
7
|
+
validate: (model: FormModel) => readonly FormSchemaIssue[] | Promise<readonly FormSchemaIssue[]>;
|
|
8
|
+
isRequired?: (path: string) => boolean | undefined;
|
|
9
|
+
};
|
|
10
|
+
export type FormError = {
|
|
11
|
+
prop: string;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
export type FormValidateResult = {
|
|
15
|
+
valid: boolean;
|
|
16
|
+
errors: FormError[];
|
|
17
|
+
outOfDate?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type FormValidateTrigger = 'submit' | 'change' | 'blur';
|
|
20
|
+
export declare const formPath: (path: FormSchemaIssue["path"]) => string;
|
|
21
|
+
export declare const includesFormPath: (parent: string, child: string) => boolean;
|
|
22
|
+
export declare function formValue(model: unknown, path: string): unknown;
|
|
23
|
+
export declare function copyFormValue<T>(value: T): T;
|
|
24
|
+
export declare function equalFormValue(a: unknown, b: unknown): boolean;
|
|
25
|
+
/** Structural adapter: Zod stays an optional application dependency. */
|
|
26
|
+
export declare function zodAdapter(schema: {
|
|
27
|
+
safeParseAsync: (model: unknown) => Promise<{
|
|
28
|
+
success: boolean;
|
|
29
|
+
error?: {
|
|
30
|
+
issues: readonly {
|
|
31
|
+
path: readonly PropertyKey[];
|
|
32
|
+
message: string;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
}, options?: FormSchema['isRequired'] | {
|
|
37
|
+
isRequired?: FormSchema['isRequired'];
|
|
38
|
+
}): FormSchema;
|