@m3ui-vue/m3ui-vue 0.9.0 → 0.9.2
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/README.md +53 -2
- package/dist/API.md +3806 -0
- package/dist/MIcon-CaEooCmZ.js.map +1 -1
- package/dist/{MTextField-B0wGv1Mx.js → MTextField-Ck0oWDMk.js} +9 -3
- package/dist/MTextField-Ck0oWDMk.js.map +1 -0
- package/dist/api.json +1 -0
- package/dist/barcode.js.map +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/code-editor.js +2 -2
- package/dist/code-editor.js.map +1 -1
- package/dist/components/MAbsolute.vue.d.ts +12 -0
- package/dist/components/MAlert.vue.d.ts +4 -0
- package/dist/components/MAppBar.vue.d.ts +12 -0
- package/dist/components/MAppLayout.vue.d.ts +2 -0
- package/dist/components/MAspectRatio.vue.d.ts +1 -0
- package/dist/components/MAutocomplete.vue.d.ts +18 -0
- package/dist/components/MAvatar.vue.d.ts +3 -0
- package/dist/components/MBadge.vue.d.ts +6 -0
- package/dist/components/MBar.vue.d.ts +5 -0
- package/dist/components/MBarcode.vue.d.ts +9 -0
- package/dist/components/MBottomSheet.vue.d.ts +3 -0
- package/dist/components/MBox.vue.d.ts +8 -2
- package/dist/components/MBreadcrumbs.vue.d.ts +2 -0
- package/dist/components/MButton.vue.d.ts +14 -4
- package/dist/components/MButtonGroup.vue.d.ts +7 -0
- package/dist/components/MCalendar.vue.d.ts +8 -0
- package/dist/components/MCard.vue.d.ts +17 -0
- package/dist/components/MCarousel.vue.d.ts +7 -1
- package/dist/components/MCenter.vue.d.ts +1 -0
- package/dist/components/MChart.vue.d.ts +7 -0
- package/dist/components/MChatBubble.vue.d.ts +10 -0
- package/dist/components/MCheckbox.vue.d.ts +5 -0
- package/dist/components/MChip.vue.d.ts +9 -0
- package/dist/components/MCircleProgressBar.vue.d.ts +7 -0
- package/dist/components/MCodeEditor.vue.d.ts +9 -0
- package/dist/components/MColorPicker.vue.d.ts +20 -0
- package/dist/components/MColorPickerModal.vue.d.ts +16 -0
- package/dist/components/MCommandPalette.vue.d.ts +8 -0
- package/dist/components/MConfirmDialog.vue.d.ts +7 -0
- package/dist/components/MContainer.vue.d.ts +4 -0
- package/dist/components/MContextMenu.vue.d.ts +3 -6
- package/dist/components/MCopyButton.vue.d.ts +10 -0
- package/dist/components/MDataTable.vue.d.ts +33 -12
- package/dist/components/MDatePicker.vue.d.ts +16 -0
- package/dist/components/MDatePickerModal.vue.d.ts +9 -0
- package/dist/components/MDateRangePicker.vue.d.ts +18 -0
- package/dist/components/MDateRangePickerModal.vue.d.ts +9 -0
- package/dist/components/MDialog.vue.d.ts +9 -7
- package/dist/components/MDivider.vue.d.ts +6 -0
- package/dist/components/MDragDropList.vue.d.ts +6 -0
- package/dist/components/MDragHandle.vue.d.ts +12 -0
- package/dist/components/MEmoji.vue.d.ts +6 -0
- package/dist/components/MEmojiButton.vue.d.ts +5 -0
- package/dist/components/MEmojiSelector.vue.d.ts +1 -1
- package/dist/components/MEmptyState.vue.d.ts +4 -0
- package/dist/components/MExpansionPanel.vue.d.ts +9 -0
- package/dist/components/MExportButton.vue.d.ts +8 -0
- package/dist/components/MFab.vue.d.ts +10 -1
- package/dist/components/MFabMenu.vue.d.ts +15 -1
- package/dist/components/MFileUpload.vue.d.ts +8 -0
- package/dist/components/MFixed.vue.d.ts +10 -0
- package/dist/components/MFlex.vue.d.ts +6 -0
- package/dist/components/MFooter.vue.d.ts +11 -0
- package/dist/components/MFullscreen.vue.d.ts +2 -0
- package/dist/components/MGrid.vue.d.ts +7 -0
- package/dist/components/MHotkeys.vue.d.ts +4 -0
- package/dist/components/MIcon.vue.d.ts +2 -0
- package/dist/components/MIconButton.vue.d.ts +10 -0
- package/dist/components/MInfiniteScroll.vue.d.ts +6 -0
- package/dist/components/MJsonEditor.vue.d.ts +8 -0
- package/dist/components/MJsonViewer.vue.d.ts +4 -0
- package/dist/components/MKanban.vue.d.ts +2 -0
- package/dist/components/MKbd.vue.d.ts +2 -0
- package/dist/components/MLightbox.vue.d.ts +4 -0
- package/dist/components/MList.vue.d.ts +7 -0
- package/dist/components/MListItem.vue.d.ts +29 -5
- package/dist/components/MListSubheader.vue.d.ts +6 -0
- package/dist/components/MLoadingIndicator.vue.d.ts +10 -0
- package/dist/components/MLoadingOverlay.vue.d.ts +5 -0
- package/dist/components/MMarkdown.vue.d.ts +3 -0
- package/dist/components/MMaskField.vue.d.ts +15 -0
- package/dist/components/MMasonry.vue.d.ts +5 -0
- package/dist/components/MMenu.vue.d.ts +3 -6
- package/dist/components/MMenuDivider.vue.d.ts +4 -0
- package/dist/components/MMenuItem.vue.d.ts +5 -0
- package/dist/components/MMultiAutocomplete.vue.d.ts +20 -0
- package/dist/components/MMultiSelect.vue.d.ts +21 -0
- package/dist/components/MNavigationBar.vue.d.ts +2 -0
- package/dist/components/MNavigationDrawer.vue.d.ts +11 -0
- package/dist/components/MNavigationRail.vue.d.ts +9 -6
- package/dist/components/MNavigationSuite.vue.d.ts +5 -3
- package/dist/components/MNumberField.vue.d.ts +17 -0
- package/dist/components/MOverlay.vue.d.ts +4 -1
- package/dist/components/MPageProgress.vue.d.ts +3 -0
- package/dist/components/MPagination.vue.d.ts +3 -0
- package/dist/components/MPasswordMeter.vue.d.ts +1 -0
- package/dist/components/MPinInput.vue.d.ts +11 -0
- package/dist/components/MProgressBar.vue.d.ts +6 -0
- package/dist/components/MPullToRefresh.vue.d.ts +8 -0
- package/dist/components/MQRCode.vue.d.ts +6 -0
- package/dist/components/MRadio.vue.d.ts +5 -0
- package/dist/components/MRadioGroup.vue.d.ts +6 -0
- package/dist/components/MRating.vue.d.ts +11 -0
- package/dist/components/MRelativeTime.vue.d.ts +1 -0
- package/dist/components/MResponsive.vue.d.ts +3 -0
- package/dist/components/MResult.vue.d.ts +6 -0
- package/dist/components/MRichTextEditor.vue.d.ts +8 -0
- package/dist/components/MScheduler.vue.d.ts +10 -0
- package/dist/components/MScrollField.vue.d.ts +40 -0
- package/dist/components/MScrollable.vue.d.ts +12 -0
- package/dist/components/MSearchBar.vue.d.ts +6 -0
- package/dist/components/MSection.vue.d.ts +5 -0
- package/dist/components/MSegmentedButton.vue.d.ts +5 -0
- package/dist/components/MSelect.vue.d.ts +17 -0
- package/dist/components/MShader.vue.d.ts +1 -0
- package/dist/components/MShortNavigationBar.vue.d.ts +8 -9
- package/dist/components/MSideSheet.vue.d.ts +3 -0
- package/dist/components/MSignaturePad.vue.d.ts +7 -0
- package/dist/components/MSimpleCarousel.vue.d.ts +10 -0
- package/dist/components/MSkeleton.vue.d.ts +8 -0
- package/dist/components/MSlider.vue.d.ts +14 -0
- package/dist/components/MSnackbar.vue.d.ts +1 -0
- package/dist/components/MSpinner.vue.d.ts +6 -0
- package/dist/components/MSplitButton.vue.d.ts +7 -0
- package/dist/components/MSplitter.vue.d.ts +6 -2
- package/dist/components/MSpotlightSearch.vue.d.ts +18 -0
- package/dist/components/MStack.vue.d.ts +7 -0
- package/dist/components/MStatCard.vue.d.ts +7 -0
- package/dist/components/MStepper.vue.d.ts +7 -0
- package/dist/components/MSticky.vue.d.ts +2 -0
- package/dist/components/MSubtitle.vue.d.ts +4 -0
- package/dist/components/MSwipeToDismiss.vue.d.ts +49 -0
- package/dist/components/MSwitch.vue.d.ts +5 -6
- package/dist/components/MTable.vue.d.ts +17 -4
- package/dist/components/MTabs.vue.d.ts +6 -0
- package/dist/components/MTagInput.vue.d.ts +17 -0
- package/dist/components/MTerminal.vue.d.ts +4 -0
- package/dist/components/MText.vue.d.ts +10 -0
- package/dist/components/MTextField.vue.d.ts +18 -0
- package/dist/components/MTimePicker.vue.d.ts +10 -0
- package/dist/components/MTimePickerModal.vue.d.ts +5 -0
- package/dist/components/MTimeline.vue.d.ts +3 -0
- package/dist/components/MTitle.vue.d.ts +4 -0
- package/dist/components/MToggleButton.vue.d.ts +4 -0
- package/dist/components/MToolbar.vue.d.ts +5 -0
- package/dist/components/MTooltip.vue.d.ts +7 -0
- package/dist/components/MTopAppBar.vue.d.ts +8 -0
- package/dist/components/MTour.vue.d.ts +5 -0
- package/dist/components/MTransferList.vue.d.ts +11 -0
- package/dist/components/MTransition.vue.d.ts +34 -0
- package/dist/components/MTree.vue.d.ts +11 -0
- package/dist/components/MTreeTable.vue.d.ts +7 -0
- package/dist/components/MVirtualTable.vue.d.ts +6 -0
- package/dist/components/MWindow.vue.d.ts +33 -1
- package/dist/components/_MColorPanel.vue.d.ts +18 -0
- package/dist/composables/_colorUtils.d.ts +34 -0
- package/dist/composables/_themeColor.d.ts +1 -0
- package/dist/composables/_useSpring.d.ts +15 -0
- package/dist/composables/dynamicColor.d.ts +18 -0
- package/dist/composables/useColorPalette.d.ts +27 -0
- package/dist/composables/useLocale.d.ts +12 -0
- package/dist/index.d.ts +9 -1
- package/dist/locales/index.js +70 -0
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +6456 -5273
- package/dist/m3ui.js.map +1 -1
- package/dist/markdown.js +1 -1
- package/dist/markdown.js.map +1 -1
- package/dist/material-color-utilities-Cktu8DBU.js +3160 -0
- package/dist/material-color-utilities-Cktu8DBU.js.map +1 -0
- package/dist/plugin.d.ts +18 -0
- package/dist/qrcode.js.map +1 -1
- package/dist/rich-text-editor.js +3 -3
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles/palettes.css +546 -0
- package/dist/styles/theme.css +77 -0
- package/dist/styles.css +1 -1
- package/dist/terminal.js.map +1 -1
- package/dist/{useLocale-CmI675Ab.js → useLocale-CFW8cIzL.js} +23 -10
- package/dist/useLocale-CFW8cIzL.js.map +1 -0
- package/package.json +5 -2
- package/src/__tests__/MButtonGroup.test.ts +51 -0
- package/src/__tests__/MColorPicker.test.ts +141 -0
- package/src/__tests__/MDragHandle.test.ts +57 -0
- package/src/__tests__/MHotkeys.test.ts +57 -0
- package/src/__tests__/MListItemShape.test.ts +76 -0
- package/src/__tests__/MScrollField.test.ts +41 -0
- package/src/__tests__/MScrollable.test.ts +42 -0
- package/src/__tests__/MSwipeToDismiss.test.ts +104 -0
- package/src/__tests__/MTransition.test.ts +27 -0
- package/src/__tests__/dynamicColor.test.ts +191 -0
- package/src/__tests__/hostLocale.test.ts +57 -0
- package/src/components/MAbsolute.vue +18 -0
- package/src/components/MAlert.vue +12 -0
- package/src/components/MAppBar.vue +12 -0
- package/src/components/MAppLayout.vue +11 -0
- package/src/components/MAspectRatio.vue +6 -0
- package/src/components/MAutocomplete.vue +24 -0
- package/src/components/MAvatar.vue +12 -1
- package/src/components/MBadge.vue +11 -0
- package/src/components/MBar.vue +19 -0
- package/src/components/MBarcode.vue +14 -0
- package/src/components/MBottomSheet.vue +12 -0
- package/src/components/MBox.vue +15 -1
- package/src/components/MBreadcrumbs.vue +7 -0
- package/src/components/MButton.vue +22 -4
- package/src/components/MButtonGroup.vue +129 -35
- package/src/components/MCalendar.vue +14 -0
- package/src/components/MCard.vue +26 -0
- package/src/components/MCarousel.vue +17 -1
- package/src/components/MCenter.vue +6 -0
- package/src/components/MChart.vue +12 -0
- package/src/components/MChatBubble.vue +17 -0
- package/src/components/MCheckbox.vue +11 -0
- package/src/components/MChip.vue +17 -0
- package/src/components/MCircleProgressBar.vue +13 -0
- package/src/components/MCodeEditor.vue +15 -0
- package/src/components/MColorPicker.vue +124 -207
- package/src/components/MColorPickerModal.vue +58 -247
- package/src/components/MCommandPalette.vue +16 -0
- package/src/components/MConfirmDialog.vue +15 -0
- package/src/components/MContainer.vue +9 -0
- package/src/components/MContextMenu.vue +17 -6
- package/src/components/MCopyButton.vue +16 -0
- package/src/components/MDataTable.vue +58 -12
- package/src/components/MDatePicker.vue +21 -0
- package/src/components/MDatePickerModal.vue +16 -0
- package/src/components/MDateRangePicker.vue +23 -0
- package/src/components/MDateRangePickerModal.vue +16 -0
- package/src/components/MDialog.vue +27 -7
- package/src/components/MDivider.vue +6 -0
- package/src/components/MDragDropList.vue +18 -0
- package/src/components/MDragHandle.vue +54 -0
- package/src/components/MEmoji.vue +6 -0
- package/src/components/MEmojiButton.vue +11 -0
- package/src/components/MEmojiSelector.vue +7 -0
- package/src/components/MEmptyState.vue +9 -0
- package/src/components/MExpansionPanel.vue +17 -0
- package/src/components/MExportButton.vue +15 -0
- package/src/components/MFab.vue +17 -0
- package/src/components/MFabMenu.vue +20 -0
- package/src/components/MFileUpload.vue +19 -0
- package/src/components/MFixed.vue +16 -0
- package/src/components/MFlex.vue +11 -0
- package/src/components/MFooter.vue +11 -0
- package/src/components/MFullscreen.vue +8 -0
- package/src/components/MGrid.vue +12 -0
- package/src/components/MHotkeys.vue +20 -13
- package/src/components/MIcon.vue +10 -1
- package/src/components/MIconButton.vue +13 -0
- package/src/components/MInfiniteScroll.vue +16 -0
- package/src/components/MJsonEditor.vue +13 -0
- package/src/components/MJsonViewer.vue +7 -0
- package/src/components/MKanban.vue +18 -0
- package/src/components/MKbd.vue +6 -0
- package/src/components/MLightbox.vue +16 -0
- package/src/components/MList.vue +48 -3
- package/src/components/MListDetail.vue +11 -0
- package/src/components/MListItem.vue +112 -5
- package/src/components/MListSubheader.vue +6 -0
- package/src/components/MLoadingIndicator.vue +15 -0
- package/src/components/MLoadingOverlay.vue +12 -0
- package/src/components/MMarkdown.vue +7 -0
- package/src/components/MMaskField.vue +21 -0
- package/src/components/MMasonry.vue +11 -0
- package/src/components/MMenu.vue +16 -6
- package/src/components/MMenuDivider.vue +4 -0
- package/src/components/MMenuItem.vue +16 -0
- package/src/components/MMultiAutocomplete.vue +26 -0
- package/src/components/MMultiSelect.vue +27 -0
- package/src/components/MNavigationBar.vue +7 -0
- package/src/components/MNavigationDrawer.vue +25 -0
- package/src/components/MNavigationRail.vue +24 -6
- package/src/components/MNavigationSuite.vue +20 -3
- package/src/components/MNotificationHost.vue +3 -0
- package/src/components/MNumberField.vue +24 -0
- package/src/components/MOverlay.vue +10 -0
- package/src/components/MPageProgress.vue +7 -0
- package/src/components/MPagination.vue +15 -1
- package/src/components/MPasswordMeter.vue +7 -0
- package/src/components/MPinInput.vue +19 -0
- package/src/components/MProgressBar.vue +9 -0
- package/src/components/MPullToRefresh.vue +17 -0
- package/src/components/MQRCode.vue +12 -0
- package/src/components/MRadio.vue +11 -0
- package/src/components/MRadioGroup.vue +11 -0
- package/src/components/MRating.vue +19 -0
- package/src/components/MRelative.vue +8 -0
- package/src/components/MRelativeTime.vue +6 -0
- package/src/components/MResponsive.vue +9 -0
- package/src/components/MResult.vue +14 -0
- package/src/components/MRichTextEditor.vue +14 -0
- package/src/components/MScheduler.vue +21 -0
- package/src/components/MScrollField.vue +302 -0
- package/src/components/MScrollable.vue +167 -4
- package/src/components/MSearchBar.vue +17 -0
- package/src/components/MSection.vue +13 -0
- package/src/components/MSegmentedButton.vue +10 -0
- package/src/components/MSelect.vue +22 -0
- package/src/components/MShader.vue +13 -0
- package/src/components/MShape.vue +6 -0
- package/src/components/MShortNavigationBar.vue +23 -9
- package/src/components/MSideSheet.vue +13 -0
- package/src/components/MSignaturePad.vue +15 -0
- package/src/components/MSimpleCarousel.vue +18 -0
- package/src/components/MSkeleton.vue +8 -0
- package/src/components/MSlider.vue +21 -0
- package/src/components/MSnackbar.vue +5 -0
- package/src/components/MSpacer.vue +6 -0
- package/src/components/MSpinner.vue +10 -0
- package/src/components/MSplitButton.vue +14 -0
- package/src/components/MSplitter.vue +42 -9
- package/src/components/MSpotlightSearch.vue +27 -0
- package/src/components/MStack.vue +12 -0
- package/src/components/MStatCard.vue +13 -0
- package/src/components/MStepper.vue +12 -0
- package/src/components/MSticky.vue +7 -0
- package/src/components/MSubtitle.vue +9 -0
- package/src/components/MSupportingPane.vue +10 -0
- package/src/components/MSwipeToDismiss.vue +247 -0
- package/src/components/MSwitch.vue +14 -6
- package/src/components/MTable.vue +33 -4
- package/src/components/MTabs.vue +12 -0
- package/src/components/MTagInput.vue +23 -0
- package/src/components/MTerminal.vue +11 -0
- package/src/components/MText.vue +15 -0
- package/src/components/MTextField.vue +26 -0
- package/src/components/MTimePicker.vue +15 -0
- package/src/components/MTimePickerModal.vue +12 -0
- package/src/components/MTimeline.vue +7 -0
- package/src/components/MTitle.vue +9 -0
- package/src/components/MToggleButton.vue +12 -0
- package/src/components/MToolbar.vue +12 -0
- package/src/components/MTooltip.vue +15 -0
- package/src/components/MTopAppBar.vue +18 -0
- package/src/components/MTour.vue +13 -0
- package/src/components/MTransferList.vue +24 -0
- package/src/components/MTransition.vue +149 -0
- package/src/components/MTree.vue +11 -0
- package/src/components/MTreeTable.vue +15 -0
- package/src/components/MVirtualTable.vue +12 -0
- package/src/components/MWindow.vue +34 -0
- package/src/components/_MColorPanel.vue +478 -0
- package/src/composables/_colorUtils.ts +107 -0
- package/src/composables/_themeColor.ts +33 -0
- package/src/composables/_useSpring.ts +89 -0
- package/src/composables/dynamicColor.ts +85 -0
- package/src/composables/useColorPalette.ts +171 -25
- package/src/composables/useFieldBg.ts +6 -0
- package/src/composables/useLocale.ts +38 -3
- package/src/index.ts +9 -1
- package/src/locales/de.ts +10 -0
- package/src/locales/es.ts +10 -0
- package/src/locales/fr.ts +10 -0
- package/src/locales/ja.ts +10 -0
- package/src/locales/ko.ts +10 -0
- package/src/locales/pt.ts +10 -0
- package/src/locales/zh.ts +10 -0
- package/src/plugin.ts +30 -8
- package/src/styles/palettes.css +546 -0
- package/src/styles/theme.css +77 -0
- package/dist/MTextField-B0wGv1Mx.js.map +0 -1
- package/dist/useLocale-CmI675Ab.js.map +0 -1
|
@@ -1,277 +1,88 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* A color picker in a dialog: saturation/brightness area, hue (and optional opacity) slider, eyedropper,
|
|
4
|
+
* HEX/RGB/HSL fields, recent colors and preset swatches. Built on MDialog; the color is only applied on confirm,
|
|
5
|
+
* and the preview shows it next to the original.
|
|
6
|
+
*
|
|
7
|
+
* @event update:modelValue Emitted when a color is confirmed — powers v-model. Only fires on confirm, not while
|
|
8
|
+
* dragging
|
|
9
|
+
* @event update:show Emitted when the dialog opens or closes — powers v-model:show
|
|
10
|
+
*/
|
|
11
|
+
import { ref, watch } from 'vue'
|
|
3
12
|
import MButton from './MButton.vue'
|
|
4
|
-
import
|
|
13
|
+
import MDialog from './MDialog.vue'
|
|
14
|
+
import MColorPanel from './_MColorPanel.vue'
|
|
5
15
|
import { useLocale } from '../composables/useLocale'
|
|
16
|
+
import { defaultColorPresets, normalizeHex, pushRecentColor } from '../composables/_colorUtils'
|
|
6
17
|
|
|
7
18
|
const props = withDefaults(defineProps<{
|
|
19
|
+
/** Selected color in hex format (v-model). `#rrggbb`, or `#rrggbbaa` when `alpha` is on and the color isn't opaque. */
|
|
8
20
|
modelValue: string
|
|
21
|
+
/** Controls dialog visibility (v-model:show) */
|
|
9
22
|
show?: boolean
|
|
23
|
+
/** Preset color swatches shown in the dialog */
|
|
10
24
|
presets?: string[]
|
|
25
|
+
/** Dialog title; defaults to the locale's `selectColor` */
|
|
11
26
|
title?: string
|
|
27
|
+
/** Adds an opacity slider and an alpha channel to the value */
|
|
28
|
+
alpha?: boolean
|
|
29
|
+
/** Remember confirmed colors and show them above the presets (stored in localStorage, shared by every picker). */
|
|
30
|
+
recent?: boolean
|
|
31
|
+
/** How many recent colors to keep. */
|
|
32
|
+
recentLimit?: number
|
|
33
|
+
/** Show a button to pick a color from the screen, where the browser supports it (Chrome, Edge). */
|
|
34
|
+
eyedropper?: boolean
|
|
12
35
|
}>(), {
|
|
13
36
|
show: false,
|
|
14
|
-
presets: () =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
37
|
+
presets: () => defaultColorPresets,
|
|
38
|
+
alpha: false,
|
|
39
|
+
recent: true,
|
|
40
|
+
recentLimit: 7,
|
|
41
|
+
eyedropper: true,
|
|
19
42
|
})
|
|
20
43
|
|
|
21
|
-
const
|
|
44
|
+
const t = useLocale()
|
|
22
45
|
const emit = defineEmits<{
|
|
23
46
|
'update:modelValue': [string]
|
|
24
47
|
'update:show': [boolean]
|
|
25
48
|
}>()
|
|
26
49
|
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
const hue = ref(0)
|
|
30
|
-
const sat = ref(100)
|
|
31
|
-
const bright = ref(100)
|
|
32
|
-
const hexInput = ref('')
|
|
33
|
-
|
|
34
|
-
function hexToHsv(hex: string) {
|
|
35
|
-
let c = hex.replace('#', '')
|
|
36
|
-
if (c.length === 3) c = c[0]! + c[0]! + c[1]! + c[1]! + c[2]! + c[2]!
|
|
37
|
-
const r = parseInt(c.substring(0, 2), 16) / 255
|
|
38
|
-
const g = parseInt(c.substring(2, 4), 16) / 255
|
|
39
|
-
const b = parseInt(c.substring(4, 6), 16) / 255
|
|
40
|
-
const max = Math.max(r, g, b), min = Math.min(r, g, b)
|
|
41
|
-
const d = max - min
|
|
42
|
-
let h = 0
|
|
43
|
-
if (d !== 0) {
|
|
44
|
-
if (max === r) h = ((g - b) / d + 6) % 6
|
|
45
|
-
else if (max === g) h = (b - r) / d + 2
|
|
46
|
-
else h = (r - g) / d + 4
|
|
47
|
-
h *= 60
|
|
48
|
-
}
|
|
49
|
-
return { h, s: max === 0 ? 0 : (d / max) * 100, v: max * 100 }
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function hsvToHex(h: number, s: number, v: number) {
|
|
53
|
-
s /= 100; v /= 100
|
|
54
|
-
const c = v * s
|
|
55
|
-
const x = c * (1 - Math.abs((h / 60) % 2 - 1))
|
|
56
|
-
const m = v - c
|
|
57
|
-
let r = 0, g = 0, b = 0
|
|
58
|
-
if (h < 60) { r = c; g = x }
|
|
59
|
-
else if (h < 120) { r = x; g = c }
|
|
60
|
-
else if (h < 180) { g = c; b = x }
|
|
61
|
-
else if (h < 240) { g = x; b = c }
|
|
62
|
-
else if (h < 300) { r = x; b = c }
|
|
63
|
-
else { r = c; b = x }
|
|
64
|
-
const toHex = (n: number) => Math.round((n + m) * 255).toString(16).padStart(2, '0')
|
|
65
|
-
return `#${toHex(r)}${toHex(g)}${toHex(b)}`
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const currentHex = computed(() => hsvToHex(hue.value, sat.value, bright.value))
|
|
69
|
-
const hueColor = computed(() => `hsl(${hue.value}, 100%, 50%)`)
|
|
50
|
+
// The color being picked; becomes the value only on confirm
|
|
51
|
+
const draft = ref(props.modelValue)
|
|
70
52
|
|
|
71
53
|
watch(() => props.show, (open) => {
|
|
72
|
-
if (open)
|
|
73
|
-
|
|
74
|
-
hue.value = hsv.h
|
|
75
|
-
sat.value = hsv.s
|
|
76
|
-
bright.value = hsv.v
|
|
77
|
-
hexInput.value = props.modelValue
|
|
78
|
-
document.addEventListener('keydown', onKeydown)
|
|
79
|
-
document.body.style.overflow = 'hidden'
|
|
80
|
-
} else {
|
|
81
|
-
document.removeEventListener('keydown', onKeydown)
|
|
82
|
-
document.body.style.overflow = ''
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
function syncHex() {
|
|
87
|
-
hexInput.value = currentHex.value
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// ── Saturation / Brightness ────────────────────────────────────────
|
|
91
|
-
function onSBPointerDown(e: PointerEvent) {
|
|
92
|
-
e.preventDefault()
|
|
93
|
-
draggingSB.value = true
|
|
94
|
-
updateSB(e)
|
|
95
|
-
;(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId)
|
|
96
|
-
}
|
|
97
|
-
function onSBPointerMove(e: PointerEvent) {
|
|
98
|
-
if (!draggingSB.value) return
|
|
99
|
-
updateSB(e)
|
|
100
|
-
}
|
|
101
|
-
function onSBPointerUp() {
|
|
102
|
-
draggingSB.value = false
|
|
103
|
-
syncHex()
|
|
104
|
-
}
|
|
105
|
-
function updateSB(e: PointerEvent) {
|
|
106
|
-
if (!satBrightEl.value) return
|
|
107
|
-
const rect = satBrightEl.value.getBoundingClientRect()
|
|
108
|
-
sat.value = Math.max(0, Math.min(100, ((e.clientX - rect.left) / rect.width) * 100))
|
|
109
|
-
bright.value = Math.max(0, Math.min(100, (1 - (e.clientY - rect.top) / rect.height) * 100))
|
|
110
|
-
syncHex()
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function onHueInput(e: Event) {
|
|
114
|
-
hue.value = Number((e.target as HTMLInputElement).value)
|
|
115
|
-
syncHex()
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function selectPreset(color: string) {
|
|
119
|
-
const hsv = hexToHsv(color)
|
|
120
|
-
hue.value = hsv.h
|
|
121
|
-
sat.value = hsv.s
|
|
122
|
-
bright.value = hsv.v
|
|
123
|
-
hexInput.value = color
|
|
124
|
-
}
|
|
54
|
+
if (open) draft.value = props.modelValue
|
|
55
|
+
}, { immediate: true })
|
|
125
56
|
|
|
126
|
-
function onHexFieldInput(e: Event) {
|
|
127
|
-
const v = (e.target as HTMLInputElement).value
|
|
128
|
-
hexInput.value = v
|
|
129
|
-
if (/^#[0-9a-fA-F]{6}$/.test(v)) {
|
|
130
|
-
const hsv = hexToHsv(v)
|
|
131
|
-
hue.value = hsv.h
|
|
132
|
-
sat.value = hsv.s
|
|
133
|
-
bright.value = hsv.v
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// ── Actions ────────────────────────────────────────────────────────
|
|
138
57
|
function cancel() { emit('update:show', false) }
|
|
139
58
|
|
|
140
59
|
function confirm() {
|
|
141
|
-
|
|
60
|
+
const picked = normalizeHex(draft.value) || draft.value
|
|
61
|
+
if (props.recent) pushRecentColor(picked, props.recentLimit)
|
|
62
|
+
emit('update:modelValue', picked)
|
|
142
63
|
emit('update:show', false)
|
|
143
64
|
}
|
|
144
|
-
|
|
145
|
-
function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
|
|
146
65
|
</script>
|
|
147
66
|
|
|
148
67
|
<template>
|
|
149
|
-
<
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
</div>
|
|
170
|
-
|
|
171
|
-
<!-- Saturation / Brightness area -->
|
|
172
|
-
<div
|
|
173
|
-
ref="satBrightEl"
|
|
174
|
-
class="relative mb-3 h-44 w-full cursor-crosshair overflow-hidden rounded-lg"
|
|
175
|
-
:style="{ background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${hueColor})`, touchAction: 'none' }"
|
|
176
|
-
@pointerdown="onSBPointerDown"
|
|
177
|
-
@pointermove="onSBPointerMove"
|
|
178
|
-
@pointerup="onSBPointerUp"
|
|
179
|
-
>
|
|
180
|
-
<div
|
|
181
|
-
class="pointer-events-none absolute h-5 w-5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-elevation-1"
|
|
182
|
-
:style="{
|
|
183
|
-
left: `${sat}%`,
|
|
184
|
-
top: `${100 - bright}%`,
|
|
185
|
-
backgroundColor: currentHex,
|
|
186
|
-
}"
|
|
187
|
-
/>
|
|
188
|
-
</div>
|
|
189
|
-
|
|
190
|
-
<!-- Hue slider -->
|
|
191
|
-
<div class="mb-3">
|
|
192
|
-
<input
|
|
193
|
-
type="range"
|
|
194
|
-
min="0"
|
|
195
|
-
max="360"
|
|
196
|
-
:value="hue"
|
|
197
|
-
class="hue-slider h-3 w-full cursor-pointer appearance-none rounded-full outline-none"
|
|
198
|
-
@input="onHueInput"
|
|
199
|
-
/>
|
|
200
|
-
</div>
|
|
201
|
-
|
|
202
|
-
<!-- Hex input -->
|
|
203
|
-
<div class="mb-3">
|
|
204
|
-
<input
|
|
205
|
-
type="text"
|
|
206
|
-
:value="hexInput"
|
|
207
|
-
maxlength="7"
|
|
208
|
-
class="w-full rounded-xs border border-outline bg-transparent px-3 py-2 font-mono text-body-medium text-on-surface caret-primary outline-none transition-colors focus:border-primary"
|
|
209
|
-
@input="onHexFieldInput"
|
|
210
|
-
/>
|
|
211
|
-
</div>
|
|
212
|
-
|
|
213
|
-
<!-- Presets -->
|
|
214
|
-
<div class="mb-4 flex flex-wrap gap-1.5">
|
|
215
|
-
<button
|
|
216
|
-
v-for="color in presets"
|
|
217
|
-
:key="color"
|
|
218
|
-
type="button"
|
|
219
|
-
class="flex h-7 w-7 cursor-pointer items-center justify-center rounded-full border transition-transform duration-100 hover:scale-110"
|
|
220
|
-
:class="color === currentHex ? 'border-on-surface' : 'border-transparent'"
|
|
221
|
-
:style="{ backgroundColor: color }"
|
|
222
|
-
@click="selectPreset(color)"
|
|
223
|
-
>
|
|
224
|
-
<MIcon v-if="color === currentHex" name="check" :size="14" class="text-white drop-shadow-[0_1px_1px_rgba(0,0,0,0.5)]" />
|
|
225
|
-
</button>
|
|
226
|
-
</div>
|
|
227
|
-
|
|
228
|
-
<!-- Footer -->
|
|
229
|
-
<div class="flex justify-end gap-2">
|
|
230
|
-
<MButton variant="text" @click="cancel">{{ locale.cancel }}</MButton>
|
|
231
|
-
<MButton variant="text" @click="confirm">OK</MButton>
|
|
232
|
-
</div>
|
|
233
|
-
</div>
|
|
234
|
-
</div>
|
|
235
|
-
</Transition>
|
|
236
|
-
</Teleport>
|
|
68
|
+
<MDialog
|
|
69
|
+
:model-value="show"
|
|
70
|
+
:title="title || t.selectColor"
|
|
71
|
+
max-width="328px"
|
|
72
|
+
:closable="false"
|
|
73
|
+
@update:model-value="!$event && cancel()"
|
|
74
|
+
>
|
|
75
|
+
<MColorPanel
|
|
76
|
+
v-model="draft"
|
|
77
|
+
:presets="presets"
|
|
78
|
+
:alpha="alpha"
|
|
79
|
+
:recent="recent"
|
|
80
|
+
:eyedropper="eyedropper"
|
|
81
|
+
:original="modelValue"
|
|
82
|
+
/>
|
|
83
|
+
<template #actions>
|
|
84
|
+
<MButton variant="text" @click="cancel">{{ t.cancel }}</MButton>
|
|
85
|
+
<MButton variant="text" @click="confirm">{{ t.confirm }}</MButton>
|
|
86
|
+
</template>
|
|
87
|
+
</MDialog>
|
|
237
88
|
</template>
|
|
238
|
-
|
|
239
|
-
<style scoped>
|
|
240
|
-
.hue-slider {
|
|
241
|
-
background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
|
|
242
|
-
}
|
|
243
|
-
.hue-slider::-webkit-slider-thumb {
|
|
244
|
-
-webkit-appearance: none;
|
|
245
|
-
width: 16px;
|
|
246
|
-
height: 16px;
|
|
247
|
-
border-radius: 50%;
|
|
248
|
-
background: white;
|
|
249
|
-
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
|
|
250
|
-
cursor: pointer;
|
|
251
|
-
}
|
|
252
|
-
.hue-slider::-moz-range-thumb {
|
|
253
|
-
width: 16px;
|
|
254
|
-
height: 16px;
|
|
255
|
-
border-radius: 50%;
|
|
256
|
-
background: white;
|
|
257
|
-
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
|
|
258
|
-
border: none;
|
|
259
|
-
cursor: pointer;
|
|
260
|
-
}
|
|
261
|
-
.m3-cp-modal-enter-active,
|
|
262
|
-
.m3-cp-modal-leave-active {
|
|
263
|
-
transition: opacity 0.15s ease;
|
|
264
|
-
}
|
|
265
|
-
.m3-cp-modal-enter-from,
|
|
266
|
-
.m3-cp-modal-leave-to {
|
|
267
|
-
opacity: 0;
|
|
268
|
-
}
|
|
269
|
-
.m3-cp-modal-enter-active .cp-box,
|
|
270
|
-
.m3-cp-modal-leave-active .cp-box {
|
|
271
|
-
transition: transform 0.15s ease;
|
|
272
|
-
}
|
|
273
|
-
.m3-cp-modal-enter-from .cp-box,
|
|
274
|
-
.m3-cp-modal-leave-to .cp-box {
|
|
275
|
-
transform: scale(0.95);
|
|
276
|
-
}
|
|
277
|
-
</style>
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A searchable, keyboard-driven command palette — grouped commands, fuzzy-free substring search, and a global
|
|
4
|
+
* hotkey (Cmd/Ctrl+K by default).
|
|
5
|
+
*
|
|
6
|
+
* @event update:modelValue Emitted on open/close — powers v-model
|
|
7
|
+
* @event select Emitted when an item is chosen (click, or Enter) — fires before the item's own onSelect
|
|
8
|
+
* callback runs
|
|
9
|
+
*/
|
|
2
10
|
import { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue'
|
|
3
11
|
import MIcon from './MIcon.vue'
|
|
4
12
|
import { useLocale } from '../composables/useLocale'
|
|
@@ -17,13 +25,21 @@ export interface CommandItem {
|
|
|
17
25
|
|
|
18
26
|
const props = withDefaults(
|
|
19
27
|
defineProps<{
|
|
28
|
+
/** Open/closed state (v-model). Required — there is no default. */
|
|
20
29
|
modelValue: boolean
|
|
30
|
+
/** Commands to search over (see `CommandItem`). Required — there is no default. */
|
|
21
31
|
items: CommandItem[]
|
|
32
|
+
/** Search input placeholder — falls back to the locale's own string when unset */
|
|
22
33
|
placeholder?: string
|
|
34
|
+
/** Empty-state text — falls back to the locale's own string when unset */
|
|
23
35
|
noResultsText?: string
|
|
36
|
+
/** Global keyboard shortcut key, combined with Cmd/Ctrl, to toggle the palette */
|
|
24
37
|
hotkey?: string
|
|
38
|
+
/** Footer hint text for the arrow keys — falls back to the locale's own string when unset */
|
|
25
39
|
navigateHint?: string
|
|
40
|
+
/** Footer hint text for Enter — falls back to the locale's own string when unset */
|
|
26
41
|
selectHint?: string
|
|
42
|
+
/** Footer hint text for Escape — falls back to the locale's own string when unset */
|
|
27
43
|
closeHint?: string
|
|
28
44
|
}>(),
|
|
29
45
|
{
|
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A pre-built confirmation dialog on top of MDialog — title, message, cancel/confirm buttons, a danger color
|
|
4
|
+
* mode, and a loading state, so you don't have to hand-roll one for every "are you sure?" prompt.
|
|
5
|
+
*
|
|
6
|
+
* @event update:modelValue Emitted when the dialog should open/close — powers v-model
|
|
7
|
+
* @event confirm Emitted when the confirm button is clicked — the dialog stays open until the caller sets
|
|
8
|
+
* modelValue to false (or clears loading)
|
|
9
|
+
*/
|
|
2
10
|
import MDialog from './MDialog.vue'
|
|
3
11
|
import MButton from './MButton.vue'
|
|
4
12
|
import { useLocale } from '../composables/useLocale'
|
|
5
13
|
|
|
6
14
|
const props = withDefaults(
|
|
7
15
|
defineProps<{
|
|
16
|
+
/** Open/closed state (v-model) */
|
|
8
17
|
modelValue: boolean
|
|
18
|
+
/** Dialog title */
|
|
9
19
|
title: string
|
|
20
|
+
/** Confirmation message body */
|
|
10
21
|
message: string
|
|
22
|
+
/** Confirm button label — falls back to the locale string when omitted */
|
|
11
23
|
confirmLabel?: string
|
|
24
|
+
/** Cancel button label — falls back to the locale string when omitted */
|
|
12
25
|
cancelLabel?: string
|
|
26
|
+
/** Error color on the confirm button, for destructive actions */
|
|
13
27
|
danger?: boolean
|
|
28
|
+
/** Shows a spinner on the confirm button and disables cancel */
|
|
14
29
|
loading?: boolean
|
|
15
30
|
/** Passed straight through to MDialog's `closable` — show/hide the header close (X) button. */
|
|
16
31
|
closable?: boolean
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Constrains content width with responsive horizontal padding.
|
|
4
|
+
*
|
|
5
|
+
* @slot default Content.
|
|
6
|
+
*/
|
|
2
7
|
import { computed } from 'vue'
|
|
3
8
|
|
|
4
9
|
const props = withDefaults(
|
|
5
10
|
defineProps<{
|
|
11
|
+
/** Maximum width breakpoint */
|
|
6
12
|
maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full'
|
|
13
|
+
/** Full-width (no max constraint) */
|
|
7
14
|
fluid?: boolean
|
|
15
|
+
/** Center horizontally with mx-auto */
|
|
8
16
|
centered?: boolean
|
|
17
|
+
/** Add responsive horizontal padding */
|
|
9
18
|
padding?: boolean
|
|
10
19
|
}>(),
|
|
11
20
|
{ maxWidth: 'lg', fluid: false, centered: true, padding: true },
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A right-click context menu composed with MMenuItem — same item/divider/submenu building blocks as MMenu, but
|
|
4
|
+
* positioned at the cursor instead of anchored to a trigger element.
|
|
5
|
+
*
|
|
6
|
+
* @slot trigger The element(s) that respond to right-click. MContextMenu intercepts contextmenu events
|
|
7
|
+
* automatically and positions the panel at the cursor, clamped to stay on-screen.
|
|
8
|
+
* @slot default Menu items — use MMenuItem, MMenuDivider, or any element.
|
|
9
|
+
*/
|
|
2
10
|
import { computed, Fragment, inject, nextTick, onMounted, onUnmounted, provide, ref, useSlots, watch, type VNode } from 'vue'
|
|
3
11
|
import MIcon from './MIcon.vue'
|
|
4
12
|
import MMenuDivider from './MMenuDivider.vue'
|
|
@@ -15,13 +23,16 @@ const props = withDefaults(
|
|
|
15
23
|
*/
|
|
16
24
|
submenuMode?: 'flyout' | 'push'
|
|
17
25
|
/**
|
|
18
|
-
*
|
|
19
|
-
* (
|
|
20
|
-
*
|
|
21
|
-
* (`SegmentedMenuTokens.ContainerShape`/`CornerLarge`). Combine with
|
|
22
|
-
* `<MMenuDivider gap />` to split the panel into independently-rounded
|
|
23
|
-
* groups with a visible gap between them, instead of a plain line.
|
|
26
|
+
* 'standard' is M3's baseline menu (4dp corners). 'expressive' is M3's rounder 'vertical menu' styling
|
|
27
|
+
* (16dp corners) — combine with `<MMenuDivider gap />` to split the panel into independently-rounded groups
|
|
28
|
+
* with a visible gap, instead of a plain divider line.
|
|
24
29
|
*/
|
|
30
|
+
// `'standard'` is M3's baseline menu — square-ish 4dp corners
|
|
31
|
+
// (`MenuTokens.ContainerShape`/`CornerExtraSmall`).
|
|
32
|
+
// `'expressive'` is M3's rounder "vertical menu" styling — 16dp corners
|
|
33
|
+
// (`SegmentedMenuTokens.ContainerShape`/`CornerLarge`). Combine with
|
|
34
|
+
// `<MMenuDivider gap />` to split the panel into independently-rounded
|
|
35
|
+
// groups with a visible gap between them, instead of a plain line.
|
|
25
36
|
variant?: 'standard' | 'expressive'
|
|
26
37
|
}>(),
|
|
27
38
|
{ submenuMode: 'flyout', variant: 'standard' },
|
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Wraps MIconButton and swaps to a checkmark for resetDelay ms after a successful copy.
|
|
4
|
+
*
|
|
5
|
+
* @event error Emitted if the browser refuses the clipboard write
|
|
6
|
+
* @event copied Emitted with the copied value after a successful clipboard write
|
|
7
|
+
*/
|
|
2
8
|
import { onUnmounted, ref } from 'vue'
|
|
3
9
|
import MIconButton from './MIconButton.vue'
|
|
4
10
|
|
|
5
11
|
const props = withDefaults(
|
|
6
12
|
defineProps<{
|
|
13
|
+
/** Text copied to the clipboard on click */
|
|
7
14
|
value: string
|
|
15
|
+
/** Icon shown in the idle state */
|
|
8
16
|
icon?: string
|
|
17
|
+
/** Icon shown right after a successful copy */
|
|
9
18
|
copiedIcon?: string
|
|
19
|
+
/** aria-label in the idle state */
|
|
10
20
|
label?: string
|
|
21
|
+
/** aria-label right after a successful copy */
|
|
11
22
|
copiedLabel?: string
|
|
23
|
+
/** Visual style (same as MIconButton) */
|
|
12
24
|
variant?: 'standard' | 'filled' | 'tonal' | 'outlined'
|
|
25
|
+
/** Button shape */
|
|
13
26
|
shape?: 'rounded' | 'squared'
|
|
27
|
+
/** Button size */
|
|
14
28
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number
|
|
29
|
+
/** Disables the button */
|
|
15
30
|
disabled?: boolean
|
|
31
|
+
/** Milliseconds before the icon reverts to idle after copying */
|
|
16
32
|
resetDelay?: number
|
|
17
33
|
}>(),
|
|
18
34
|
{
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A feature-rich data table — everything MTable has, plus column resize/pin/toggle, row grouping, striped/dense
|
|
4
|
+
* density, sticky header, expandable rows, and CSV export.
|
|
5
|
+
*
|
|
6
|
+
* @slot toolbar Extra content in the toolbar next to the search input (filters, buttons, etc.)
|
|
7
|
+
* @slot empty Custom empty-state content, replaces the default icon + text
|
|
8
|
+
* @slot row-actions Per-row action buttons — rendering this slot adds a trailing actions column
|
|
9
|
+
* @slot row-expand Expanded-row detail content, shown when expandable is true and the row is toggled open
|
|
10
|
+
* @event update:modelValue Emitted when the selection changes — powers v-model
|
|
11
|
+
* @event update:page Emitted when the page changes — powers v-model:page
|
|
12
|
+
* @event rowClick Emitted with the row's data when you click a row (unless `selectOnRowClick` makes the click
|
|
13
|
+
* select it).
|
|
14
|
+
* @event fetch Emitted instead of filtering locally when serverSide is true
|
|
15
|
+
*/
|
|
2
16
|
import { computed, ref, useSlots, watch, onMounted } from 'vue'
|
|
3
17
|
import MCheckbox from './MCheckbox.vue'
|
|
4
18
|
import MIcon from './MIcon.vue'
|
|
@@ -30,46 +44,78 @@ export interface DataTableGroup {
|
|
|
30
44
|
const SKEL = [65, 80, 50, 75, 90, 55, 70, 85, 60, 78]
|
|
31
45
|
|
|
32
46
|
const props = withDefaults(defineProps<{
|
|
47
|
+
/** Column definitions; see `DataTableColumn` */
|
|
33
48
|
columns: DataTableColumn[]
|
|
49
|
+
/** Table data rows */
|
|
34
50
|
rows: Record<string, any>[]
|
|
51
|
+
/** Show skeleton loading state */
|
|
35
52
|
loading?: boolean
|
|
53
|
+
/** Text when no rows (defaults to the locale string) */
|
|
36
54
|
emptyText?: string
|
|
55
|
+
/** Unique key field in each row */
|
|
37
56
|
rowKey?: string
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
* `rowClick`, así una tabla puede seleccionar filas y a la vez abrirlas al click.
|
|
57
|
+
/**
|
|
58
|
+
* Enable row selection with checkboxes (by default only the checkbox toggles a row; clicking the row itself
|
|
59
|
+
* still emits row-click)
|
|
42
60
|
*/
|
|
61
|
+
selectable?: boolean
|
|
62
|
+
/** With selectable, clicking anywhere on a row toggles its selection instead of emitting row-click */
|
|
63
|
+
// Con `selectable`, que el click en cualquier parte de la fila la marque/desmarque (en vez de
|
|
64
|
+
// emitir `rowClick`). Default false: sólo el checkbox selecciona y el click en la fila emite
|
|
65
|
+
// `rowClick`, así una tabla puede seleccionar filas y a la vez abrirlas al click.
|
|
43
66
|
selectOnRowClick?: boolean
|
|
67
|
+
/** Selected rows (v-model) */
|
|
44
68
|
modelValue?: Record<string, any>[]
|
|
69
|
+
/** Rows per page */
|
|
45
70
|
perPage?: number
|
|
71
|
+
/** Show search input */
|
|
46
72
|
searchable?: boolean
|
|
73
|
+
/** Enable row expansion (requires the row-expand slot) */
|
|
47
74
|
expandable?: boolean
|
|
75
|
+
/** Alternate row colors */
|
|
48
76
|
striped?: boolean
|
|
77
|
+
/** Compact row height */
|
|
49
78
|
dense?: boolean
|
|
79
|
+
/** Sticky table header */
|
|
50
80
|
stickyHeader?: boolean
|
|
81
|
+
/** Group rows by this column key */
|
|
51
82
|
groupBy?: string
|
|
83
|
+
/** Allow hiding/showing columns from a menu */
|
|
52
84
|
columnToggle?: boolean
|
|
85
|
+
/** Show an export-to-CSV button */
|
|
53
86
|
exportable?: boolean
|
|
87
|
+
/** Emit fetch instead of local filtering. Requires :total. */
|
|
54
88
|
serverSide?: boolean
|
|
89
|
+
/** Total rows (for server-side pagination) */
|
|
55
90
|
total?: number
|
|
91
|
+
/** Current page (v-model via update:page) */
|
|
56
92
|
page?: number
|
|
93
|
+
/** Placeholder for search input (defaults to the locale string) */
|
|
57
94
|
searchPlaceholder?: string
|
|
95
|
+
/** Text for selected count badge (defaults to the locale string) */
|
|
58
96
|
selectedText?: string
|
|
97
|
+
/** Text for total records count (defaults to the locale string) */
|
|
59
98
|
recordsText?: string
|
|
99
|
+
/** Aria label for the expand button (defaults to the locale string) */
|
|
60
100
|
expandLabel?: string
|
|
101
|
+
/** Label for the column-toggle button (defaults to the locale string) */
|
|
61
102
|
columnsLabel?: string
|
|
103
|
+
/** Label for the export button (defaults to the locale string) */
|
|
62
104
|
exportLabel?: string
|
|
105
|
+
/** Text for the ungrouped-rows bucket (defaults to the locale string) */
|
|
63
106
|
noGroupText?: string
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* (default), la tabla vuelve a su comportamiento natural: alto según la cantidad real de filas,
|
|
68
|
-
* sin piso reservado — usalo sólo en tablas puntuales que necesiten ese piso (p. ej. una agenda
|
|
69
|
-
* diaria que suele tener pocos o cero elementos y no debería verse minúscula al filtrar a un día
|
|
70
|
-
* vacío). El estado vacío siempre reserva un mínimo propio independientemente de este prop, ver
|
|
71
|
-
* `emptyStateMinHeight`.
|
|
107
|
+
/**
|
|
108
|
+
* Reserves a fixed min-height for the table area (any valid CSS min-height value) so switching between
|
|
109
|
+
* loading/empty/loaded doesn't visibly resize the table. Off by default.
|
|
72
110
|
*/
|
|
111
|
+
// Alto mínimo del área de la tabla (cualquier valor CSS válido para `min-height`) — reserva
|
|
112
|
+
// espacio fijo para que pasar de "cargando" (skeleton) a "pocos o cero resultados" (o
|
|
113
|
+
// viceversa, al cambiar de filtro/página) no encoja/agrande la tabla visiblemente. Sin valor
|
|
114
|
+
// (default), la tabla vuelve a su comportamiento natural: alto según la cantidad real de filas,
|
|
115
|
+
// sin piso reservado — usalo sólo en tablas puntuales que necesiten ese piso (p. ej. una agenda
|
|
116
|
+
// diaria que suele tener pocos o cero elementos y no debería verse minúscula al filtrar a un día
|
|
117
|
+
// vacío). El estado vacío siempre reserva un mínimo propio independientemente de este prop, ver
|
|
118
|
+
// `emptyStateMinHeight`.
|
|
73
119
|
minHeight?: string
|
|
74
120
|
}>(), {
|
|
75
121
|
loading: false,
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* An inline, dropdown-anchored calendar date picker with locale support and min/max range clamping.
|
|
4
|
+
*
|
|
5
|
+
* @event update:modelValue Emitted with the picked date.
|
|
6
|
+
*/
|
|
2
7
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
3
8
|
import MIcon from './MIcon.vue'
|
|
4
9
|
import MIconButton from './MIconButton.vue'
|
|
@@ -6,18 +11,34 @@ import { useFieldBg } from '../composables/useFieldBg'
|
|
|
6
11
|
import { useLocale } from '../composables/useLocale'
|
|
7
12
|
|
|
8
13
|
const props = defineProps<{
|
|
14
|
+
/** Selected date (YYYY-MM-DD, v-model) */
|
|
9
15
|
modelValue: string | null
|
|
16
|
+
/** Field label */
|
|
10
17
|
label?: string
|
|
18
|
+
/** Placeholder shown when no date is selected — falls back to label, then the current locale's string */
|
|
11
19
|
placeholder?: string
|
|
20
|
+
/** Minimum selectable date (YYYY-MM-DD) */
|
|
12
21
|
min?: string
|
|
22
|
+
/** Maximum selectable date (YYYY-MM-DD) */
|
|
13
23
|
max?: string
|
|
24
|
+
/** Disables the picker */
|
|
14
25
|
disabled?: boolean
|
|
26
|
+
/** Error state */
|
|
15
27
|
error?: boolean
|
|
28
|
+
/** Error message shown when error is true */
|
|
16
29
|
errorLabel?: string
|
|
30
|
+
/** Hint text below the field */
|
|
17
31
|
hint?: string
|
|
32
|
+
/**
|
|
33
|
+
* Locale for month/day names. Falls back to the app's configured locale (createM3UI({ locale })) — same
|
|
34
|
+
* pattern as MRelativeTime
|
|
35
|
+
*/
|
|
18
36
|
locale?: string
|
|
37
|
+
/** Overrides the auto-detected background color used to cut the floating label out of the border */
|
|
19
38
|
fieldBg?: string
|
|
39
|
+
/** Aria label for the previous-month button — defaults to the current locale's string */
|
|
20
40
|
prevMonthLabel?: string
|
|
41
|
+
/** Aria label for the next-month button — defaults to the current locale's string */
|
|
21
42
|
nextMonthLabel?: string
|
|
22
43
|
}>()
|
|
23
44
|
|