@itguy614/clean-ui 0.9.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_plugin-vue_export-helper.js +9 -0
- package/dist/clean-ui.css +1 -1
- package/dist/components/CuiAccordion.vue.js +7 -0
- package/dist/components/CuiAccordion.vue2.js +55 -0
- package/dist/components/CuiAccordionItem.vue.js +7 -0
- package/dist/components/CuiAccordionItem.vue2.js +91 -0
- package/dist/components/CuiAlert.vue.d.ts.map +1 -1
- package/dist/components/CuiAlert.vue.js +7 -0
- package/dist/components/CuiAlert.vue2.js +113 -0
- package/dist/components/CuiAvatar.vue.js +99 -0
- package/dist/components/CuiAvatar.vue3.js +5 -0
- package/dist/components/CuiAvatarGroup.vue.js +22 -0
- package/dist/components/CuiAvatarGroup.vue3.js +5 -0
- package/dist/components/CuiBackdrop.vue.js +7 -0
- package/dist/components/CuiBackdrop.vue2.js +49 -0
- package/dist/components/CuiBadge.vue.d.ts.map +1 -1
- package/dist/components/CuiBadge.vue.js +7 -0
- package/dist/components/CuiBadge.vue2.js +82 -0
- package/dist/components/CuiBanner.vue.js +81 -0
- package/dist/components/CuiBanner.vue2.js +4 -0
- package/dist/components/CuiBreadcrumb.vue.js +7 -0
- package/dist/components/CuiBreadcrumb.vue2.js +29 -0
- package/dist/components/CuiBreadcrumbItem.vue.js +7 -0
- package/dist/components/CuiBreadcrumbItem.vue2.js +46 -0
- package/dist/components/CuiButton.vue.d.ts.map +1 -1
- package/dist/components/CuiButton.vue.js +7 -0
- package/dist/components/CuiButton.vue2.js +136 -0
- package/dist/components/CuiButtonGroup.vue.js +7 -0
- package/dist/components/CuiButtonGroup.vue2.js +21 -0
- package/dist/components/CuiCard.vue.js +35 -0
- package/dist/components/CuiCard.vue2.js +4 -0
- package/dist/components/CuiCardBody.vue.js +20 -0
- package/dist/components/CuiCardBody.vue2.js +4 -0
- package/dist/components/CuiCardFooter.vue.js +32 -0
- package/dist/components/CuiCardFooter.vue2.js +4 -0
- package/dist/components/CuiCardHeader.vue.js +51 -0
- package/dist/components/CuiCardHeader.vue2.js +4 -0
- package/dist/components/CuiCardMedia.vue.js +7 -0
- package/dist/components/CuiCardMedia.vue2.js +38 -0
- package/dist/components/CuiCheckbox.vue.js +7 -0
- package/dist/components/CuiCheckbox.vue2.js +105 -0
- package/dist/components/CuiCheckboxGroup.vue.js +7 -0
- package/dist/components/CuiCheckboxGroup.vue2.js +59 -0
- package/dist/components/CuiCodeBlock.vue.js +129 -0
- package/dist/components/CuiCodeBlock.vue2.js +4 -0
- package/dist/components/CuiColorPicker.vue.js +348 -0
- package/dist/components/CuiColorPicker.vue2.js +4 -0
- package/dist/components/CuiCombobox.vue.js +332 -0
- package/dist/components/CuiCombobox.vue2.js +4 -0
- package/dist/components/CuiConfigProvider.vue.js +18 -0
- package/dist/components/CuiConfigProvider.vue2.js +4 -0
- package/dist/components/CuiConfirmDialog.vue.js +208 -0
- package/dist/components/CuiConfirmDialog.vue2.js +4 -0
- package/dist/components/CuiContainer.vue.js +35 -0
- package/dist/components/CuiContainer.vue2.js +4 -0
- package/dist/components/CuiContextMenu.vue.js +7 -0
- package/dist/components/CuiContextMenu.vue2.js +136 -0
- package/dist/components/CuiCopyButton.vue.js +63 -0
- package/dist/components/CuiCopyButton.vue2.js +4 -0
- package/dist/components/CuiDataGrid.vue.d.ts +53 -79
- package/dist/components/CuiDataGrid.vue.d.ts.map +1 -1
- package/dist/components/CuiDataGrid.vue.js +178 -0
- package/dist/components/CuiDataGrid.vue3.js +5 -0
- package/dist/components/CuiDataGridActiveFilters.vue.js +47 -0
- package/dist/components/CuiDataGridActiveFilters.vue3.js +5 -0
- package/dist/components/CuiDataGridBulkBar.vue.d.ts.map +1 -1
- package/dist/components/CuiDataGridBulkBar.vue.js +70 -0
- package/dist/components/CuiDataGridBulkBar.vue3.js +5 -0
- package/dist/components/CuiDataGridCardView.vue.js +31 -0
- package/dist/components/CuiDataGridCardView.vue2.js +4 -0
- package/dist/components/CuiDataGridColumnManager.vue.js +86 -0
- package/dist/components/CuiDataGridColumnManager.vue2.js +4 -0
- package/dist/components/CuiDataGridFilterPanel.vue.js +181 -0
- package/dist/components/CuiDataGridFilterPanel.vue3.js +5 -0
- package/dist/components/CuiDataGridPagination.vue.js +28 -0
- package/dist/components/CuiDataGridPagination.vue2.js +4 -0
- package/dist/components/CuiDataGridSearch.vue.js +69 -0
- package/dist/components/CuiDataGridSearch.vue2.js +4 -0
- package/dist/components/CuiDataGridTable.vue.js +336 -0
- package/dist/components/CuiDataGridTable.vue2.js +4 -0
- package/dist/components/CuiDataGridToolbar.vue.js +73 -0
- package/dist/components/CuiDataGridToolbar.vue3.js +5 -0
- package/dist/components/CuiDataGridViewManager.vue.js +209 -0
- package/dist/components/CuiDataGridViewManager.vue2.js +4 -0
- package/dist/components/CuiDataGridViewToggle.vue.js +43 -0
- package/dist/components/CuiDataGridViewToggle.vue3.js +5 -0
- package/dist/components/CuiDatePicker.vue.js +382 -0
- package/dist/components/CuiDatePicker.vue2.js +4 -0
- package/dist/components/CuiDateRangePicker.vue.js +376 -0
- package/dist/components/CuiDateRangePicker.vue2.js +4 -0
- package/dist/components/CuiDivider.vue.js +124 -0
- package/dist/components/CuiDivider.vue2.js +4 -0
- package/dist/components/CuiDropdown.vue.js +7 -0
- package/dist/components/CuiDropdown.vue2.js +110 -0
- package/dist/components/CuiDropdownCheckItem.vue.js +7 -0
- package/dist/components/CuiDropdownCheckItem.vue2.js +45 -0
- package/dist/components/CuiDropdownDivider.vue.js +14 -0
- package/dist/components/CuiDropdownHeader.vue.js +16 -0
- package/dist/components/CuiDropdownItem.vue.js +7 -0
- package/dist/components/CuiDropdownItem.vue2.js +55 -0
- package/dist/components/CuiDropdownMenu.vue.js +7 -0
- package/dist/components/CuiDropdownMenu.vue2.js +79 -0
- package/dist/components/CuiDropdownRadioGroup.vue.js +23 -0
- package/dist/components/CuiDropdownRadioGroup.vue2.js +4 -0
- package/dist/components/CuiDropdownRadioItem.vue.js +7 -0
- package/dist/components/CuiDropdownRadioItem.vue2.js +43 -0
- package/dist/components/CuiDropdownSub.vue.js +7 -0
- package/dist/components/CuiDropdownSub.vue2.js +91 -0
- package/dist/components/CuiDropdownTrigger.vue.js +7 -0
- package/dist/components/CuiDropdownTrigger.vue2.js +25 -0
- package/dist/components/CuiEmptyState.vue.js +7 -0
- package/dist/components/CuiEmptyState.vue2.js +70 -0
- package/dist/components/CuiFieldset.vue.js +7 -0
- package/dist/components/CuiFieldset.vue2.js +79 -0
- package/dist/components/CuiFileUpload.vue.js +254 -0
- package/dist/components/CuiFileUpload.vue2.js +4 -0
- package/dist/components/CuiFlex.vue.js +7 -0
- package/dist/components/CuiFlex.vue2.js +72 -0
- package/dist/components/CuiFlexItem.vue.js +35 -0
- package/dist/components/CuiFlexItem.vue2.js +4 -0
- package/dist/components/CuiForm.vue.js +116 -0
- package/dist/components/CuiForm.vue2.js +4 -0
- package/dist/components/CuiFormField.vue.js +7 -0
- package/dist/components/CuiFormField.vue2.js +73 -0
- package/dist/components/CuiGrid.vue.js +7 -0
- package/dist/components/CuiGrid.vue2.js +51 -0
- package/dist/components/CuiGridItem.vue.js +30 -0
- package/dist/components/CuiGridItem.vue2.js +4 -0
- package/dist/components/CuiIcon.vue.js +7 -0
- package/dist/components/CuiIcon.vue2.js +72 -0
- package/dist/components/CuiInput.vue.d.ts +6 -6
- package/dist/components/CuiInput.vue.d.ts.map +1 -1
- package/dist/components/CuiInput.vue.js +7 -0
- package/dist/components/CuiInput.vue2.js +150 -0
- package/dist/components/CuiInputStepper.vue.js +189 -0
- package/dist/components/CuiInputStepper.vue2.js +4 -0
- package/dist/components/CuiKbd.vue.js +44 -0
- package/dist/components/CuiKbd.vue2.js +4 -0
- package/dist/components/CuiMaskedInput.vue.d.ts +8 -8
- package/dist/components/CuiMaskedInput.vue.js +256 -0
- package/dist/components/CuiMaskedInput.vue2.js +4 -0
- package/dist/components/CuiModal.vue.js +7 -0
- package/dist/components/CuiModal.vue2.js +98 -0
- package/dist/components/CuiModalBody.vue.js +50 -0
- package/dist/components/CuiModalBody.vue2.js +4 -0
- package/dist/components/CuiModalFooter.vue.js +36 -0
- package/dist/components/CuiModalFooter.vue2.js +4 -0
- package/dist/components/CuiModalHeader.vue.js +85 -0
- package/dist/components/CuiModalHeader.vue2.js +4 -0
- package/dist/components/CuiPagination.vue.js +7 -0
- package/dist/components/CuiPagination.vue2.js +136 -0
- package/dist/components/CuiPopover.vue.js +227 -0
- package/dist/components/CuiPopover.vue2.js +4 -0
- package/dist/components/CuiProgress.vue.js +7 -0
- package/dist/components/CuiProgress.vue2.js +132 -0
- package/dist/components/CuiRadio.vue.d.ts.map +1 -1
- package/dist/components/CuiRadio.vue.js +7 -0
- package/dist/components/CuiRadio.vue2.js +139 -0
- package/dist/components/CuiRadioGroup.vue.js +7 -0
- package/dist/components/CuiRadioGroup.vue2.js +78 -0
- package/dist/components/CuiRating.vue.js +129 -0
- package/dist/components/CuiRating.vue2.js +4 -0
- package/dist/components/CuiResizablePanels.vue.js +147 -0
- package/dist/components/CuiResizablePanels.vue2.js +4 -0
- package/dist/components/CuiSelect.vue.d.ts.map +1 -1
- package/dist/components/CuiSelect.vue.js +7 -0
- package/dist/components/CuiSelect.vue2.js +359 -0
- package/dist/components/CuiSkeleton.vue.js +7 -0
- package/dist/components/CuiSkeleton.vue2.js +80 -0
- package/dist/components/CuiSlideover.vue.js +109 -0
- package/dist/components/CuiSlideover.vue2.js +4 -0
- package/dist/components/CuiSlider.vue.js +156 -0
- package/dist/components/CuiSlider.vue2.js +4 -0
- package/dist/components/CuiSpacer.vue.js +32 -0
- package/dist/components/CuiSpacer.vue2.js +4 -0
- package/dist/components/CuiSpinner.vue.js +99 -0
- package/dist/components/CuiSpinner.vue3.js +5 -0
- package/dist/components/CuiStack.vue.js +30 -0
- package/dist/components/CuiStack.vue2.js +4 -0
- package/dist/components/CuiStepper.vue.js +153 -0
- package/dist/components/CuiStepper.vue2.js +4 -0
- package/dist/components/CuiTab.vue.js +7 -0
- package/dist/components/CuiTab.vue2.js +73 -0
- package/dist/components/CuiTable.vue.d.ts.map +1 -1
- package/dist/components/CuiTable.vue.js +90 -0
- package/dist/components/CuiTable.vue3.js +5 -0
- package/dist/components/CuiTableBody.vue.js +18 -0
- package/dist/components/CuiTableBody.vue2.js +4 -0
- package/dist/components/CuiTableCell.vue.js +36 -0
- package/dist/components/CuiTableCell.vue2.js +4 -0
- package/dist/components/CuiTableFoot.vue.js +18 -0
- package/dist/components/CuiTableFoot.vue2.js +4 -0
- package/dist/components/CuiTableHead.vue.js +18 -0
- package/dist/components/CuiTableHead.vue2.js +4 -0
- package/dist/components/CuiTableRow.vue.js +23 -0
- package/dist/components/CuiTableRow.vue2.js +4 -0
- package/dist/components/CuiTabs.vue.js +7 -0
- package/dist/components/CuiTabs.vue2.js +124 -0
- package/dist/components/CuiTagInput.vue.js +296 -0
- package/dist/components/CuiTagInput.vue2.js +4 -0
- package/dist/components/CuiTextarea.vue.js +7 -0
- package/dist/components/CuiTextarea.vue2.js +112 -0
- package/dist/components/CuiTimePicker.vue.js +193 -0
- package/dist/components/CuiTimePicker.vue2.js +4 -0
- package/dist/components/CuiTimeline.vue.js +25 -0
- package/dist/components/CuiTimeline.vue2.js +4 -0
- package/dist/components/CuiTimelineItem.vue.js +113 -0
- package/dist/components/CuiTimelineItem.vue2.js +4 -0
- package/dist/components/CuiToast.vue.js +7 -0
- package/dist/components/CuiToast.vue2.js +129 -0
- package/dist/components/CuiToastProvider.vue.js +7 -0
- package/dist/components/CuiToastProvider.vue2.js +87 -0
- package/dist/components/CuiToggle.vue.d.ts.map +1 -1
- package/dist/components/CuiToggle.vue.js +7 -0
- package/dist/components/CuiToggle.vue2.js +116 -0
- package/dist/components/CuiToggleGroup.vue.js +7 -0
- package/dist/components/CuiToggleGroup.vue2.js +59 -0
- package/dist/components/CuiTooltip.vue.js +7 -0
- package/dist/components/CuiTooltip.vue2.js +128 -0
- package/dist/components/CuiTransferList.vue.js +442 -0
- package/dist/components/CuiTransferList.vue2.js +4 -0
- package/dist/components/CuiTreeNode.vue.js +180 -0
- package/dist/components/CuiTreeNode.vue2.js +4 -0
- package/dist/components/CuiTreeView.vue.js +73 -0
- package/dist/components/CuiTreeView.vue2.js +4 -0
- package/dist/components/accordion-context.js +4 -0
- package/dist/components/breadcrumb-context.js +4 -0
- package/dist/components/config-context.js +4 -0
- package/dist/components/data-grid-context.js +4 -0
- package/dist/components/dropdown-context.js +30 -0
- package/dist/components/form-context.js +4 -0
- package/dist/components/multi-select-group-context.js +5 -0
- package/dist/components/radio-context.js +4 -0
- package/dist/components/table-context.js +5 -0
- package/dist/components/tabs-context.js +4 -0
- package/dist/components/toast-context.js +45 -0
- package/dist/composables/useBreakpoint.js +34 -0
- package/dist/composables/useClickOutside.js +14 -0
- package/dist/composables/useCopyToClipboard.js +25 -0
- package/dist/composables/useDataGrid.js +269 -0
- package/dist/composables/useDataGridInertia.js +35 -0
- package/dist/composables/useDataGridViews.js +67 -0
- package/dist/composables/useDensity.js +42 -0
- package/dist/composables/useLayoutContext.js +21 -0
- package/dist/composables/useMessages.js +10 -0
- package/dist/composables/useOverlay.d.ts.map +1 -1
- package/dist/composables/useOverlay.js +59 -0
- package/dist/composables/usePopover.js +53 -0
- package/dist/composables/useScrollShadows.js +56 -0
- package/dist/composables/useTheme.js +57 -0
- package/dist/composables/useToast.js +23 -0
- package/dist/composables/useVirtualScroll.js +69 -0
- package/dist/index.js +290 -0
- package/dist/messages.js +57 -0
- package/dist/ssr-theme-init.js +13 -0
- package/dist/utils/color.js +195 -0
- package/dist/utils/colorIconMap.js +11 -0
- package/dist/utils/date.js +114 -0
- package/dist/utils/devWarn.d.ts +15 -0
- package/dist/utils/devWarn.d.ts.map +1 -0
- package/dist/utils/devWarn.js +20 -0
- package/dist/utils/liveRegion.js +12 -0
- package/dist/utils/resolvers.js +28 -0
- package/dist/utils/responsive.js +68 -0
- package/dist/utils/sizing.js +39 -0
- package/package.json +8 -7
- package/dist/clean-ui.js +0 -11937
- package/dist/clean-ui.umd.cjs +0 -11
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { defineComponent as p, computed as c, withDirectives as x, openBlock as n, createElementBlock as i, normalizeStyle as l, toDisplayString as u, createBlock as L, createCommentVNode as m, createElementVNode as g, Fragment as h, renderList as y, vShow as k } from "vue";
|
|
2
|
+
import { clampSize as z, scaleDensity as f } from "../utils/sizing.js";
|
|
3
|
+
import H from "./CuiCopyButton.vue.js";
|
|
4
|
+
const R = { style: {
|
|
5
|
+
borderRadius: "0.5rem",
|
|
6
|
+
overflow: "hidden",
|
|
7
|
+
border: "1px solid var(--cui-border)",
|
|
8
|
+
background: "var(--color-surface-950, #1a1a2e)"
|
|
9
|
+
} }, B = { key: 1 }, E = /* @__PURE__ */ p({
|
|
10
|
+
__name: "CuiCodeBlock",
|
|
11
|
+
props: {
|
|
12
|
+
code: {},
|
|
13
|
+
language: {},
|
|
14
|
+
filename: {},
|
|
15
|
+
lineNumbers: { type: Boolean, default: !1 },
|
|
16
|
+
startLine: { default: 1 },
|
|
17
|
+
highlightLines: {},
|
|
18
|
+
copyable: { type: Boolean, default: !0 },
|
|
19
|
+
maxHeight: {},
|
|
20
|
+
hidden: { type: Boolean, default: !1 },
|
|
21
|
+
size: { default: "md" }
|
|
22
|
+
},
|
|
23
|
+
setup(e) {
|
|
24
|
+
const b = ["sm", "md", "lg"], o = e, d = c(() => o.code.split(`
|
|
25
|
+
`)), S = {
|
|
26
|
+
sm: { fontSize: "0.75rem", lineHeight: "1.6", padding: f("0.75rem"), headerFont: "0.6875rem" },
|
|
27
|
+
md: { fontSize: "0.8125rem", lineHeight: "1.65", padding: f("1rem"), headerFont: "0.75rem" },
|
|
28
|
+
lg: { fontSize: "0.875rem", lineHeight: "1.7", padding: f("1.25rem"), headerFont: "0.8125rem" }
|
|
29
|
+
}, t = c(() => S[z(o.size, b)]), s = c(() => o.filename || o.language || ""), r = c(() => new Set(o.highlightLines ?? []));
|
|
30
|
+
return (F, w) => x((n(), i("div", R, [
|
|
31
|
+
s.value || e.copyable ? (n(), i("div", {
|
|
32
|
+
key: 0,
|
|
33
|
+
style: l({
|
|
34
|
+
display: "flex",
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
justifyContent: "space-between",
|
|
37
|
+
padding: `calc(0.375rem * var(--cui-density-scale, 1)) ${t.value.padding}`,
|
|
38
|
+
background: "rgba(255,255,255,0.04)",
|
|
39
|
+
borderBottom: "1px solid rgba(255,255,255,0.06)"
|
|
40
|
+
})
|
|
41
|
+
}, [
|
|
42
|
+
s.value ? (n(), i("span", {
|
|
43
|
+
key: 0,
|
|
44
|
+
style: l({
|
|
45
|
+
fontSize: t.value.headerFont,
|
|
46
|
+
fontWeight: "500",
|
|
47
|
+
color: "var(--color-surface-400, #999)",
|
|
48
|
+
fontFamily: "var(--cui-font-mono, monospace)",
|
|
49
|
+
textTransform: e.language && !e.filename ? "uppercase" : "none",
|
|
50
|
+
letterSpacing: e.language && !e.filename ? "0.04em" : "normal"
|
|
51
|
+
})
|
|
52
|
+
}, u(s.value), 5)) : (n(), i("span", B)),
|
|
53
|
+
e.copyable ? (n(), L(H, {
|
|
54
|
+
key: 2,
|
|
55
|
+
value: e.code,
|
|
56
|
+
size: "xs",
|
|
57
|
+
variant: "ghost",
|
|
58
|
+
style: { color: "var(--color-surface-400, #999)" }
|
|
59
|
+
}, null, 8, ["value"])) : m("", !0)
|
|
60
|
+
], 4)) : m("", !0),
|
|
61
|
+
g("div", {
|
|
62
|
+
style: l({
|
|
63
|
+
overflow: "auto",
|
|
64
|
+
maxHeight: e.maxHeight || void 0
|
|
65
|
+
})
|
|
66
|
+
}, [
|
|
67
|
+
g("div", {
|
|
68
|
+
style: l({
|
|
69
|
+
display: "flex",
|
|
70
|
+
padding: `${t.value.padding} 0`,
|
|
71
|
+
minWidth: "fit-content"
|
|
72
|
+
})
|
|
73
|
+
}, [
|
|
74
|
+
e.lineNumbers ? (n(), i("div", {
|
|
75
|
+
key: 0,
|
|
76
|
+
style: l({
|
|
77
|
+
display: "flex",
|
|
78
|
+
flexDirection: "column",
|
|
79
|
+
alignItems: "flex-end",
|
|
80
|
+
paddingRight: "calc(0.75rem * var(--cui-density-scale, 1))",
|
|
81
|
+
paddingLeft: t.value.padding,
|
|
82
|
+
borderRight: "1px solid rgba(255,255,255,0.06)",
|
|
83
|
+
marginRight: "calc(0.75rem * var(--cui-density-scale, 1))",
|
|
84
|
+
userSelect: "none",
|
|
85
|
+
flexShrink: "0"
|
|
86
|
+
})
|
|
87
|
+
}, [
|
|
88
|
+
(n(!0), i(h, null, y(d.value, (v, a) => (n(), i("span", {
|
|
89
|
+
key: a,
|
|
90
|
+
style: l({
|
|
91
|
+
fontSize: t.value.fontSize,
|
|
92
|
+
lineHeight: t.value.lineHeight,
|
|
93
|
+
fontFamily: "var(--cui-font-mono, monospace)",
|
|
94
|
+
color: r.value.has(e.startLine + a) ? "var(--color-surface-200, #ccc)" : "var(--color-surface-600, #555)",
|
|
95
|
+
minWidth: `${String(e.startLine + d.value.length - 1).length}ch`
|
|
96
|
+
})
|
|
97
|
+
}, u(e.startLine + a), 5))), 128))
|
|
98
|
+
], 4)) : m("", !0),
|
|
99
|
+
g("div", {
|
|
100
|
+
style: l({ flex: "1", paddingRight: t.value.padding, paddingLeft: e.lineNumbers ? "0" : t.value.padding })
|
|
101
|
+
}, [
|
|
102
|
+
(n(!0), i(h, null, y(d.value, (v, a) => (n(), i("div", {
|
|
103
|
+
key: a,
|
|
104
|
+
style: l({
|
|
105
|
+
fontSize: t.value.fontSize,
|
|
106
|
+
lineHeight: t.value.lineHeight,
|
|
107
|
+
fontFamily: "var(--cui-font-mono, monospace)",
|
|
108
|
+
color: "var(--color-surface-200, #e0e0e0)",
|
|
109
|
+
whiteSpace: "pre",
|
|
110
|
+
background: r.value.has(e.startLine + a) ? "rgba(255,255,255,0.06)" : "transparent",
|
|
111
|
+
marginLeft: r.value.has(e.startLine + a) ? "calc(-0.5rem * var(--cui-density-scale, 1))" : "0",
|
|
112
|
+
marginRight: r.value.has(e.startLine + a) ? "calc(-0.5rem * var(--cui-density-scale, 1))" : "0",
|
|
113
|
+
paddingLeft: r.value.has(e.startLine + a) ? "calc(0.5rem * var(--cui-density-scale, 1))" : "0",
|
|
114
|
+
paddingRight: r.value.has(e.startLine + a) ? "calc(0.5rem * var(--cui-density-scale, 1))" : "0",
|
|
115
|
+
borderLeft: r.value.has(e.startLine + a) ? "2px solid var(--cui-primary)" : "2px solid transparent",
|
|
116
|
+
borderRadius: "2px"
|
|
117
|
+
})
|
|
118
|
+
}, u(v || " "), 5))), 128))
|
|
119
|
+
], 4)
|
|
120
|
+
], 4)
|
|
121
|
+
], 4)
|
|
122
|
+
], 512)), [
|
|
123
|
+
[k, !e.hidden]
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
export {
|
|
128
|
+
E as default
|
|
129
|
+
};
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { defineComponent as pe, ref as s, computed as p, watch as he, onMounted as J, onUnmounted as me, useTemplateRef as Q, withDirectives as _, openBlock as d, createElementBlock as c, normalizeStyle as r, withModifiers as B, createElementVNode as l, createCommentVNode as h, withKeys as ge, vModelText as be, createBlock as xe, withCtx as ye, createTextVNode as we, toDisplayString as ke, Fragment as Se, renderList as Ee, vShow as Re } from "vue";
|
|
2
|
+
import { clampSize as ze } from "../utils/sizing.js";
|
|
3
|
+
import Pe from "./CuiButton.vue.js";
|
|
4
|
+
import { hsvToRgb as ee, rgbToHex as Ce, formatColor as Le, getThemePalette as Me, PALETTE_BASIC as Te, PALETTE_MATERIAL as He, PALETTE_TAILWIND as Be, parseColor as A, rgbToHsv as $ } from "../utils/color.js";
|
|
5
|
+
const Ae = {
|
|
6
|
+
key: 0,
|
|
7
|
+
style: { display: "flex", gap: "calc(0.625rem * var(--cui-density-scale, 1))", alignItems: "center" }
|
|
8
|
+
}, $e = { style: { flex: "1", display: "flex", flexDirection: "column", gap: "calc(0.5rem * var(--cui-density-scale, 1))" } }, De = {
|
|
9
|
+
key: 1,
|
|
10
|
+
style: { display: "flex", gap: "calc(0.375rem * var(--cui-density-scale, 1))", alignItems: "center" }
|
|
11
|
+
}, Ve = {
|
|
12
|
+
key: 2,
|
|
13
|
+
style: { display: "flex", flexWrap: "wrap", gap: "calc(0.3125rem * var(--cui-density-scale, 1))" }
|
|
14
|
+
}, Fe = ["onClick"], te = "repeating-conic-gradient(#d0d0d0 0% 25%, transparent 0% 50%) 0 0 / 12px 12px", Ge = /* @__PURE__ */ pe({
|
|
15
|
+
__name: "CuiColorPicker",
|
|
16
|
+
props: {
|
|
17
|
+
modelValue: { default: "#000000" },
|
|
18
|
+
format: { default: "hex" },
|
|
19
|
+
palette: {},
|
|
20
|
+
presetPalette: {},
|
|
21
|
+
showAlpha: { type: Boolean, default: !1 },
|
|
22
|
+
showInput: { type: Boolean, default: !0 },
|
|
23
|
+
showFormatToggle: { type: Boolean, default: !0 },
|
|
24
|
+
swatchOnly: { type: Boolean, default: !1 },
|
|
25
|
+
hidden: { type: Boolean, default: !1 },
|
|
26
|
+
size: { default: "md" },
|
|
27
|
+
disabled: { type: Boolean, default: !1 }
|
|
28
|
+
},
|
|
29
|
+
emits: ["update:modelValue"],
|
|
30
|
+
setup(a, { expose: ne, emit: oe }) {
|
|
31
|
+
const re = ["sm", "md", "lg"], n = a, ie = oe, v = s(0), m = s(1), g = s(1), u = s(1), S = s(n.format), f = s(""), ae = {
|
|
32
|
+
sm: { width: "220px", gradientHeight: "130px", sliderHeight: "10px", thumbSize: "14px", swatchSize: "20px", fontSize: "0.75rem" },
|
|
33
|
+
md: { width: "280px", gradientHeight: "160px", sliderHeight: "12px", thumbSize: "16px", swatchSize: "24px", fontSize: "0.8125rem" },
|
|
34
|
+
lg: { width: "340px", gradientHeight: "200px", sliderHeight: "14px", thumbSize: "18px", swatchSize: "28px", fontSize: "0.875rem" }
|
|
35
|
+
}, i = p(() => ae[ze(n.size, re)]), b = p(() => ee(v.value, m.value, g.value)), x = p(() => Ce(b.value.r, b.value.g, b.value.b)), D = p(() => {
|
|
36
|
+
const { r: e, g: t, b: o } = b.value;
|
|
37
|
+
return u.value < 1 ? `rgba(${e}, ${t}, ${o}, ${u.value.toFixed(2)})` : x.value;
|
|
38
|
+
}), y = p(() => {
|
|
39
|
+
const { r: e, g: t, b: o } = b.value;
|
|
40
|
+
return Le(e, t, o, u.value, S.value);
|
|
41
|
+
});
|
|
42
|
+
function V() {
|
|
43
|
+
const e = A(n.modelValue);
|
|
44
|
+
if (e) {
|
|
45
|
+
const t = $(e.r, e.g, e.b);
|
|
46
|
+
v.value = t.h, m.value = t.s, g.value = t.v, u.value = e.a, f.value = y.value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
he(() => n.modelValue, V), J(V);
|
|
50
|
+
const F = s(0);
|
|
51
|
+
let w = null;
|
|
52
|
+
J(() => {
|
|
53
|
+
n.presetPalette === "theme" && typeof MutationObserver < "u" && (w = new MutationObserver(() => {
|
|
54
|
+
F.value++;
|
|
55
|
+
}), w.observe(document.documentElement, { attributes: !0, attributeFilter: ["class"] }));
|
|
56
|
+
}), me(() => {
|
|
57
|
+
w == null || w.disconnect();
|
|
58
|
+
});
|
|
59
|
+
function k() {
|
|
60
|
+
f.value = y.value, ie("update:modelValue", y.value);
|
|
61
|
+
}
|
|
62
|
+
const I = p(() => n.palette ? n.palette : n.presetPalette === "theme" ? (F.value, Me()) : n.presetPalette === "basic" ? Te : n.presetPalette === "material" ? He : n.presetPalette === "tailwind" ? Be : []), P = s(null);
|
|
63
|
+
let C = !1;
|
|
64
|
+
function le(e) {
|
|
65
|
+
n.disabled || (C = !0, W(e), document.addEventListener("pointermove", O), document.addEventListener("pointerup", U));
|
|
66
|
+
}
|
|
67
|
+
function O(e) {
|
|
68
|
+
C && W(e);
|
|
69
|
+
}
|
|
70
|
+
function U() {
|
|
71
|
+
C = !1, document.removeEventListener("pointermove", O), document.removeEventListener("pointerup", U);
|
|
72
|
+
}
|
|
73
|
+
function W(e) {
|
|
74
|
+
if (!P.value) return;
|
|
75
|
+
const t = P.value.getBoundingClientRect();
|
|
76
|
+
m.value = Math.max(0, Math.min(1, (e.clientX - t.left) / t.width)), g.value = Math.max(0, Math.min(1, 1 - (e.clientY - t.top) / t.height)), k();
|
|
77
|
+
}
|
|
78
|
+
const L = s(null);
|
|
79
|
+
let M = !1;
|
|
80
|
+
function ue(e) {
|
|
81
|
+
n.disabled || (M = !0, X(e), document.addEventListener("pointermove", G), document.addEventListener("pointerup", N));
|
|
82
|
+
}
|
|
83
|
+
function G(e) {
|
|
84
|
+
M && X(e);
|
|
85
|
+
}
|
|
86
|
+
function N() {
|
|
87
|
+
M = !1, document.removeEventListener("pointermove", G), document.removeEventListener("pointerup", N);
|
|
88
|
+
}
|
|
89
|
+
function X(e) {
|
|
90
|
+
if (!L.value) return;
|
|
91
|
+
const t = L.value.getBoundingClientRect();
|
|
92
|
+
v.value = Math.max(0, Math.min(360, (e.clientX - t.left) / t.width * 360)), k();
|
|
93
|
+
}
|
|
94
|
+
const T = s(null);
|
|
95
|
+
let H = !1;
|
|
96
|
+
function se(e) {
|
|
97
|
+
n.disabled || (H = !0, Z(e), document.addEventListener("pointermove", K), document.addEventListener("pointerup", Y));
|
|
98
|
+
}
|
|
99
|
+
function K(e) {
|
|
100
|
+
H && Z(e);
|
|
101
|
+
}
|
|
102
|
+
function Y() {
|
|
103
|
+
H = !1, document.removeEventListener("pointermove", K), document.removeEventListener("pointerup", Y);
|
|
104
|
+
}
|
|
105
|
+
function Z(e) {
|
|
106
|
+
if (!T.value) return;
|
|
107
|
+
const t = T.value.getBoundingClientRect();
|
|
108
|
+
u.value = Math.max(0, Math.min(1, (e.clientX - t.left) / t.width)), u.value = Math.round(u.value * 100) / 100, k();
|
|
109
|
+
}
|
|
110
|
+
function j() {
|
|
111
|
+
const e = A(f.value);
|
|
112
|
+
if (e) {
|
|
113
|
+
const t = $(e.r, e.g, e.b);
|
|
114
|
+
v.value = t.h, m.value = t.s, g.value = t.v, u.value = e.a, k();
|
|
115
|
+
} else
|
|
116
|
+
f.value = y.value;
|
|
117
|
+
}
|
|
118
|
+
function de() {
|
|
119
|
+
const e = ["hex", "rgb", "hsl"], t = e.indexOf(S.value);
|
|
120
|
+
S.value = e[(t + 1) % e.length], f.value = y.value;
|
|
121
|
+
}
|
|
122
|
+
function ce(e) {
|
|
123
|
+
if (n.disabled) return;
|
|
124
|
+
const t = A(e);
|
|
125
|
+
if (t) {
|
|
126
|
+
const o = $(t.r, t.g, t.b);
|
|
127
|
+
v.value = o.h, m.value = o.s, g.value = o.v, u.value = t.a, k();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const q = p(() => {
|
|
131
|
+
const e = ee(v.value, 1, 1);
|
|
132
|
+
return `rgb(${e.r}, ${e.g}, ${e.b})`;
|
|
133
|
+
}), E = Q("rootEl"), R = Q("inputEl");
|
|
134
|
+
function ve(e) {
|
|
135
|
+
var t;
|
|
136
|
+
R.value ? R.value.focus(e) : (t = E.value) == null || t.focus(e);
|
|
137
|
+
}
|
|
138
|
+
function fe() {
|
|
139
|
+
var e;
|
|
140
|
+
R.value ? R.value.blur() : (e = E.value) == null || e.blur();
|
|
141
|
+
}
|
|
142
|
+
return ne({ el: E, focus: ve, blur: fe }), (e, t) => _((d(), c("div", {
|
|
143
|
+
ref_key: "rootEl",
|
|
144
|
+
ref: E,
|
|
145
|
+
style: r({
|
|
146
|
+
width: i.value.width,
|
|
147
|
+
opacity: a.disabled ? "0.5" : "1",
|
|
148
|
+
pointerEvents: a.disabled ? "none" : void 0,
|
|
149
|
+
userSelect: "none"
|
|
150
|
+
})
|
|
151
|
+
}, [
|
|
152
|
+
a.swatchOnly ? h("", !0) : (d(), c("div", {
|
|
153
|
+
key: 0,
|
|
154
|
+
ref_key: "gradientRef",
|
|
155
|
+
ref: P,
|
|
156
|
+
style: r({
|
|
157
|
+
position: "relative",
|
|
158
|
+
width: "100%",
|
|
159
|
+
height: i.value.gradientHeight,
|
|
160
|
+
borderRadius: "0.5rem 0.5rem 0 0",
|
|
161
|
+
cursor: "crosshair",
|
|
162
|
+
overflow: "hidden",
|
|
163
|
+
background: q.value
|
|
164
|
+
}),
|
|
165
|
+
onPointerdown: B(le, ["prevent"])
|
|
166
|
+
}, [
|
|
167
|
+
t[3] || (t[3] = l("div", { style: { position: "absolute", inset: "0", background: "linear-gradient(to right, white, transparent)" } }, null, -1)),
|
|
168
|
+
t[4] || (t[4] = l("div", { style: { position: "absolute", inset: "0", background: "linear-gradient(to bottom, transparent, black)" } }, null, -1)),
|
|
169
|
+
l("div", {
|
|
170
|
+
style: r({
|
|
171
|
+
position: "absolute",
|
|
172
|
+
left: `${m.value * 100}%`,
|
|
173
|
+
top: `${(1 - g.value) * 100}%`,
|
|
174
|
+
width: i.value.thumbSize,
|
|
175
|
+
height: i.value.thumbSize,
|
|
176
|
+
borderRadius: "50%",
|
|
177
|
+
border: "2px solid white",
|
|
178
|
+
boxShadow: "0 1px 4px rgba(0,0,0,0.3)",
|
|
179
|
+
transform: "translate(-50%, -50%)",
|
|
180
|
+
pointerEvents: "none"
|
|
181
|
+
})
|
|
182
|
+
}, null, 4)
|
|
183
|
+
], 36)),
|
|
184
|
+
l("div", {
|
|
185
|
+
style: r({
|
|
186
|
+
padding: "calc(0.75rem * var(--cui-density-scale, 1))",
|
|
187
|
+
background: "var(--cui-surface-base, white)",
|
|
188
|
+
border: "1px solid var(--cui-border)",
|
|
189
|
+
borderTop: a.swatchOnly ? void 0 : "none",
|
|
190
|
+
borderRadius: a.swatchOnly ? "0.5rem" : "0 0 0.5rem 0.5rem",
|
|
191
|
+
display: "flex",
|
|
192
|
+
flexDirection: "column",
|
|
193
|
+
gap: "calc(0.625rem * var(--cui-density-scale, 1))"
|
|
194
|
+
})
|
|
195
|
+
}, [
|
|
196
|
+
a.swatchOnly ? h("", !0) : (d(), c("div", Ae, [
|
|
197
|
+
l("div", {
|
|
198
|
+
style: r({
|
|
199
|
+
width: "2rem",
|
|
200
|
+
height: "2rem",
|
|
201
|
+
borderRadius: "50%",
|
|
202
|
+
border: "1px solid var(--cui-border)",
|
|
203
|
+
flexShrink: "0",
|
|
204
|
+
background: te,
|
|
205
|
+
position: "relative",
|
|
206
|
+
overflow: "hidden"
|
|
207
|
+
})
|
|
208
|
+
}, [
|
|
209
|
+
l("div", {
|
|
210
|
+
style: r({ position: "absolute", inset: "0", borderRadius: "50%", background: D.value })
|
|
211
|
+
}, null, 4)
|
|
212
|
+
], 4),
|
|
213
|
+
l("div", $e, [
|
|
214
|
+
l("div", {
|
|
215
|
+
ref_key: "hueRef",
|
|
216
|
+
ref: L,
|
|
217
|
+
style: r({
|
|
218
|
+
position: "relative",
|
|
219
|
+
height: i.value.sliderHeight,
|
|
220
|
+
borderRadius: "9999px",
|
|
221
|
+
cursor: "pointer",
|
|
222
|
+
background: "linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000)"
|
|
223
|
+
}),
|
|
224
|
+
onPointerdown: B(ue, ["prevent"])
|
|
225
|
+
}, [
|
|
226
|
+
l("div", {
|
|
227
|
+
style: r({
|
|
228
|
+
position: "absolute",
|
|
229
|
+
left: `${v.value / 360 * 100}%`,
|
|
230
|
+
top: "50%",
|
|
231
|
+
width: i.value.thumbSize,
|
|
232
|
+
height: i.value.thumbSize,
|
|
233
|
+
borderRadius: "50%",
|
|
234
|
+
border: "2px solid white",
|
|
235
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.3)",
|
|
236
|
+
transform: "translate(-50%, -50%)",
|
|
237
|
+
pointerEvents: "none",
|
|
238
|
+
background: q.value
|
|
239
|
+
})
|
|
240
|
+
}, null, 4)
|
|
241
|
+
], 36),
|
|
242
|
+
a.showAlpha ? (d(), c("div", {
|
|
243
|
+
key: 0,
|
|
244
|
+
ref_key: "alphaRef",
|
|
245
|
+
ref: T,
|
|
246
|
+
style: r({
|
|
247
|
+
position: "relative",
|
|
248
|
+
height: i.value.sliderHeight,
|
|
249
|
+
borderRadius: "9999px",
|
|
250
|
+
cursor: "pointer",
|
|
251
|
+
background: te,
|
|
252
|
+
overflow: "hidden"
|
|
253
|
+
}),
|
|
254
|
+
onPointerdown: B(se, ["prevent"])
|
|
255
|
+
}, [
|
|
256
|
+
l("div", {
|
|
257
|
+
style: r({ position: "absolute", inset: "0", borderRadius: "9999px", background: `linear-gradient(to right, transparent, ${x.value})` })
|
|
258
|
+
}, null, 4),
|
|
259
|
+
l("div", {
|
|
260
|
+
style: r({
|
|
261
|
+
position: "absolute",
|
|
262
|
+
left: `${u.value * 100}%`,
|
|
263
|
+
top: "50%",
|
|
264
|
+
width: i.value.thumbSize,
|
|
265
|
+
height: i.value.thumbSize,
|
|
266
|
+
borderRadius: "50%",
|
|
267
|
+
border: "2px solid white",
|
|
268
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.3)",
|
|
269
|
+
transform: "translate(-50%, -50%)",
|
|
270
|
+
pointerEvents: "none",
|
|
271
|
+
background: x.value
|
|
272
|
+
})
|
|
273
|
+
}, null, 4)
|
|
274
|
+
], 36)) : h("", !0)
|
|
275
|
+
])
|
|
276
|
+
])),
|
|
277
|
+
a.showInput ? (d(), c("div", De, [
|
|
278
|
+
a.swatchOnly ? (d(), c("div", {
|
|
279
|
+
key: 0,
|
|
280
|
+
style: r({
|
|
281
|
+
width: "1.5rem",
|
|
282
|
+
height: "1.5rem",
|
|
283
|
+
borderRadius: "0.25rem",
|
|
284
|
+
border: "1px solid var(--cui-border)",
|
|
285
|
+
flexShrink: "0",
|
|
286
|
+
background: D.value
|
|
287
|
+
})
|
|
288
|
+
}, null, 4)) : h("", !0),
|
|
289
|
+
_(l("input", {
|
|
290
|
+
ref: "inputEl",
|
|
291
|
+
"onUpdate:modelValue": t[0] || (t[0] = (o) => f.value = o),
|
|
292
|
+
style: r({
|
|
293
|
+
flex: "1",
|
|
294
|
+
padding: "calc(0.3125rem * var(--cui-density-scale, 1)) calc(0.5rem * var(--cui-density-scale, 1))",
|
|
295
|
+
fontSize: i.value.fontSize,
|
|
296
|
+
fontFamily: "var(--cui-font-mono, monospace)",
|
|
297
|
+
border: "1px solid var(--cui-border-strong, var(--cui-border))",
|
|
298
|
+
borderRadius: "0.25rem",
|
|
299
|
+
background: "var(--cui-surface-base, white)",
|
|
300
|
+
color: "var(--cui-text-body)",
|
|
301
|
+
outline: "none",
|
|
302
|
+
minWidth: "0"
|
|
303
|
+
}),
|
|
304
|
+
onKeydown: ge(j, ["enter"]),
|
|
305
|
+
onBlur: j
|
|
306
|
+
}, null, 36), [
|
|
307
|
+
[be, f.value]
|
|
308
|
+
]),
|
|
309
|
+
a.showFormatToggle ? (d(), xe(Pe, {
|
|
310
|
+
key: 1,
|
|
311
|
+
variant: "ghost",
|
|
312
|
+
size: "xs",
|
|
313
|
+
style: r({ flexShrink: "0", fontFamily: "var(--cui-font-mono, monospace)", fontSize: i.value.fontSize, fontWeight: "600", minWidth: "2.5rem" }),
|
|
314
|
+
onClick: de
|
|
315
|
+
}, {
|
|
316
|
+
default: ye(() => [
|
|
317
|
+
we(ke(S.value.toUpperCase()), 1)
|
|
318
|
+
]),
|
|
319
|
+
_: 1
|
|
320
|
+
}, 8, ["style"])) : h("", !0)
|
|
321
|
+
])) : h("", !0),
|
|
322
|
+
I.value.length > 0 ? (d(), c("div", Ve, [
|
|
323
|
+
(d(!0), c(Se, null, Ee(I.value, (o) => (d(), c("div", {
|
|
324
|
+
key: o,
|
|
325
|
+
style: r({
|
|
326
|
+
width: i.value.swatchSize,
|
|
327
|
+
height: i.value.swatchSize,
|
|
328
|
+
borderRadius: "0.25rem",
|
|
329
|
+
background: o,
|
|
330
|
+
cursor: "pointer",
|
|
331
|
+
border: x.value.toLowerCase() === o.toLowerCase() ? "2px solid var(--cui-primary)" : "1px solid var(--cui-border)",
|
|
332
|
+
boxShadow: x.value.toLowerCase() === o.toLowerCase() ? "0 0 0 1px var(--cui-primary)" : "none",
|
|
333
|
+
transition: "transform 0.1s ease"
|
|
334
|
+
}),
|
|
335
|
+
onClick: (z) => ce(o),
|
|
336
|
+
onMouseenter: t[1] || (t[1] = (z) => z.target.style.transform = "scale(1.15)"),
|
|
337
|
+
onMouseleave: t[2] || (t[2] = (z) => z.target.style.transform = "scale(1)")
|
|
338
|
+
}, null, 44, Fe))), 128))
|
|
339
|
+
])) : h("", !0)
|
|
340
|
+
], 4)
|
|
341
|
+
], 4)), [
|
|
342
|
+
[Re, !a.hidden]
|
|
343
|
+
]);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
export {
|
|
347
|
+
Ge as default
|
|
348
|
+
};
|