@nextcloud/vue 8.1.0 → 8.3.0
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 +57 -5
- package/dist/Components/NcActionButton.cjs +16 -8
- package/dist/Components/NcActionButton.cjs.map +1 -1
- package/dist/Components/NcActionButton.mjs +22 -14
- package/dist/Components/NcActionButton.mjs.map +1 -1
- package/dist/Components/NcActionButtonGroup.cjs +22 -11
- package/dist/Components/NcActionButtonGroup.cjs.map +1 -1
- package/dist/Components/NcActionButtonGroup.mjs +19 -7
- package/dist/Components/NcActionButtonGroup.mjs.map +1 -1
- package/dist/Components/NcActionCaption.cjs +17 -11
- package/dist/Components/NcActionCaption.cjs.map +1 -1
- package/dist/Components/NcActionCaption.mjs +14 -8
- package/dist/Components/NcActionCaption.mjs.map +1 -1
- package/dist/Components/NcActionCheckbox.cjs +26 -11
- package/dist/Components/NcActionCheckbox.cjs.map +1 -1
- package/dist/Components/NcActionCheckbox.mjs +26 -11
- package/dist/Components/NcActionCheckbox.mjs.map +1 -1
- package/dist/Components/NcActionInput.cjs +7 -5
- package/dist/Components/NcActionInput.cjs.map +1 -1
- package/dist/Components/NcActionInput.mjs +11 -9
- package/dist/Components/NcActionInput.mjs.map +1 -1
- package/dist/Components/NcActionLink.cjs +14 -6
- package/dist/Components/NcActionLink.cjs.map +1 -1
- package/dist/Components/NcActionLink.mjs +19 -11
- package/dist/Components/NcActionLink.mjs.map +1 -1
- package/dist/Components/NcActionRadio.cjs +29 -14
- package/dist/Components/NcActionRadio.cjs.map +1 -1
- package/dist/Components/NcActionRadio.mjs +26 -11
- package/dist/Components/NcActionRadio.mjs.map +1 -1
- package/dist/Components/NcActionRouter.cjs +14 -8
- package/dist/Components/NcActionRouter.cjs.map +1 -1
- package/dist/Components/NcActionRouter.mjs +17 -11
- package/dist/Components/NcActionRouter.mjs.map +1 -1
- package/dist/Components/NcActionSeparator.cjs +10 -10
- package/dist/Components/NcActionSeparator.cjs.map +1 -1
- package/dist/Components/NcActionSeparator.mjs +11 -11
- package/dist/Components/NcActionSeparator.mjs.map +1 -1
- package/dist/Components/NcActionText.cjs +15 -9
- package/dist/Components/NcActionText.cjs.map +1 -1
- package/dist/Components/NcActionText.mjs +20 -14
- package/dist/Components/NcActionText.mjs.map +1 -1
- package/dist/Components/NcActionTextEditable.cjs +1 -1
- package/dist/Components/NcActionTextEditable.mjs +1 -1
- package/dist/Components/NcActions.cjs +100 -79
- package/dist/Components/NcActions.cjs.map +1 -1
- package/dist/Components/NcActions.mjs +103 -82
- package/dist/Components/NcActions.mjs.map +1 -1
- package/dist/Components/NcAppContent.cjs +1 -1
- package/dist/Components/NcAppContent.mjs +1 -1
- package/dist/Components/NcAppNavigation.cjs +14 -14
- package/dist/Components/NcAppNavigation.cjs.map +1 -1
- package/dist/Components/NcAppNavigation.mjs +20 -20
- package/dist/Components/NcAppNavigation.mjs.map +1 -1
- package/dist/Components/NcAppNavigationCaption.cjs +2 -2
- package/dist/Components/NcAppNavigationCaption.cjs.map +1 -1
- package/dist/Components/NcAppNavigationCaption.mjs +2 -2
- package/dist/Components/NcAppNavigationCaption.mjs.map +1 -1
- package/dist/Components/NcAppNavigationItem.cjs +3 -3
- package/dist/Components/NcAppNavigationItem.cjs.map +1 -1
- package/dist/Components/NcAppNavigationItem.mjs +4 -4
- package/dist/Components/NcAppNavigationItem.mjs.map +1 -1
- package/dist/Components/NcAppNavigationNewItem.cjs +1 -1
- package/dist/Components/NcAppNavigationNewItem.mjs +1 -1
- package/dist/Components/NcAppNavigationSettings.cjs +1 -1
- package/dist/Components/NcAppNavigationSettings.mjs +1 -1
- package/dist/Components/NcAppNavigationToggle.cjs +1 -1
- package/dist/Components/NcAppNavigationToggle.mjs +1 -1
- package/dist/Components/NcAppSettingsDialog.cjs +33 -33
- package/dist/Components/NcAppSettingsDialog.cjs.map +1 -1
- package/dist/Components/NcAppSettingsDialog.mjs +57 -56
- package/dist/Components/NcAppSettingsDialog.mjs.map +1 -1
- package/dist/Components/NcAppSidebar.cjs +3 -3
- package/dist/Components/NcAppSidebar.cjs.map +1 -1
- package/dist/Components/NcAppSidebar.mjs +3 -3
- package/dist/Components/NcAppSidebar.mjs.map +1 -1
- package/dist/Components/NcAvatar.cjs +1 -1
- package/dist/Components/NcAvatar.mjs +1 -1
- package/dist/Components/NcButton.cjs +6 -4
- package/dist/Components/NcButton.cjs.map +1 -1
- package/dist/Components/NcButton.mjs +11 -9
- package/dist/Components/NcButton.mjs.map +1 -1
- package/dist/Components/NcCheckboxRadioSwitch.cjs +7 -7
- package/dist/Components/NcCheckboxRadioSwitch.cjs.map +1 -1
- package/dist/Components/NcCheckboxRadioSwitch.mjs +7 -7
- package/dist/Components/NcCheckboxRadioSwitch.mjs.map +1 -1
- package/dist/Components/NcColorPicker.cjs +48 -31
- package/dist/Components/NcColorPicker.cjs.map +1 -1
- package/dist/Components/NcColorPicker.mjs +58 -40
- package/dist/Components/NcColorPicker.mjs.map +1 -1
- package/dist/Components/NcDashboardWidget.cjs +1 -1
- package/dist/Components/NcDashboardWidget.mjs +2 -2
- package/dist/Components/NcDashboardWidgetItem.cjs +1 -1
- package/dist/Components/NcDashboardWidgetItem.mjs +1 -1
- package/dist/Components/NcDateTime.cjs +17 -14
- package/dist/Components/NcDateTime.cjs.map +1 -1
- package/dist/Components/NcDateTime.mjs +18 -15
- package/dist/Components/NcDateTime.mjs.map +1 -1
- package/dist/Components/NcDateTimePicker.cjs +2 -2
- package/dist/Components/NcDateTimePicker.mjs +4 -4
- package/dist/Components/NcDateTimePickerNative.cjs +1 -1
- package/dist/Components/NcDateTimePickerNative.mjs +1 -1
- package/dist/Components/NcDialog.cjs +15 -15
- package/dist/Components/NcDialog.cjs.map +1 -1
- package/dist/Components/NcDialog.mjs +13 -13
- package/dist/Components/NcDialog.mjs.map +1 -1
- package/dist/Components/NcDialogButton.cjs +1 -1
- package/dist/Components/NcDialogButton.cjs.map +1 -1
- package/dist/Components/NcDialogButton.mjs +1 -1
- package/dist/Components/NcDialogButton.mjs.map +1 -1
- package/dist/Components/NcEmojiPicker.cjs +1 -1
- package/dist/Components/NcEmojiPicker.mjs +1 -1
- package/dist/Components/NcInputField.cjs +15 -4
- package/dist/Components/NcInputField.cjs.map +1 -1
- package/dist/Components/NcInputField.mjs +18 -7
- package/dist/Components/NcInputField.mjs.map +1 -1
- package/dist/Components/NcListItem.cjs +1 -1
- package/dist/Components/NcListItem.mjs +1 -1
- package/dist/Components/NcListItemIcon.cjs +1 -1
- package/dist/Components/NcListItemIcon.mjs +1 -1
- package/dist/Components/NcModal.cjs +1 -1
- package/dist/Components/NcModal.mjs +3 -3
- package/dist/Components/NcPasswordField.cjs +1 -1
- package/dist/Components/NcPasswordField.mjs +1 -1
- package/dist/Components/NcRelatedResourcesPanel.cjs +1 -1
- package/dist/Components/NcRelatedResourcesPanel.mjs +1 -1
- package/dist/Components/NcRichContenteditable.cjs +5 -5
- package/dist/Components/NcRichContenteditable.cjs.map +1 -1
- package/dist/Components/NcRichContenteditable.mjs +5 -5
- package/dist/Components/NcRichContenteditable.mjs.map +1 -1
- package/dist/Components/NcRichText.cjs +1 -1
- package/dist/Components/NcRichText.mjs +3 -3
- package/dist/Components/NcSelect.cjs +1 -1
- package/dist/Components/NcSelect.mjs +2 -2
- package/dist/Components/NcSelectTags.cjs +1 -1
- package/dist/Components/NcSelectTags.mjs +1 -1
- package/dist/Components/NcSettingsInputText.cjs +1 -1
- package/dist/Components/NcSettingsInputText.mjs +1 -1
- package/dist/Components/NcSettingsSection.cjs +1 -1
- package/dist/Components/NcSettingsSection.mjs +1 -1
- package/dist/Components/NcSettingsSelectGroup.cjs +1 -1
- package/dist/Components/NcSettingsSelectGroup.mjs +1 -1
- package/dist/Components/NcTextArea.cjs +5 -5
- package/dist/Components/NcTextArea.cjs.map +1 -1
- package/dist/Components/NcTextArea.mjs +4 -4
- package/dist/Components/NcTextArea.mjs.map +1 -1
- package/dist/Components/NcTextField.cjs +1 -1
- package/dist/Components/NcTextField.mjs +1 -1
- package/dist/Components/NcTimezonePicker.cjs +1 -1
- package/dist/Components/NcTimezonePicker.mjs +1 -1
- package/dist/Components/NcUserBubble.cjs +1 -1
- package/dist/Components/NcUserBubble.mjs +1 -1
- package/dist/Composables/useIsFullscreen.cjs +1 -2
- package/dist/Composables/useIsFullscreen.cjs.map +1 -1
- package/dist/Composables/useIsFullscreen.mjs +1 -2
- package/dist/Composables/useIsFullscreen.mjs.map +1 -1
- package/dist/Functions/usernameToColor.cjs +1 -1
- package/dist/Functions/usernameToColor.mjs +1 -1
- package/dist/assets/{NcAppNavigationToggle-9e170630.css → NcAppNavigationToggle-2bc73ee8.css} +2 -2
- package/dist/assets/{NcSettingsSelectGroup-0d38d76b.css → NcSettingsSelectGroup-6ddb63a6.css} +2 -2
- package/dist/assets/{index-d3702c91.css → index-00012a4c.css} +18 -18
- package/dist/assets/{index-8f52a20f.css → index-018895f7.css} +2 -2
- package/dist/assets/{index-a0532427.css → index-2a1ec06b.css} +42 -36
- package/dist/assets/{index-6899d75b.css → index-30ca9574.css} +31 -30
- package/dist/assets/{index-2e31f707.css → index-3d1ccc15.css} +29 -29
- package/dist/assets/{index-441b6552.css → index-418d4e87.css} +2 -2
- package/dist/assets/{index-05760fea.css → index-4ba699a1.css} +12 -12
- package/dist/assets/{index-dce4b705.css → index-50dc154e.css} +10 -10
- package/dist/assets/{index-24f6c355.css → index-542cf50a.css} +12 -12
- package/dist/assets/{index-4437e6bf.css → index-5784183b.css} +8 -8
- package/dist/assets/{index-f8d6daf3.css → index-5e4bf286.css} +41 -41
- package/dist/assets/{index-4ef32afd.css → index-7157aefa.css} +26 -23
- package/dist/assets/{index-802d2118.css → index-7868494b.css} +24 -24
- package/dist/assets/{index-0e9b11c7.css → index-7fac55ed.css} +24 -24
- package/dist/assets/{index-9ca89b81.css → index-810b8984.css} +16 -19
- package/dist/assets/{index-e7c55791.css → index-9020d9ca.css} +67 -67
- package/dist/assets/{index-dc612aa3.css → index-9941f384.css} +15 -12
- package/dist/assets/{index-55600948.css → index-b0a8a48c.css} +11 -11
- package/dist/assets/{index-baf8711a.css → index-e0e6bab6.css} +12 -12
- package/dist/assets/{index-fbc0b606.css → index-e6a91529.css} +50 -45
- package/dist/assets/{index-d812ed9e.css → index-f091e784.css} +43 -43
- package/dist/assets/{index-edee3304.css → index-f72cef5d.css} +6 -7
- package/dist/assets/{index-d9ae9479.css → index-ffa6d11c.css} +7 -7
- package/dist/chunks/GenColors-12ec1caa.mjs +56 -0
- package/dist/chunks/GenColors-12ec1caa.mjs.map +1 -0
- package/dist/chunks/GenColors-a8d54566.cjs +55 -0
- package/dist/chunks/GenColors-a8d54566.cjs.map +1 -0
- package/dist/chunks/{NcAppNavigationToggle-d248cb09.cjs → NcAppNavigationToggle-6a975868.cjs} +21 -26
- package/dist/chunks/{NcAppNavigationToggle-a031dce0.mjs.map → NcAppNavigationToggle-6a975868.cjs.map} +1 -1
- package/dist/chunks/{NcAppNavigationToggle-a031dce0.mjs → NcAppNavigationToggle-f5591773.mjs} +25 -30
- package/dist/chunks/{NcAppNavigationToggle-d248cb09.cjs.map → NcAppNavigationToggle-f5591773.mjs.map} +1 -1
- package/dist/chunks/{NcInputConfirmCancel-40ea7cd1.mjs → NcInputConfirmCancel-7837eb4d.mjs} +1 -1
- package/dist/chunks/{NcInputConfirmCancel-40ea7cd1.mjs.map → NcInputConfirmCancel-7837eb4d.mjs.map} +1 -1
- package/dist/chunks/{NcInputConfirmCancel-00bdeac7.cjs → NcInputConfirmCancel-790f5902.cjs} +1 -1
- package/dist/chunks/{NcInputConfirmCancel-00bdeac7.cjs.map → NcInputConfirmCancel-790f5902.cjs.map} +1 -1
- package/dist/chunks/{NcRichText-e2026b55.mjs → NcRichText-0db09c78.mjs} +1 -1
- package/dist/chunks/{NcRichText-e2026b55.mjs.map → NcRichText-0db09c78.mjs.map} +1 -1
- package/dist/chunks/{NcRichText-89373b11.cjs → NcRichText-0dd96aac.cjs} +1 -1
- package/dist/chunks/{NcRichText-89373b11.cjs.map → NcRichText-0dd96aac.cjs.map} +1 -1
- package/dist/chunks/{NcSettingsSelectGroup-fad68876.cjs → NcSettingsSelectGroup-532ba813.cjs} +12 -12
- package/dist/chunks/NcSettingsSelectGroup-532ba813.cjs.map +1 -0
- package/dist/chunks/{NcSettingsSelectGroup-b49652df.mjs → NcSettingsSelectGroup-cdd84895.mjs} +12 -12
- package/dist/chunks/NcSettingsSelectGroup-cdd84895.mjs.map +1 -0
- package/dist/chunks/{ScopeComponent-a24eb082.cjs → ScopeComponent-92144d97.cjs} +1 -1
- package/dist/chunks/{ScopeComponent-a24eb082.cjs.map → ScopeComponent-92144d97.cjs.map} +1 -1
- package/dist/chunks/{ScopeComponent-a06864ef.mjs → ScopeComponent-ac5265f5.mjs} +1 -1
- package/dist/chunks/{ScopeComponent-a06864ef.mjs.map → ScopeComponent-ac5265f5.mjs.map} +1 -1
- package/dist/chunks/{actionText-a64be267.mjs → actionText-60ff01d1.mjs} +3 -1
- package/dist/chunks/{actionText-54bc24a6.cjs.map → actionText-60ff01d1.mjs.map} +1 -1
- package/dist/chunks/{actionText-54bc24a6.cjs → actionText-9582810f.cjs} +3 -1
- package/dist/chunks/{actionText-a64be267.mjs.map → actionText-9582810f.cjs.map} +1 -1
- package/dist/chunks/{index-ac31691c.cjs → index-32c8b581.cjs} +1 -1
- package/dist/chunks/{index-ac31691c.cjs.map → index-32c8b581.cjs.map} +1 -1
- package/dist/chunks/{index-831524a1.mjs → index-efb07851.mjs} +1 -1
- package/dist/chunks/{index-831524a1.mjs.map → index-efb07851.mjs.map} +1 -1
- package/dist/chunks/l10n-070da9ad.cjs +29 -0
- package/dist/chunks/l10n-070da9ad.cjs.map +1 -0
- package/dist/chunks/l10n-1b905a9a.mjs +31 -0
- package/dist/chunks/l10n-1b905a9a.mjs.map +1 -0
- package/dist/chunks/{l10n-098e6a54.cjs → l10n-38626490.cjs} +1 -1
- package/dist/chunks/{l10n-098e6a54.cjs.map → l10n-38626490.cjs.map} +1 -1
- package/dist/chunks/{l10n-a929cdef.mjs → l10n-6cfc1200.mjs} +1 -1
- package/dist/chunks/{l10n-a929cdef.mjs.map → l10n-6cfc1200.mjs.map} +1 -1
- package/dist/chunks/{referencePickerModal-b79b7b92.cjs → referencePickerModal-90dac0d0.cjs} +1 -1
- package/dist/chunks/{referencePickerModal-b79b7b92.cjs.map → referencePickerModal-90dac0d0.cjs.map} +1 -1
- package/dist/chunks/{referencePickerModal-c87eab17.mjs → referencePickerModal-ded8273d.mjs} +1 -1
- package/dist/chunks/{referencePickerModal-c87eab17.mjs.map → referencePickerModal-ded8273d.mjs.map} +1 -1
- package/dist/index.cjs +139 -134
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +96 -89
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/GenColors-38246c38.mjs +0 -46
- package/dist/chunks/GenColors-38246c38.mjs.map +0 -1
- package/dist/chunks/GenColors-eedcc70a.cjs +0 -45
- package/dist/chunks/GenColors-eedcc70a.cjs.map +0 -1
- package/dist/chunks/NcSettingsSelectGroup-b49652df.mjs.map +0 -1
- package/dist/chunks/NcSettingsSelectGroup-fad68876.cjs.map +0 -1
- package/dist/chunks/l10n-c3dbf018.cjs +0 -29
- package/dist/chunks/l10n-c3dbf018.cjs.map +0 -1
- package/dist/chunks/l10n-f51d3415.mjs +0 -31
- package/dist/chunks/l10n-f51d3415.mjs.map +0 -1
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
return e
|
|
6
|
-
}
|
|
1
|
+
var x = require("../assets/index-7157aefa.css");
|
|
2
|
+
const s = require("./NcButton.cjs"), i = require("./NcPopover.cjs"), a = require("../chunks/l10n-070da9ad.cjs"), u = require("../chunks/GenColors-a8d54566.cjs"), d = require("../chunks/GenRandomId-c214d235.cjs"), p = require("../chunks/ArrowLeft-2f9b9323.cjs"), _ = require("../chunks/Check-be8cd6af.cjs"), v = require("../chunks/DotsHorizontal-ac96129a.cjs"), f = require("vue-color"), h = require("../chunks/_plugin-vue2_normalizer-7f9efb60.cjs");
|
|
3
|
+
function C({ r: t, g: e, b: r }) {
|
|
4
|
+
const o = (n) => n.toString(16).padStart(2, "0");
|
|
5
|
+
return `#${o(t)}${o(e)}${o(r)}`;
|
|
6
|
+
}
|
|
7
|
+
const c = /^#([a-f0-9]{3}|[a-f0-9]{6})$/i, m = {
|
|
7
8
|
name: "NcColorPicker",
|
|
8
9
|
components: {
|
|
9
|
-
ArrowLeft:
|
|
10
|
-
Check:
|
|
11
|
-
Chrome:
|
|
12
|
-
DotsHorizontal:
|
|
13
|
-
NcButton:
|
|
14
|
-
NcPopover:
|
|
10
|
+
ArrowLeft: p.ArrowLeft,
|
|
11
|
+
Check: _.Check,
|
|
12
|
+
Chrome: f.Chrome,
|
|
13
|
+
DotsHorizontal: v.DotsHorizontal,
|
|
14
|
+
NcButton: s,
|
|
15
|
+
NcPopover: i
|
|
15
16
|
},
|
|
16
17
|
props: {
|
|
17
18
|
/**
|
|
@@ -29,14 +30,19 @@ const a = function(t) {
|
|
|
29
30
|
default: !1
|
|
30
31
|
},
|
|
31
32
|
/**
|
|
32
|
-
* Provide a custom array of
|
|
33
|
+
* Provide a custom array of colors to show.
|
|
34
|
+
* Can be either an array of string hexadecimal colors,
|
|
35
|
+
* or an array of object with a `color` property with hexadecimal color string,
|
|
36
|
+
* and a `name` property for accessibility.
|
|
37
|
+
*
|
|
38
|
+
* @type {string[] | {color: string, name: string}[]}
|
|
33
39
|
*/
|
|
34
40
|
palette: {
|
|
35
41
|
type: Array,
|
|
36
|
-
default: () =>
|
|
37
|
-
validator(t)
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
default: () => u.GenColors(4).map((t) => ({ color: C(t), name: t.name })),
|
|
43
|
+
validator: (t) => t.every(
|
|
44
|
+
(e) => typeof e == "string" && c.test(e) || typeof e == "object" && e.color && c.test(e.color)
|
|
45
|
+
)
|
|
40
46
|
}
|
|
41
47
|
},
|
|
42
48
|
emits: [
|
|
@@ -50,17 +56,28 @@ const a = function(t) {
|
|
|
50
56
|
return {
|
|
51
57
|
currentColor: this.value,
|
|
52
58
|
advanced: !1,
|
|
53
|
-
ariaBack:
|
|
54
|
-
ariaMore:
|
|
59
|
+
ariaBack: a.t("Back"),
|
|
60
|
+
ariaMore: a.t("More options")
|
|
55
61
|
};
|
|
56
62
|
},
|
|
63
|
+
computed: {
|
|
64
|
+
normalizedPalette() {
|
|
65
|
+
return this.palette.map((t) => ({
|
|
66
|
+
color: typeof t == "object" ? t.color : t,
|
|
67
|
+
name: typeof t == "object" && t.name ? t.name : a.t("A color with a HEX value {hex}", { hex: t.color })
|
|
68
|
+
}));
|
|
69
|
+
},
|
|
70
|
+
uid() {
|
|
71
|
+
return d.GenRandomId();
|
|
72
|
+
}
|
|
73
|
+
},
|
|
57
74
|
watch: {
|
|
58
75
|
value(t) {
|
|
59
76
|
this.currentColor = t;
|
|
60
77
|
}
|
|
61
78
|
},
|
|
62
79
|
methods: {
|
|
63
|
-
t:
|
|
80
|
+
t: a.t,
|
|
64
81
|
/**
|
|
65
82
|
* Submit a picked colour and close picker
|
|
66
83
|
*/
|
|
@@ -89,14 +106,14 @@ const a = function(t) {
|
|
|
89
106
|
}
|
|
90
107
|
}
|
|
91
108
|
};
|
|
92
|
-
var
|
|
109
|
+
var k = function() {
|
|
93
110
|
var e = this, r = e._self._c;
|
|
94
111
|
return r("NcPopover", e._g(e._b({ on: { "apply-hide": e.handleClose }, scopedSlots: e._u([{ key: "trigger", fn: function() {
|
|
95
112
|
return [e._t("default")];
|
|
96
|
-
}, proxy: !0 }], null, !0) }, "NcPopover", e.$attrs, !1), e.$listeners), [r("div", { staticClass: "color-picker", class: { "color-picker--advanced-fields": e.advanced && e.advancedFields } }, [r("
|
|
97
|
-
return r("
|
|
113
|
+
}, proxy: !0 }], null, !0) }, "NcPopover", e.$attrs, !1), e.$listeners), [r("div", { staticClass: "color-picker", class: { "color-picker--advanced-fields": e.advanced && e.advancedFields } }, [r("Transition", { attrs: { name: "slide", mode: "out-in" } }, [e.advanced ? e._e() : r("div", { staticClass: "color-picker__simple" }, e._l(e.normalizedPalette, function({ color: o, name: n }, l) {
|
|
114
|
+
return r("label", { key: l, staticClass: "color-picker__simple-color-circle", class: { "color-picker__simple-color-circle--active": o === e.currentColor }, style: { backgroundColor: o } }, [o === e.currentColor ? r("Check", { attrs: { size: 20 } }) : e._e(), r("input", { staticClass: "hidden-visually", attrs: { type: "radio", "aria-label": n, name: `color-picker-${e.uid}` }, domProps: { checked: o === e.currentColor }, on: { click: function($) {
|
|
98
115
|
return e.pickColor(o);
|
|
99
|
-
} } }
|
|
116
|
+
} } })], 1);
|
|
100
117
|
}), 0), e.advanced ? r("Chrome", { staticClass: "color-picker__advanced", attrs: { "disable-alpha": !0, "disable-fields": !e.advancedFields }, on: { input: e.pickColor }, model: { value: e.currentColor, callback: function(o) {
|
|
101
118
|
e.currentColor = o;
|
|
102
119
|
}, expression: "currentColor" } }) : e._e()], 1), r("div", { staticClass: "color-picker__navigation" }, [e.advanced ? r("NcButton", { attrs: { type: "tertiary", "aria-label": e.ariaBack }, on: { click: e.handleBack }, scopedSlots: e._u([{ key: "icon", fn: function() {
|
|
@@ -104,15 +121,15 @@ var f = function() {
|
|
|
104
121
|
}, proxy: !0 }], null, !1, 1821202730) }) : e._e(), e.advanced ? e._e() : r("NcButton", { attrs: { type: "tertiary", "aria-label": e.ariaMore }, on: { click: e.handleMoreSettings }, scopedSlots: e._u([{ key: "icon", fn: function() {
|
|
105
122
|
return [r("DotsHorizontal", { attrs: { size: 20 } })];
|
|
106
123
|
}, proxy: !0 }], null, !1, 1056868794) }), e.advanced ? r("NcButton", { attrs: { type: "primary" }, on: { click: e.handleConfirm } }, [e._v(" " + e._s(e.t("Choose")) + " ")]) : e._e()], 1)], 1)]);
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
124
|
+
}, y = [], b = /* @__PURE__ */ h.normalizeComponent(
|
|
125
|
+
m,
|
|
126
|
+
k,
|
|
127
|
+
y,
|
|
111
128
|
!1,
|
|
112
129
|
null,
|
|
113
|
-
"
|
|
130
|
+
"b23899c8",
|
|
114
131
|
null,
|
|
115
132
|
null
|
|
116
133
|
);
|
|
117
|
-
const
|
|
118
|
-
module.exports =
|
|
134
|
+
const g = b.exports;
|
|
135
|
+
module.exports = g;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NcColorPicker.cjs","sources":["../../src/components/NcColorPicker/NcColorPicker.vue"],"sourcesContent":["<!--\n - @copyright Copyright (c) 2019 Marco Ambrosini <marcoambrosini@icloud.com>\n -\n - @author Marco Ambrosini <marcoambrosini@icloud.com>\n -\n - @license GNU AGPL version 3 or any later version\n -\n - This program is free software: you can redistribute it and/or modify\n - it under the terms of the GNU Affero General Public License as\n - published by the Free Software Foundation, either version 3 of the\n - License, or (at your option) any later version.\n -\n - This program is distributed in the hope that it will be useful,\n - but WITHOUT ANY WARRANTY; without even the implied warranty of\n - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n - GNU Affero General Public License for more details.\n -\n - You should have received a copy of the GNU Affero General Public License\n - along with this program. If not, see <http://www.gnu.org/licenses/>.\n -\n -->\n\n<docs>\n\n### General description\n\nThis component allows the user to choose a color. It consists of 2\nactual pickers:\n\n- One simple picker with a predefined palette of colors;\n- One more advanced picker that provides the full color spectrum;\n\n### Usage\n\n* Using v-model and passing in an HTML element that will be treated as a trigger:\n\n```vue\n<template>\n\t<div class=\"container0\">\n\t\t<NcColorPicker v-model=\"color\">\n\t\t\t<NcButton> Click Me </NcButton>\n\t\t</NcColorPicker>\n\t\t<NcColorPicker v-model=\"color\" :palette=\"customPalette\">\n\t\t\t<NcButton> Click Me for a custom palette </NcButton>\n\t\t</NcColorPicker>\n\t\t<div :style=\"{'background-color': color}\" class=\"color0\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tcolor: '#0082c9',\n\t\t\tcustomPalette: [\n\t\t\t\t'#E40303',\n\t\t\t\t'#FF8C00',\n\t\t\t\t'#FFED00',\n\t\t\t\t'#008026',\n\t\t\t\t'#24408E',\n\t\t\t\t'#732982',\n\t\t\t\t'#5BCEFA',\n\t\t\t\t'#F5A9B8',\n\t\t\t\t'#FFFFFF',\n\t\t\t\t'#F5A9B8',\n\t\t\t\t'#5BCEFA',\n\t\t\t],\n\t\t}\n\t}\n}\n</script>\n<style>\n.container0 {\n\tdisplay: flex;\n\tgap: 20px;\n}\n\n.color0 {\n\twidth: 100px;\n\theight: 40px;\n\tborder-radius: 6px;\n}\n</style>\n```\n\n* Using v-bind for both color and open state and emitting an event that updates the color\n\n```vue\n<template>\n\t<div class=\"container1\">\n\t\t<NcButton @click=\"open = !open\"> Click Me </NcButton>\n\t\t<NcColorPicker :value=\"color\" @input=\"updateColor\" :shown.sync=\"open\">\n\t\t\t<div :style=\"{'background-color': color}\" class=\"color1\" />\n\t\t</NcColorPicker>\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tcolor: '#0082c9',\n\t\t\topen: false\n\t\t}\n\t},\n\tmethods: {\n\t\tupdateColor(e) {\n\t\t\tthis.color = e\n\t\t}\n\t}\n}\n</script>\n<style>\n.container1 {\n\tdisplay: flex;\n}\n\n.color1 {\n\twidth: 100px;\n\theight: 40px;\n\tmargin-left: 20px;\n\tborder-radius: 6px;\n}\n</style>\n```\n\n* Using advanced fields including HEX, RGB, and HSL:\n\n```vue\n<template>\n\t<div class=\"container0\">\n\t\t<NcColorPicker v-model=\"color\"\n\t\t\t:advanced-fields=\"true\">\n\t\t\t<NcButton> Click Me </NcButton>\n\t\t</NcColorPicker>\n\t\t<div :style=\"{'background-color': color}\" class=\"color0\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tcolor: '#0082c9'\n\t\t}\n\t}\n}\n</script>\n<style>\n.container0 {\n\tdisplay: flex;\n}\n\n.color0 {\n\twidth: 100px;\n\theight: 40px;\n\tmargin-left: 20px;\n\tborder-radius: 6px;\n}\n</style>\n```\n</docs>\n\n<template>\n\t<NcPopover v-bind=\"$attrs\" v-on=\"$listeners\" @apply-hide=\"handleClose\">\n\t\t<template #trigger>\n\t\t\t<slot />\n\t\t</template>\n\t\t<div class=\"color-picker\"\n\t\t\t:class=\"{ 'color-picker--advanced-fields': advanced && advancedFields }\">\n\t\t\t<transition name=\"slide\" mode=\"out-in\">\n\t\t\t\t<div v-if=\"!advanced\" class=\"color-picker__simple\">\n\t\t\t\t\t<button v-for=\"(color, index) in palette\"\n\t\t\t\t\t\t:key=\"index\"\n\t\t\t\t\t\t:style=\"{'background-color': color }\"\n\t\t\t\t\t\tclass=\"color-picker__simple-color-circle\"\n\t\t\t\t\t\t:class=\"{ 'color-picker__simple-color-circle--active' : color === currentColor }\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t@click=\"pickColor(color)\">\n\t\t\t\t\t\t<Check v-if=\"color === currentColor\"\n\t\t\t\t\t\t\t:size=\"20\" />\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<Chrome v-if=\"advanced\"\n\t\t\t\t\tv-model=\"currentColor\"\n\t\t\t\t\tclass=\"color-picker__advanced\"\n\t\t\t\t\t:disable-alpha=\"true\"\n\t\t\t\t\t:disable-fields=\"!advancedFields\"\n\t\t\t\t\t@input=\"pickColor\" />\n\t\t\t</transition>\n\t\t\t<div class=\"color-picker__navigation\">\n\t\t\t\t<NcButton v-if=\"advanced\"\n\t\t\t\t\ttype=\"tertiary\"\n\t\t\t\t\t:aria-label=\"ariaBack\"\n\t\t\t\t\t@click=\"handleBack\">\n\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t<ArrowLeft :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t</NcButton>\n\t\t\t\t<NcButton v-if=\"!advanced\"\n\t\t\t\t\ttype=\"tertiary\"\n\t\t\t\t\t:aria-label=\"ariaMore\"\n\t\t\t\t\t@click=\"handleMoreSettings\">\n\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t<DotsHorizontal :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t</NcButton>\n\t\t\t\t<NcButton v-if=\"advanced\"\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\t@click=\"handleConfirm\">\n\t\t\t\t\t{{ t('Choose') }}\n\t\t\t\t</NcButton>\n\t\t\t</div>\n\t\t</div>\n\t</NcPopover>\n</template>\n\n<script>\nimport NcButton from '../NcButton/index.js'\nimport NcPopover from '../NcPopover/index.js'\nimport { t } from '../../l10n.js'\nimport GenColors from '../../utils/GenColors.js'\n\nimport ArrowLeft from 'vue-material-design-icons/ArrowLeft.vue'\nimport Check from 'vue-material-design-icons/Check.vue'\nimport DotsHorizontal from 'vue-material-design-icons/DotsHorizontal.vue'\n\nimport { Chrome } from 'vue-color'\n\nconst rgbToHex = function(color) {\n\tconst hex = color.toString(16)\n\treturn hex.length === 1 ? '0' + hex : hex\n}\n\nexport default {\n\tname: 'NcColorPicker',\n\n\tcomponents: {\n\t\tArrowLeft,\n\t\tCheck,\n\t\tChrome,\n\t\tDotsHorizontal,\n\t\tNcButton,\n\t\tNcPopover,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * A HEX color that represents the initial value of the picker\n\t\t */\n\t\tvalue: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/**\n\t\t * Set to `true` to enable advanced fields including HEX, RGB, and HSL\n\t\t */\n\t\tadvancedFields: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * Provide a custom array of hexadecimal colors to show\n\t\t */\n\t\tpalette: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => GenColors(4).map(color => {\n\t\t\t\treturn '#' + rgbToHex(color.r) + rgbToHex(color.g) + rgbToHex(color.b)\n\t\t\t}),\n\t\t\tvalidator(palette) {\n\t\t\t\treturn palette.every(color => /^#([a-f0-9]{3}|[a-f0-9]{6})$/i.test(color))\n\t\t\t},\n\t\t},\n\t},\n\n\temits: [\n\t\t'submit',\n\t\t'close',\n\t\t'update:open',\n\t\t'update:value',\n\t\t'input',\n\t],\n\n\tdata() {\n\t\treturn {\n\t\t\tcurrentColor: this.value,\n\t\t\tadvanced: false,\n\t\t\tariaBack: t('Back'),\n\t\t\tariaMore: t('More options'),\n\t\t}\n\t},\n\n\twatch: {\n\t\tvalue(color) {\n\t\t\tthis.currentColor = color\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * Submit a picked colour and close picker\n\t\t */\n\t\thandleConfirm() {\n\t\t\t/**\n\t\t\t * Emits a hexadecimal string e.g. '#ffffff'\n\t\t\t */\n\t\t\tthis.$emit('submit', this.currentColor)\n\t\t\tthis.handleClose()\n\n\t\t\tthis.advanced = false\n\t\t},\n\t\thandleClose() {\n\t\t\t/**\n\t\t\t * Emitted after picker close\n\t\t\t */\n\t\t\tthis.$emit('close')\n\t\t\tthis.$emit('update:open', false)\n\t\t},\n\n\t\t/**\n\t\t * Inner navigations\n\t\t */\n\t\thandleBack() {\n\t\t\tthis.advanced = false\n\t\t},\n\t\thandleMoreSettings() {\n\t\t\tthis.advanced = true\n\t\t},\n\n\t\t/**\n\t\t * Pick a colour\n\t\t *\n\t\t * @param {string} color the picked color\n\t\t */\n\t\tpickColor(color) {\n\t\t\tif (typeof color !== 'string') {\n\t\t\t\tcolor = this.currentColor.hex\n\t\t\t}\n\t\t\tthis.currentColor = color\n\n\t\t\t/**\n\t\t\t * Emits a hexadecimal string e.g. '#ffffff'\n\t\t\t */\n\t\t\tthis.$emit('update:value', color)\n\n\t\t\t/**\n\t\t\t * Emits a hexadecimal string e.g. '#ffffff'\n\t\t\t */\n\t\t\tthis.$emit('input', color)\n\n\t\t},\n\t},\n}\n\n</script>\n\n<style lang=\"scss\" scoped>\n.color-picker {\n\tdisplay: flex;\n\toverflow: hidden;\n\talign-content: flex-end;\n\tflex-direction: column;\n\tjustify-content: space-between;\n\tbox-sizing: content-box !important;\n\twidth: 176px;\n\tpadding: 8px;\n\tborder-radius: 3px;\n\n\t&--advanced-fields {\n\t\twidth: 264px;\n\t}\n\n\t&__simple {\n\t\tdisplay: grid;\n\t\tgrid-template-columns: repeat(auto-fit, $clickable-area);\n\t\tgrid-auto-rows: $clickable-area;\n\n\t\t&-color-circle {\n\t\t\tdisplay: flex;\n\t\t\talign-items: center;\n\t\t\tjustify-content: center;\n\t\t\twidth: 34px;\n\t\t\theight: 34px;\n\t\t\tmin-height: 34px;\n\t\t\tmargin: auto;\n\t\t\tpadding: 0;\n\t\t\tcolor: white;\n\t\t\tborder: 1px solid rgba(0, 0, 0, 0.25);\n\t\t\tborder-radius: 50%;\n\t\t\tfont-size: 16px;\n\t\t\t&:hover {\n\t\t\t\topacity: .6;\n\t\t\t}\n\t\t\t&--active {\n\t\t\t\twidth: 38px;\n\t\t\t\theight: 38px;\n\t\t\t\tmin-height: 38px;\n\t\t\t\ttransition: all 100ms ease-in-out;\n\t\t\t\topacity: 1 !important;\n\t\t\t}\n\t\t}\n\t}\n\n\t&__advanced {\n\t\tbox-shadow: none !important;\n\t}\n\n\t&__navigation {\n\t\tdisplay: flex;\n\t\tflex-direction: row;\n\t\tjustify-content: space-between;\n\t\tmargin-top: 10px;\n\t}\n}\n\n:deep() .vc {\n\t&-chrome {\n\t\twidth: unset;\n\t\tbackground-color: var(--color-main-background);\n\n\t\t&-color-wrap {\n\t\t\twidth: 30px;\n\t\t\theight: 30px;\n\t\t}\n\n\t\t&-active-color {\n\t\t\twidth: 34px;\n\t\t\theight: 34px;\n\t\t\tborder-radius: 17px;\n\t\t}\n\n\t\t&-body {\n\t\t\tpadding: 14px 0 0 0;\n\t\t\tbackground-color: var(--color-main-background);\n\t\t\t.vc-input__input {\n\t\t\t\tbox-shadow: none;\n\t\t\t}\n\t\t}\n\n\t\t&-toggle-btn {\n\t\t\tfilter: var(--background-invert-if-dark);\n\t\t}\n\n\t\t&-saturation {\n\t\t\t&-wrap {\n\t\t\t\tborder-radius: 3px;\n\t\t\t}\n\n\t\t\t&-circle {\n\t\t\t\twidth: 20px;\n\t\t\t\theight: 20px;\n\t\t\t}\n\t\t}\n\t}\n}\n\n.slide {\n\t&-enter {\n\t\ttransform: translateX(-50%);\n\t\topacity: 0;\n\t}\n\t&-enter-to {\n\t\ttransform: translateX(0);\n\t\topacity: 1;\n\t}\n\t&-leave {\n\t\ttransform: translateX(0);\n\t\topacity: 1;\n\t}\n\t&-leave-to {\n\t\ttransform: translateX(-50%);\n\t\topacity: 0;\n\t}\n\t&-enter-active,\n\t&-leave-active {\n\t\ttransition: all 50ms ease-in-out;\n\t}\n}\n\n</style>\n"],"names":["rgbToHex","color","hex","_sfc_main","ArrowLeft","Check","vueColor","DotsHorizontal","Components_NcButton","Components_NcPopover","GenColors","palette","l10n"],"mappings":";;AAkOA,MAAAA,IAAA,SAAAC,GAAA;AACA,QAAAC,IAAAD,EAAA,SAAA,EAAA;AACA,SAAAC,EAAA,WAAA,IAAA,MAAAA,IAAAA;AACA,GAEAC,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,WAAAC,EAAA;AAAA,IACA,OAAAC,EAAA;AAAA,IACA,QAAAC,EAAA;AAAA,IACA,gBAAAC,EAAA;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,EACA;AAAA,EAEA,OAAA;AAAA;AAAA;AAAA;AAAA,IAIA,OAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,gBAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA,MAAAC,EAAA,UAAA,CAAA,EAAA,IAAA,CAAAT,MACA,MAAAD,EAAAC,EAAA,CAAA,IAAAD,EAAAC,EAAA,CAAA,IAAAD,EAAAC,EAAA,CAAA,CACA;AAAA,MACA,UAAAU,GAAA;AACA,eAAAA,EAAA,MAAA,CAAAV,MAAA,gCAAA,KAAAA,CAAA,CAAA;AAAA,MACA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AACA,WAAA;AAAA,MACA,cAAA,KAAA;AAAA,MACA,UAAA;AAAA,MACA,UAAAW,EAAA,EAAA,MAAA;AAAA,MACA,UAAAA,EAAA,EAAA,cAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA,IACA,MAAAX,GAAA;AACA,WAAA,eAAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,SAAA;AAAA,IACA,GAAAW,EAAA;AAAA;AAAA;AAAA;AAAA,IAKA,gBAAA;AAIA,WAAA,MAAA,UAAA,KAAA,YAAA,GACA,KAAA,YAAA,GAEA,KAAA,WAAA;AAAA,IACA;AAAA,IACA,cAAA;AAIA,WAAA,MAAA,OAAA,GACA,KAAA,MAAA,eAAA,EAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,aAAA;AACA,WAAA,WAAA;AAAA,IACA;AAAA,IACA,qBAAA;AACA,WAAA,WAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,UAAAX,GAAA;AACA,MAAA,OAAAA,KAAA,aACAA,IAAA,KAAA,aAAA,MAEA,KAAA,eAAAA,GAKA,KAAA,MAAA,gBAAAA,CAAA,GAKA,KAAA,MAAA,SAAAA,CAAA;AAAA,IAEA;AAAA,EACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"NcColorPicker.cjs","sources":["../../src/components/NcColorPicker/NcColorPicker.vue"],"sourcesContent":["<!--\n - @copyright Copyright (c) 2019 Marco Ambrosini <marcoambrosini@icloud.com>\n -\n - @author Marco Ambrosini <marcoambrosini@icloud.com>\n - @author Grigorii K. Shartsev <me@shgk.me>\n -\n - @license GNU AGPL version 3 or any later version\n -\n - This program is free software: you can redistribute it and/or modify\n - it under the terms of the GNU Affero General Public License as\n - published by the Free Software Foundation, either version 3 of the\n - License, or (at your option) any later version.\n -\n - This program is distributed in the hope that it will be useful,\n - but WITHOUT ANY WARRANTY; without even the implied warranty of\n - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n - GNU Affero General Public License for more details.\n -\n - You should have received a copy of the GNU Affero General Public License\n - along with this program. If not, see <http://www.gnu.org/licenses/>.\n -\n -->\n\n<docs>\n\n### General description\n\nThis component allows the user to choose a color. It consists of 2\nactual pickers:\n\n- One simple picker with a predefined palette of colors;\n- One more advanced picker that provides the full color spectrum;\n\n### Usage\n\n* Using v-model and passing in an HTML element that will be treated as a trigger:\n\n```vue\n<template>\n\t<div class=\"container0\">\n\t\t<NcColorPicker v-model=\"color\">\n\t\t\t<NcButton> Click Me </NcButton>\n\t\t</NcColorPicker>\n\t\t<NcColorPicker v-model=\"color\" :palette=\"customPalette\">\n\t\t\t<NcButton> Click Me for a custom palette </NcButton>\n\t\t</NcColorPicker>\n\t\t<div :style=\"{'background-color': color}\" class=\"color0\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tcolor: '#0082c9',\n\t\t\tcustomPalette: [\n\t\t\t\t'#E40303',\n\t\t\t\t'#FF8C00',\n\t\t\t\t'#FFED00',\n\t\t\t\t'#008026',\n\t\t\t\t'#24408E',\n\t\t\t\t'#732982',\n\t\t\t\t'#5BCEFA',\n\t\t\t\t'#F5A9B8',\n\t\t\t\t'#FFFFFF',\n\t\t\t\t'#F5A9B8',\n\t\t\t\t'#5BCEFA',\n\t\t\t],\n\t\t}\n\t}\n}\n</script>\n<style>\n.container0 {\n\tdisplay: flex;\n\tgap: 20px;\n}\n\n.color0 {\n\twidth: 100px;\n\theight: 40px;\n\tborder-radius: 6px;\n}\n</style>\n```\n\n* Using v-bind for both color and open state and emitting an event that updates the color\n\n```vue\n<template>\n\t<div class=\"container1\">\n\t\t<NcButton @click=\"open = !open\"> Click Me </NcButton>\n\t\t<NcColorPicker :value=\"color\" @input=\"updateColor\" :shown.sync=\"open\">\n\t\t\t<div :style=\"{'background-color': color}\" class=\"color1\" />\n\t\t</NcColorPicker>\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tcolor: '#0082c9',\n\t\t\topen: false\n\t\t}\n\t},\n\tmethods: {\n\t\tupdateColor(e) {\n\t\t\tthis.color = e\n\t\t}\n\t}\n}\n</script>\n<style>\n.container1 {\n\tdisplay: flex;\n}\n\n.color1 {\n\twidth: 100px;\n\theight: 40px;\n\tmargin-left: 20px;\n\tborder-radius: 6px;\n}\n</style>\n```\n\n* Using advanced fields including HEX, RGB, and HSL:\n\n```vue\n<template>\n\t<div class=\"container0\">\n\t\t<NcColorPicker v-model=\"color\"\n\t\t\t:advanced-fields=\"true\">\n\t\t\t<NcButton> Click Me </NcButton>\n\t\t</NcColorPicker>\n\t\t<div :style=\"{'background-color': color}\" class=\"color0\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tcolor: '#0082c9'\n\t\t}\n\t}\n}\n</script>\n<style>\n.container0 {\n\tdisplay: flex;\n}\n\n.color0 {\n\twidth: 100px;\n\theight: 40px;\n\tmargin-left: 20px;\n\tborder-radius: 6px;\n}\n</style>\n```\n</docs>\n\n<template>\n\t<NcPopover v-bind=\"$attrs\" v-on=\"$listeners\" @apply-hide=\"handleClose\">\n\t\t<template #trigger>\n\t\t\t<slot />\n\t\t</template>\n\t\t<div class=\"color-picker\"\n\t\t\t:class=\"{ 'color-picker--advanced-fields': advanced && advancedFields }\">\n\t\t\t<Transition name=\"slide\" mode=\"out-in\">\n\t\t\t\t<div v-if=\"!advanced\" class=\"color-picker__simple\">\n\t\t\t\t\t<label v-for=\"({ color, name }, index) in normalizedPalette\"\n\t\t\t\t\t\t:key=\"index\"\n\t\t\t\t\t\t:style=\"{ backgroundColor: color }\"\n\t\t\t\t\t\tclass=\"color-picker__simple-color-circle\"\n\t\t\t\t\t\t:class=\"{ 'color-picker__simple-color-circle--active' : color === currentColor }\">\n\t\t\t\t\t\t<Check v-if=\"color === currentColor\" :size=\"20\" />\n\t\t\t\t\t\t<input type=\"radio\"\n\t\t\t\t\t\t\tclass=\"hidden-visually\"\n\t\t\t\t\t\t\t:aria-label=\"name\"\n\t\t\t\t\t\t\t:name=\"`color-picker-${uid}`\"\n\t\t\t\t\t\t\t:checked=\"color === currentColor\"\n\t\t\t\t\t\t\t@click=\"pickColor(color)\">\n\t\t\t\t\t</label>\n\t\t\t\t</div>\n\t\t\t\t<Chrome v-if=\"advanced\"\n\t\t\t\t\tv-model=\"currentColor\"\n\t\t\t\t\tclass=\"color-picker__advanced\"\n\t\t\t\t\t:disable-alpha=\"true\"\n\t\t\t\t\t:disable-fields=\"!advancedFields\"\n\t\t\t\t\t@input=\"pickColor\" />\n\t\t\t</Transition>\n\t\t\t<div class=\"color-picker__navigation\">\n\t\t\t\t<NcButton v-if=\"advanced\"\n\t\t\t\t\ttype=\"tertiary\"\n\t\t\t\t\t:aria-label=\"ariaBack\"\n\t\t\t\t\t@click=\"handleBack\">\n\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t<ArrowLeft :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t</NcButton>\n\t\t\t\t<NcButton v-if=\"!advanced\"\n\t\t\t\t\ttype=\"tertiary\"\n\t\t\t\t\t:aria-label=\"ariaMore\"\n\t\t\t\t\t@click=\"handleMoreSettings\">\n\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t<DotsHorizontal :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t</NcButton>\n\t\t\t\t<NcButton v-if=\"advanced\"\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\t@click=\"handleConfirm\">\n\t\t\t\t\t{{ t('Choose') }}\n\t\t\t\t</NcButton>\n\t\t\t</div>\n\t\t</div>\n\t</NcPopover>\n</template>\n\n<script>\nimport NcButton from '../NcButton/index.js'\nimport NcPopover from '../NcPopover/index.js'\nimport { t } from '../../l10n.js'\nimport GenColors from '../../utils/GenColors.js'\nimport GenRandomId from '../../utils/GenRandomId.js'\n\nimport ArrowLeft from 'vue-material-design-icons/ArrowLeft.vue'\nimport Check from 'vue-material-design-icons/Check.vue'\nimport DotsHorizontal from 'vue-material-design-icons/DotsHorizontal.vue'\n\nimport { Chrome } from 'vue-color'\n\n/**\n * Convert RGB object to a HEX string color\n *\n * @param {object} color - The color to convert\n * @param {string} [color.r] - Red value\n * @param {string} [color.g] - Green value\n * @param {string} [color.b] - Blue value\n * @return {string} The hex value\n */\nexport function rgbToHex({ r, g, b }) {\n\tconst toHex = (number) => number.toString(16).padStart(2, '0')\n\treturn `#${toHex(r)}${toHex(g)}${toHex(b)}`\n}\n\nconst HEX_REGEX = /^#([a-f0-9]{3}|[a-f0-9]{6})$/i\n\nexport default {\n\tname: 'NcColorPicker',\n\n\tcomponents: {\n\t\tArrowLeft,\n\t\tCheck,\n\t\tChrome,\n\t\tDotsHorizontal,\n\t\tNcButton,\n\t\tNcPopover,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * A HEX color that represents the initial value of the picker\n\t\t */\n\t\tvalue: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/**\n\t\t * Set to `true` to enable advanced fields including HEX, RGB, and HSL\n\t\t */\n\t\tadvancedFields: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * Provide a custom array of colors to show.\n\t\t * Can be either an array of string hexadecimal colors,\n\t\t * or an array of object with a `color` property with hexadecimal color string,\n\t\t * and a `name` property for accessibility.\n\t\t *\n\t\t * @type {string[] | {color: string, name: string}[]}\n\t\t */\n\t\tpalette: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => GenColors(4).map(item => ({ color: rgbToHex(item), name: item.name })),\n\t\t\tvalidator: (palette) => palette.every(item =>\n\t\t\t\t(typeof item === 'string' && HEX_REGEX.test(item))\n\t\t\t\t|| (typeof item === 'object' && item.color && HEX_REGEX.test(item.color)),\n\t\t\t),\n\t\t},\n\t},\n\n\temits: [\n\t\t'submit',\n\t\t'close',\n\t\t'update:open',\n\t\t'update:value',\n\t\t'input',\n\t],\n\n\tdata() {\n\t\treturn {\n\t\t\tcurrentColor: this.value,\n\t\t\tadvanced: false,\n\t\t\tariaBack: t('Back'),\n\t\t\tariaMore: t('More options'),\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tnormalizedPalette() {\n\t\t\treturn this.palette.map((item) => ({\n\t\t\t\tcolor: typeof item === 'object' ? item.color : item,\n\t\t\t\tname: typeof item === 'object' && item.name\n\t\t\t\t\t? item.name\n\t\t\t\t\t: t('A color with a HEX value {hex}', { hex: item.color }),\n\t\t\t}))\n\t\t},\n\n\t\tuid() {\n\t\t\treturn GenRandomId()\n\t\t},\n\t},\n\n\twatch: {\n\t\tvalue(color) {\n\t\t\tthis.currentColor = color\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * Submit a picked colour and close picker\n\t\t */\n\t\thandleConfirm() {\n\t\t\t/**\n\t\t\t * Emits a hexadecimal string e.g. '#ffffff'\n\t\t\t */\n\t\t\tthis.$emit('submit', this.currentColor)\n\t\t\tthis.handleClose()\n\n\t\t\tthis.advanced = false\n\t\t},\n\t\thandleClose() {\n\t\t\t/**\n\t\t\t * Emitted after picker close\n\t\t\t */\n\t\t\tthis.$emit('close')\n\t\t\tthis.$emit('update:open', false)\n\t\t},\n\n\t\t/**\n\t\t * Inner navigations\n\t\t */\n\t\thandleBack() {\n\t\t\tthis.advanced = false\n\t\t},\n\t\thandleMoreSettings() {\n\t\t\tthis.advanced = true\n\t\t},\n\n\t\t/**\n\t\t * Pick a colour\n\t\t *\n\t\t * @param {string} color the picked color\n\t\t */\n\t\tpickColor(color) {\n\t\t\tif (typeof color !== 'string') {\n\t\t\t\tcolor = this.currentColor.hex\n\t\t\t}\n\t\t\tthis.currentColor = color\n\n\t\t\t/**\n\t\t\t * Emits a hexadecimal string e.g. '#ffffff'\n\t\t\t */\n\t\t\tthis.$emit('update:value', color)\n\n\t\t\t/**\n\t\t\t * Emits a hexadecimal string e.g. '#ffffff'\n\t\t\t */\n\t\t\tthis.$emit('input', color)\n\n\t\t},\n\t},\n}\n\n</script>\n\n<style lang=\"scss\" scoped>\n.color-picker {\n\tdisplay: flex;\n\toverflow: hidden;\n\talign-content: flex-end;\n\tflex-direction: column;\n\tjustify-content: space-between;\n\tbox-sizing: content-box !important;\n\twidth: 176px;\n\tpadding: 8px;\n\tborder-radius: 3px;\n\n\t&--advanced-fields {\n\t\twidth: 264px;\n\t}\n\n\t&__simple {\n\t\tdisplay: grid;\n\t\tgrid-template-columns: repeat(auto-fit, $clickable-area);\n\t\tgrid-auto-rows: $clickable-area;\n\n\t\t&-color-circle {\n\t\t\tdisplay: flex;\n\t\t\talign-items: center;\n\t\t\tjustify-content: center;\n\t\t\twidth: 34px;\n\t\t\theight: 34px;\n\t\t\tmin-height: 34px;\n\t\t\tmargin: auto;\n\t\t\tpadding: 0;\n\t\t\tcolor: white;\n\t\t\tborder: 1px solid rgba(0, 0, 0, 0.25);\n\t\t\tborder-radius: 50%;\n\t\t\tfont-size: 16px;\n\t\t\t&:focus-within {\n\t\t\t\toutline: 2px solid var(--color-main-text);\n\t\t\t}\n\t\t\t&:hover {\n\t\t\t\topacity: .6;\n\t\t\t}\n\t\t\t&--active {\n\t\t\t\twidth: 38px;\n\t\t\t\theight: 38px;\n\t\t\t\tmin-height: 38px;\n\t\t\t\ttransition: all 100ms ease-in-out;\n\t\t\t\topacity: 1 !important;\n\t\t\t}\n\t\t}\n\t}\n\n\t&__advanced {\n\t\tbox-shadow: none !important;\n\t}\n\n\t&__navigation {\n\t\tdisplay: flex;\n\t\tflex-direction: row;\n\t\tjustify-content: space-between;\n\t\tmargin-top: 10px;\n\t}\n}\n\n:deep() .vc {\n\t&-chrome {\n\t\twidth: unset;\n\t\tbackground-color: var(--color-main-background);\n\n\t\t&-color-wrap {\n\t\t\twidth: 30px;\n\t\t\theight: 30px;\n\t\t}\n\n\t\t&-active-color {\n\t\t\twidth: 34px;\n\t\t\theight: 34px;\n\t\t\tborder-radius: 17px;\n\t\t}\n\n\t\t&-body {\n\t\t\tpadding: 14px 0 0 0;\n\t\t\tbackground-color: var(--color-main-background);\n\t\t\t.vc-input__input {\n\t\t\t\tbox-shadow: none;\n\t\t\t}\n\t\t}\n\n\t\t&-toggle-btn {\n\t\t\tfilter: var(--background-invert-if-dark);\n\t\t}\n\n\t\t&-saturation {\n\t\t\t&-wrap {\n\t\t\t\tborder-radius: 3px;\n\t\t\t}\n\n\t\t\t&-circle {\n\t\t\t\twidth: 20px;\n\t\t\t\theight: 20px;\n\t\t\t}\n\t\t}\n\t}\n}\n\n.slide {\n\t&-enter {\n\t\ttransform: translateX(-50%);\n\t\topacity: 0;\n\t}\n\t&-enter-to {\n\t\ttransform: translateX(0);\n\t\topacity: 1;\n\t}\n\t&-leave {\n\t\ttransform: translateX(0);\n\t\topacity: 1;\n\t}\n\t&-leave-to {\n\t\ttransform: translateX(-50%);\n\t\topacity: 0;\n\t}\n\t&-enter-active,\n\t&-leave-active {\n\t\ttransition: all 50ms ease-in-out;\n\t}\n}\n\n</style>\n"],"names":["rgbToHex","r","g","b","toHex","number","HEX_REGEX","_sfc_main","ArrowLeft","Check","vueColor","DotsHorizontal","Components_NcButton","Components_NcPopover","GenColors","item","palette","l10n","GenRandomId","color"],"mappings":";;AAgPA,SAAAA,EAAA,EAAA,GAAAC,GAAA,GAAAC,GAAA,GAAAC,EAAA,GAAA;AACA,QAAAC,IAAA,CAAAC,MAAAA,EAAA,SAAA,EAAA,EAAA,SAAA,GAAA,GAAA;AACA,SAAA,IAAAD,EAAAH,CAAA,CAAA,GAAAG,EAAAF,CAAA,CAAA,GAAAE,EAAAD,CAAA,CAAA;AACA;AAEA,MAAAG,IAAA,iCAEAC,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,WAAAC,EAAA;AAAA,IACA,OAAAC,EAAA;AAAA,IACA,QAAAC,EAAA;AAAA,IACA,gBAAAC,EAAA;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,EACA;AAAA,EAEA,OAAA;AAAA;AAAA;AAAA;AAAA,IAIA,OAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,gBAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA,MAAAC,EAAA,UAAA,CAAA,EAAA,IAAA,CAAAC,OAAA,EAAA,OAAAf,EAAAe,CAAA,GAAA,MAAAA,EAAA,KAAA,EAAA;AAAA,MACA,WAAA,CAAAC,MAAAA,EAAA;AAAA,QAAA,CAAAD,MACA,OAAAA,KAAA,YAAAT,EAAA,KAAAS,CAAA,KACA,OAAAA,KAAA,YAAAA,EAAA,SAAAT,EAAA,KAAAS,EAAA,KAAA;AAAA,MACA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AACA,WAAA;AAAA,MACA,cAAA,KAAA;AAAA,MACA,UAAA;AAAA,MACA,UAAAE,EAAA,EAAA,MAAA;AAAA,MACA,UAAAA,EAAA,EAAA,cAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,UAAA;AAAA,IACA,oBAAA;AACA,aAAA,KAAA,QAAA,IAAA,CAAAF,OAAA;AAAA,QACA,OAAA,OAAAA,KAAA,WAAAA,EAAA,QAAAA;AAAA,QACA,MAAA,OAAAA,KAAA,YAAAA,EAAA,OACAA,EAAA,OACAE,EAAA,EAAA,kCAAA,EAAA,KAAAF,EAAA,MAAA,CAAA;AAAA,MACA,EAAA;AAAA,IACA;AAAA,IAEA,MAAA;AACA,aAAAG,EAAA,YAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA,IACA,MAAAC,GAAA;AACA,WAAA,eAAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,SAAA;AAAA,IACA,GAAAF,EAAA;AAAA;AAAA;AAAA;AAAA,IAKA,gBAAA;AAIA,WAAA,MAAA,UAAA,KAAA,YAAA,GACA,KAAA,YAAA,GAEA,KAAA,WAAA;AAAA,IACA;AAAA,IACA,cAAA;AAIA,WAAA,MAAA,OAAA,GACA,KAAA,MAAA,eAAA,EAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,aAAA;AACA,WAAA,WAAA;AAAA,IACA;AAAA,IACA,qBAAA;AACA,WAAA,WAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,UAAAE,GAAA;AACA,MAAA,OAAAA,KAAA,aACAA,IAAA,KAAA,aAAA,MAEA,KAAA,eAAAA,GAKA,KAAA,MAAA,gBAAAA,CAAA,GAKA,KAAA,MAAA,SAAAA,CAAA;AAAA,IAEA;AAAA,EACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import "../assets/index-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { t as
|
|
5
|
-
import { G as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import "../assets/index-7157aefa.css";
|
|
2
|
+
import c from "./NcButton.mjs";
|
|
3
|
+
import i from "./NcPopover.mjs";
|
|
4
|
+
import { t as a } from "../chunks/l10n-1b905a9a.mjs";
|
|
5
|
+
import { G as d } from "../chunks/GenColors-12ec1caa.mjs";
|
|
6
|
+
import { G as u } from "../chunks/GenRandomId-cb9ccebe.mjs";
|
|
7
|
+
import { A as p } from "../chunks/ArrowLeft-3779ba88.mjs";
|
|
8
|
+
import { C as f } from "../chunks/Check-2ea0a88a.mjs";
|
|
9
|
+
import { D as m } from "../chunks/DotsHorizontal-0ee7d901.mjs";
|
|
9
10
|
import { Chrome as _ } from "vue-color";
|
|
10
|
-
import { n as
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
return e
|
|
14
|
-
}
|
|
11
|
+
import { n as v } from "../chunks/_plugin-vue2_normalizer-71e2aa87.mjs";
|
|
12
|
+
function h({ r: t, g: e, b: r }) {
|
|
13
|
+
const o = (n) => n.toString(16).padStart(2, "0");
|
|
14
|
+
return `#${o(t)}${o(e)}${o(r)}`;
|
|
15
|
+
}
|
|
16
|
+
const l = /^#([a-f0-9]{3}|[a-f0-9]{6})$/i, C = {
|
|
15
17
|
name: "NcColorPicker",
|
|
16
18
|
components: {
|
|
17
|
-
ArrowLeft:
|
|
18
|
-
Check:
|
|
19
|
+
ArrowLeft: p,
|
|
20
|
+
Check: f,
|
|
19
21
|
Chrome: _,
|
|
20
|
-
DotsHorizontal:
|
|
21
|
-
NcButton:
|
|
22
|
-
NcPopover:
|
|
22
|
+
DotsHorizontal: m,
|
|
23
|
+
NcButton: c,
|
|
24
|
+
NcPopover: i
|
|
23
25
|
},
|
|
24
26
|
props: {
|
|
25
27
|
/**
|
|
@@ -37,14 +39,19 @@ const n = function(t) {
|
|
|
37
39
|
default: !1
|
|
38
40
|
},
|
|
39
41
|
/**
|
|
40
|
-
* Provide a custom array of
|
|
42
|
+
* Provide a custom array of colors to show.
|
|
43
|
+
* Can be either an array of string hexadecimal colors,
|
|
44
|
+
* or an array of object with a `color` property with hexadecimal color string,
|
|
45
|
+
* and a `name` property for accessibility.
|
|
46
|
+
*
|
|
47
|
+
* @type {string[] | {color: string, name: string}[]}
|
|
41
48
|
*/
|
|
42
49
|
palette: {
|
|
43
50
|
type: Array,
|
|
44
|
-
default: () =>
|
|
45
|
-
validator(t)
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
default: () => d(4).map((t) => ({ color: h(t), name: t.name })),
|
|
52
|
+
validator: (t) => t.every(
|
|
53
|
+
(e) => typeof e == "string" && l.test(e) || typeof e == "object" && e.color && l.test(e.color)
|
|
54
|
+
)
|
|
48
55
|
}
|
|
49
56
|
},
|
|
50
57
|
emits: [
|
|
@@ -58,17 +65,28 @@ const n = function(t) {
|
|
|
58
65
|
return {
|
|
59
66
|
currentColor: this.value,
|
|
60
67
|
advanced: !1,
|
|
61
|
-
ariaBack:
|
|
62
|
-
ariaMore:
|
|
68
|
+
ariaBack: a("Back"),
|
|
69
|
+
ariaMore: a("More options")
|
|
63
70
|
};
|
|
64
71
|
},
|
|
72
|
+
computed: {
|
|
73
|
+
normalizedPalette() {
|
|
74
|
+
return this.palette.map((t) => ({
|
|
75
|
+
color: typeof t == "object" ? t.color : t,
|
|
76
|
+
name: typeof t == "object" && t.name ? t.name : a("A color with a HEX value {hex}", { hex: t.color })
|
|
77
|
+
}));
|
|
78
|
+
},
|
|
79
|
+
uid() {
|
|
80
|
+
return u();
|
|
81
|
+
}
|
|
82
|
+
},
|
|
65
83
|
watch: {
|
|
66
84
|
value(t) {
|
|
67
85
|
this.currentColor = t;
|
|
68
86
|
}
|
|
69
87
|
},
|
|
70
88
|
methods: {
|
|
71
|
-
t:
|
|
89
|
+
t: a,
|
|
72
90
|
/**
|
|
73
91
|
* Submit a picked colour and close picker
|
|
74
92
|
*/
|
|
@@ -97,32 +115,32 @@ const n = function(t) {
|
|
|
97
115
|
}
|
|
98
116
|
}
|
|
99
117
|
};
|
|
100
|
-
var
|
|
118
|
+
var k = function() {
|
|
101
119
|
var e = this, r = e._self._c;
|
|
102
120
|
return r("NcPopover", e._g(e._b({ on: { "apply-hide": e.handleClose }, scopedSlots: e._u([{ key: "trigger", fn: function() {
|
|
103
121
|
return [e._t("default")];
|
|
104
|
-
}, proxy: !0 }], null, !0) }, "NcPopover", e.$attrs, !1), e.$listeners), [r("div", { staticClass: "color-picker", class: { "color-picker--advanced-fields": e.advanced && e.advancedFields } }, [r("
|
|
105
|
-
return r("
|
|
106
|
-
return e.pickColor(
|
|
107
|
-
} } }
|
|
108
|
-
}), 0), e.advanced ? r("Chrome", { staticClass: "color-picker__advanced", attrs: { "disable-alpha": !0, "disable-fields": !e.advancedFields }, on: { input: e.pickColor }, model: { value: e.currentColor, callback: function(
|
|
109
|
-
e.currentColor =
|
|
122
|
+
}, proxy: !0 }], null, !0) }, "NcPopover", e.$attrs, !1), e.$listeners), [r("div", { staticClass: "color-picker", class: { "color-picker--advanced-fields": e.advanced && e.advancedFields } }, [r("Transition", { attrs: { name: "slide", mode: "out-in" } }, [e.advanced ? e._e() : r("div", { staticClass: "color-picker__simple" }, e._l(e.normalizedPalette, function({ color: o, name: n }, s) {
|
|
123
|
+
return r("label", { key: s, staticClass: "color-picker__simple-color-circle", class: { "color-picker__simple-color-circle--active": o === e.currentColor }, style: { backgroundColor: o } }, [o === e.currentColor ? r("Check", { attrs: { size: 20 } }) : e._e(), r("input", { staticClass: "hidden-visually", attrs: { type: "radio", "aria-label": n, name: `color-picker-${e.uid}` }, domProps: { checked: o === e.currentColor }, on: { click: function(g) {
|
|
124
|
+
return e.pickColor(o);
|
|
125
|
+
} } })], 1);
|
|
126
|
+
}), 0), e.advanced ? r("Chrome", { staticClass: "color-picker__advanced", attrs: { "disable-alpha": !0, "disable-fields": !e.advancedFields }, on: { input: e.pickColor }, model: { value: e.currentColor, callback: function(o) {
|
|
127
|
+
e.currentColor = o;
|
|
110
128
|
}, expression: "currentColor" } }) : e._e()], 1), r("div", { staticClass: "color-picker__navigation" }, [e.advanced ? r("NcButton", { attrs: { type: "tertiary", "aria-label": e.ariaBack }, on: { click: e.handleBack }, scopedSlots: e._u([{ key: "icon", fn: function() {
|
|
111
129
|
return [r("ArrowLeft", { attrs: { size: 20 } })];
|
|
112
130
|
}, proxy: !0 }], null, !1, 1821202730) }) : e._e(), e.advanced ? e._e() : r("NcButton", { attrs: { type: "tertiary", "aria-label": e.ariaMore }, on: { click: e.handleMoreSettings }, scopedSlots: e._u([{ key: "icon", fn: function() {
|
|
113
131
|
return [r("DotsHorizontal", { attrs: { size: 20 } })];
|
|
114
132
|
}, proxy: !0 }], null, !1, 1056868794) }), e.advanced ? r("NcButton", { attrs: { type: "primary" }, on: { click: e.handleConfirm } }, [e._v(" " + e._s(e.t("Choose")) + " ")]) : e._e()], 1)], 1)]);
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
133
|
+
}, y = [], b = /* @__PURE__ */ v(
|
|
134
|
+
C,
|
|
135
|
+
k,
|
|
136
|
+
y,
|
|
119
137
|
!1,
|
|
120
138
|
null,
|
|
121
|
-
"
|
|
139
|
+
"b23899c8",
|
|
122
140
|
null,
|
|
123
141
|
null
|
|
124
142
|
);
|
|
125
|
-
const
|
|
143
|
+
const w = b.exports;
|
|
126
144
|
export {
|
|
127
|
-
|
|
145
|
+
w as default
|
|
128
146
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NcColorPicker.mjs","sources":["../../src/components/NcColorPicker/NcColorPicker.vue"],"sourcesContent":["<!--\n - @copyright Copyright (c) 2019 Marco Ambrosini <marcoambrosini@icloud.com>\n -\n - @author Marco Ambrosini <marcoambrosini@icloud.com>\n -\n - @license GNU AGPL version 3 or any later version\n -\n - This program is free software: you can redistribute it and/or modify\n - it under the terms of the GNU Affero General Public License as\n - published by the Free Software Foundation, either version 3 of the\n - License, or (at your option) any later version.\n -\n - This program is distributed in the hope that it will be useful,\n - but WITHOUT ANY WARRANTY; without even the implied warranty of\n - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n - GNU Affero General Public License for more details.\n -\n - You should have received a copy of the GNU Affero General Public License\n - along with this program. If not, see <http://www.gnu.org/licenses/>.\n -\n -->\n\n<docs>\n\n### General description\n\nThis component allows the user to choose a color. It consists of 2\nactual pickers:\n\n- One simple picker with a predefined palette of colors;\n- One more advanced picker that provides the full color spectrum;\n\n### Usage\n\n* Using v-model and passing in an HTML element that will be treated as a trigger:\n\n```vue\n<template>\n\t<div class=\"container0\">\n\t\t<NcColorPicker v-model=\"color\">\n\t\t\t<NcButton> Click Me </NcButton>\n\t\t</NcColorPicker>\n\t\t<NcColorPicker v-model=\"color\" :palette=\"customPalette\">\n\t\t\t<NcButton> Click Me for a custom palette </NcButton>\n\t\t</NcColorPicker>\n\t\t<div :style=\"{'background-color': color}\" class=\"color0\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tcolor: '#0082c9',\n\t\t\tcustomPalette: [\n\t\t\t\t'#E40303',\n\t\t\t\t'#FF8C00',\n\t\t\t\t'#FFED00',\n\t\t\t\t'#008026',\n\t\t\t\t'#24408E',\n\t\t\t\t'#732982',\n\t\t\t\t'#5BCEFA',\n\t\t\t\t'#F5A9B8',\n\t\t\t\t'#FFFFFF',\n\t\t\t\t'#F5A9B8',\n\t\t\t\t'#5BCEFA',\n\t\t\t],\n\t\t}\n\t}\n}\n</script>\n<style>\n.container0 {\n\tdisplay: flex;\n\tgap: 20px;\n}\n\n.color0 {\n\twidth: 100px;\n\theight: 40px;\n\tborder-radius: 6px;\n}\n</style>\n```\n\n* Using v-bind for both color and open state and emitting an event that updates the color\n\n```vue\n<template>\n\t<div class=\"container1\">\n\t\t<NcButton @click=\"open = !open\"> Click Me </NcButton>\n\t\t<NcColorPicker :value=\"color\" @input=\"updateColor\" :shown.sync=\"open\">\n\t\t\t<div :style=\"{'background-color': color}\" class=\"color1\" />\n\t\t</NcColorPicker>\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tcolor: '#0082c9',\n\t\t\topen: false\n\t\t}\n\t},\n\tmethods: {\n\t\tupdateColor(e) {\n\t\t\tthis.color = e\n\t\t}\n\t}\n}\n</script>\n<style>\n.container1 {\n\tdisplay: flex;\n}\n\n.color1 {\n\twidth: 100px;\n\theight: 40px;\n\tmargin-left: 20px;\n\tborder-radius: 6px;\n}\n</style>\n```\n\n* Using advanced fields including HEX, RGB, and HSL:\n\n```vue\n<template>\n\t<div class=\"container0\">\n\t\t<NcColorPicker v-model=\"color\"\n\t\t\t:advanced-fields=\"true\">\n\t\t\t<NcButton> Click Me </NcButton>\n\t\t</NcColorPicker>\n\t\t<div :style=\"{'background-color': color}\" class=\"color0\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tcolor: '#0082c9'\n\t\t}\n\t}\n}\n</script>\n<style>\n.container0 {\n\tdisplay: flex;\n}\n\n.color0 {\n\twidth: 100px;\n\theight: 40px;\n\tmargin-left: 20px;\n\tborder-radius: 6px;\n}\n</style>\n```\n</docs>\n\n<template>\n\t<NcPopover v-bind=\"$attrs\" v-on=\"$listeners\" @apply-hide=\"handleClose\">\n\t\t<template #trigger>\n\t\t\t<slot />\n\t\t</template>\n\t\t<div class=\"color-picker\"\n\t\t\t:class=\"{ 'color-picker--advanced-fields': advanced && advancedFields }\">\n\t\t\t<transition name=\"slide\" mode=\"out-in\">\n\t\t\t\t<div v-if=\"!advanced\" class=\"color-picker__simple\">\n\t\t\t\t\t<button v-for=\"(color, index) in palette\"\n\t\t\t\t\t\t:key=\"index\"\n\t\t\t\t\t\t:style=\"{'background-color': color }\"\n\t\t\t\t\t\tclass=\"color-picker__simple-color-circle\"\n\t\t\t\t\t\t:class=\"{ 'color-picker__simple-color-circle--active' : color === currentColor }\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t@click=\"pickColor(color)\">\n\t\t\t\t\t\t<Check v-if=\"color === currentColor\"\n\t\t\t\t\t\t\t:size=\"20\" />\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<Chrome v-if=\"advanced\"\n\t\t\t\t\tv-model=\"currentColor\"\n\t\t\t\t\tclass=\"color-picker__advanced\"\n\t\t\t\t\t:disable-alpha=\"true\"\n\t\t\t\t\t:disable-fields=\"!advancedFields\"\n\t\t\t\t\t@input=\"pickColor\" />\n\t\t\t</transition>\n\t\t\t<div class=\"color-picker__navigation\">\n\t\t\t\t<NcButton v-if=\"advanced\"\n\t\t\t\t\ttype=\"tertiary\"\n\t\t\t\t\t:aria-label=\"ariaBack\"\n\t\t\t\t\t@click=\"handleBack\">\n\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t<ArrowLeft :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t</NcButton>\n\t\t\t\t<NcButton v-if=\"!advanced\"\n\t\t\t\t\ttype=\"tertiary\"\n\t\t\t\t\t:aria-label=\"ariaMore\"\n\t\t\t\t\t@click=\"handleMoreSettings\">\n\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t<DotsHorizontal :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t</NcButton>\n\t\t\t\t<NcButton v-if=\"advanced\"\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\t@click=\"handleConfirm\">\n\t\t\t\t\t{{ t('Choose') }}\n\t\t\t\t</NcButton>\n\t\t\t</div>\n\t\t</div>\n\t</NcPopover>\n</template>\n\n<script>\nimport NcButton from '../NcButton/index.js'\nimport NcPopover from '../NcPopover/index.js'\nimport { t } from '../../l10n.js'\nimport GenColors from '../../utils/GenColors.js'\n\nimport ArrowLeft from 'vue-material-design-icons/ArrowLeft.vue'\nimport Check from 'vue-material-design-icons/Check.vue'\nimport DotsHorizontal from 'vue-material-design-icons/DotsHorizontal.vue'\n\nimport { Chrome } from 'vue-color'\n\nconst rgbToHex = function(color) {\n\tconst hex = color.toString(16)\n\treturn hex.length === 1 ? '0' + hex : hex\n}\n\nexport default {\n\tname: 'NcColorPicker',\n\n\tcomponents: {\n\t\tArrowLeft,\n\t\tCheck,\n\t\tChrome,\n\t\tDotsHorizontal,\n\t\tNcButton,\n\t\tNcPopover,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * A HEX color that represents the initial value of the picker\n\t\t */\n\t\tvalue: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/**\n\t\t * Set to `true` to enable advanced fields including HEX, RGB, and HSL\n\t\t */\n\t\tadvancedFields: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * Provide a custom array of hexadecimal colors to show\n\t\t */\n\t\tpalette: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => GenColors(4).map(color => {\n\t\t\t\treturn '#' + rgbToHex(color.r) + rgbToHex(color.g) + rgbToHex(color.b)\n\t\t\t}),\n\t\t\tvalidator(palette) {\n\t\t\t\treturn palette.every(color => /^#([a-f0-9]{3}|[a-f0-9]{6})$/i.test(color))\n\t\t\t},\n\t\t},\n\t},\n\n\temits: [\n\t\t'submit',\n\t\t'close',\n\t\t'update:open',\n\t\t'update:value',\n\t\t'input',\n\t],\n\n\tdata() {\n\t\treturn {\n\t\t\tcurrentColor: this.value,\n\t\t\tadvanced: false,\n\t\t\tariaBack: t('Back'),\n\t\t\tariaMore: t('More options'),\n\t\t}\n\t},\n\n\twatch: {\n\t\tvalue(color) {\n\t\t\tthis.currentColor = color\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * Submit a picked colour and close picker\n\t\t */\n\t\thandleConfirm() {\n\t\t\t/**\n\t\t\t * Emits a hexadecimal string e.g. '#ffffff'\n\t\t\t */\n\t\t\tthis.$emit('submit', this.currentColor)\n\t\t\tthis.handleClose()\n\n\t\t\tthis.advanced = false\n\t\t},\n\t\thandleClose() {\n\t\t\t/**\n\t\t\t * Emitted after picker close\n\t\t\t */\n\t\t\tthis.$emit('close')\n\t\t\tthis.$emit('update:open', false)\n\t\t},\n\n\t\t/**\n\t\t * Inner navigations\n\t\t */\n\t\thandleBack() {\n\t\t\tthis.advanced = false\n\t\t},\n\t\thandleMoreSettings() {\n\t\t\tthis.advanced = true\n\t\t},\n\n\t\t/**\n\t\t * Pick a colour\n\t\t *\n\t\t * @param {string} color the picked color\n\t\t */\n\t\tpickColor(color) {\n\t\t\tif (typeof color !== 'string') {\n\t\t\t\tcolor = this.currentColor.hex\n\t\t\t}\n\t\t\tthis.currentColor = color\n\n\t\t\t/**\n\t\t\t * Emits a hexadecimal string e.g. '#ffffff'\n\t\t\t */\n\t\t\tthis.$emit('update:value', color)\n\n\t\t\t/**\n\t\t\t * Emits a hexadecimal string e.g. '#ffffff'\n\t\t\t */\n\t\t\tthis.$emit('input', color)\n\n\t\t},\n\t},\n}\n\n</script>\n\n<style lang=\"scss\" scoped>\n.color-picker {\n\tdisplay: flex;\n\toverflow: hidden;\n\talign-content: flex-end;\n\tflex-direction: column;\n\tjustify-content: space-between;\n\tbox-sizing: content-box !important;\n\twidth: 176px;\n\tpadding: 8px;\n\tborder-radius: 3px;\n\n\t&--advanced-fields {\n\t\twidth: 264px;\n\t}\n\n\t&__simple {\n\t\tdisplay: grid;\n\t\tgrid-template-columns: repeat(auto-fit, $clickable-area);\n\t\tgrid-auto-rows: $clickable-area;\n\n\t\t&-color-circle {\n\t\t\tdisplay: flex;\n\t\t\talign-items: center;\n\t\t\tjustify-content: center;\n\t\t\twidth: 34px;\n\t\t\theight: 34px;\n\t\t\tmin-height: 34px;\n\t\t\tmargin: auto;\n\t\t\tpadding: 0;\n\t\t\tcolor: white;\n\t\t\tborder: 1px solid rgba(0, 0, 0, 0.25);\n\t\t\tborder-radius: 50%;\n\t\t\tfont-size: 16px;\n\t\t\t&:hover {\n\t\t\t\topacity: .6;\n\t\t\t}\n\t\t\t&--active {\n\t\t\t\twidth: 38px;\n\t\t\t\theight: 38px;\n\t\t\t\tmin-height: 38px;\n\t\t\t\ttransition: all 100ms ease-in-out;\n\t\t\t\topacity: 1 !important;\n\t\t\t}\n\t\t}\n\t}\n\n\t&__advanced {\n\t\tbox-shadow: none !important;\n\t}\n\n\t&__navigation {\n\t\tdisplay: flex;\n\t\tflex-direction: row;\n\t\tjustify-content: space-between;\n\t\tmargin-top: 10px;\n\t}\n}\n\n:deep() .vc {\n\t&-chrome {\n\t\twidth: unset;\n\t\tbackground-color: var(--color-main-background);\n\n\t\t&-color-wrap {\n\t\t\twidth: 30px;\n\t\t\theight: 30px;\n\t\t}\n\n\t\t&-active-color {\n\t\t\twidth: 34px;\n\t\t\theight: 34px;\n\t\t\tborder-radius: 17px;\n\t\t}\n\n\t\t&-body {\n\t\t\tpadding: 14px 0 0 0;\n\t\t\tbackground-color: var(--color-main-background);\n\t\t\t.vc-input__input {\n\t\t\t\tbox-shadow: none;\n\t\t\t}\n\t\t}\n\n\t\t&-toggle-btn {\n\t\t\tfilter: var(--background-invert-if-dark);\n\t\t}\n\n\t\t&-saturation {\n\t\t\t&-wrap {\n\t\t\t\tborder-radius: 3px;\n\t\t\t}\n\n\t\t\t&-circle {\n\t\t\t\twidth: 20px;\n\t\t\t\theight: 20px;\n\t\t\t}\n\t\t}\n\t}\n}\n\n.slide {\n\t&-enter {\n\t\ttransform: translateX(-50%);\n\t\topacity: 0;\n\t}\n\t&-enter-to {\n\t\ttransform: translateX(0);\n\t\topacity: 1;\n\t}\n\t&-leave {\n\t\ttransform: translateX(0);\n\t\topacity: 1;\n\t}\n\t&-leave-to {\n\t\ttransform: translateX(-50%);\n\t\topacity: 0;\n\t}\n\t&-enter-active,\n\t&-leave-active {\n\t\ttransition: all 50ms ease-in-out;\n\t}\n}\n\n</style>\n"],"names":["rgbToHex","color","hex","_sfc_main","ArrowLeft","Check","Chrome","DotsHorizontal","NcButton","NcPopover","GenColors","palette","t"],"mappings":";;;;;;;;;;AAkOA,MAAAA,IAAA,SAAAC,GAAA;AACA,QAAAC,IAAAD,EAAA,SAAA,EAAA;AACA,SAAAC,EAAA,WAAA,IAAA,MAAAA,IAAAA;AACA,GAEAC,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,EACA;AAAA,EAEA,OAAA;AAAA;AAAA;AAAA;AAAA,IAIA,OAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,gBAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA,MAAAC,EAAA,CAAA,EAAA,IAAA,CAAAT,MACA,MAAAD,EAAAC,EAAA,CAAA,IAAAD,EAAAC,EAAA,CAAA,IAAAD,EAAAC,EAAA,CAAA,CACA;AAAA,MACA,UAAAU,GAAA;AACA,eAAAA,EAAA,MAAA,CAAAV,MAAA,gCAAA,KAAAA,CAAA,CAAA;AAAA,MACA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AACA,WAAA;AAAA,MACA,cAAA,KAAA;AAAA,MACA,UAAA;AAAA,MACA,UAAAW,EAAA,MAAA;AAAA,MACA,UAAAA,EAAA,cAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA,IACA,MAAAX,GAAA;AACA,WAAA,eAAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,SAAA;AAAA,IACA,GAAAW;AAAA;AAAA;AAAA;AAAA,IAKA,gBAAA;AAIA,WAAA,MAAA,UAAA,KAAA,YAAA,GACA,KAAA,YAAA,GAEA,KAAA,WAAA;AAAA,IACA;AAAA,IACA,cAAA;AAIA,WAAA,MAAA,OAAA,GACA,KAAA,MAAA,eAAA,EAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,aAAA;AACA,WAAA,WAAA;AAAA,IACA;AAAA,IACA,qBAAA;AACA,WAAA,WAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,UAAAX,GAAA;AACA,MAAA,OAAAA,KAAA,aACAA,IAAA,KAAA,aAAA,MAEA,KAAA,eAAAA,GAKA,KAAA,MAAA,gBAAAA,CAAA,GAKA,KAAA,MAAA,SAAAA,CAAA;AAAA,IAEA;AAAA,EACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"NcColorPicker.mjs","sources":["../../src/components/NcColorPicker/NcColorPicker.vue"],"sourcesContent":["<!--\n - @copyright Copyright (c) 2019 Marco Ambrosini <marcoambrosini@icloud.com>\n -\n - @author Marco Ambrosini <marcoambrosini@icloud.com>\n - @author Grigorii K. Shartsev <me@shgk.me>\n -\n - @license GNU AGPL version 3 or any later version\n -\n - This program is free software: you can redistribute it and/or modify\n - it under the terms of the GNU Affero General Public License as\n - published by the Free Software Foundation, either version 3 of the\n - License, or (at your option) any later version.\n -\n - This program is distributed in the hope that it will be useful,\n - but WITHOUT ANY WARRANTY; without even the implied warranty of\n - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n - GNU Affero General Public License for more details.\n -\n - You should have received a copy of the GNU Affero General Public License\n - along with this program. If not, see <http://www.gnu.org/licenses/>.\n -\n -->\n\n<docs>\n\n### General description\n\nThis component allows the user to choose a color. It consists of 2\nactual pickers:\n\n- One simple picker with a predefined palette of colors;\n- One more advanced picker that provides the full color spectrum;\n\n### Usage\n\n* Using v-model and passing in an HTML element that will be treated as a trigger:\n\n```vue\n<template>\n\t<div class=\"container0\">\n\t\t<NcColorPicker v-model=\"color\">\n\t\t\t<NcButton> Click Me </NcButton>\n\t\t</NcColorPicker>\n\t\t<NcColorPicker v-model=\"color\" :palette=\"customPalette\">\n\t\t\t<NcButton> Click Me for a custom palette </NcButton>\n\t\t</NcColorPicker>\n\t\t<div :style=\"{'background-color': color}\" class=\"color0\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tcolor: '#0082c9',\n\t\t\tcustomPalette: [\n\t\t\t\t'#E40303',\n\t\t\t\t'#FF8C00',\n\t\t\t\t'#FFED00',\n\t\t\t\t'#008026',\n\t\t\t\t'#24408E',\n\t\t\t\t'#732982',\n\t\t\t\t'#5BCEFA',\n\t\t\t\t'#F5A9B8',\n\t\t\t\t'#FFFFFF',\n\t\t\t\t'#F5A9B8',\n\t\t\t\t'#5BCEFA',\n\t\t\t],\n\t\t}\n\t}\n}\n</script>\n<style>\n.container0 {\n\tdisplay: flex;\n\tgap: 20px;\n}\n\n.color0 {\n\twidth: 100px;\n\theight: 40px;\n\tborder-radius: 6px;\n}\n</style>\n```\n\n* Using v-bind for both color and open state and emitting an event that updates the color\n\n```vue\n<template>\n\t<div class=\"container1\">\n\t\t<NcButton @click=\"open = !open\"> Click Me </NcButton>\n\t\t<NcColorPicker :value=\"color\" @input=\"updateColor\" :shown.sync=\"open\">\n\t\t\t<div :style=\"{'background-color': color}\" class=\"color1\" />\n\t\t</NcColorPicker>\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tcolor: '#0082c9',\n\t\t\topen: false\n\t\t}\n\t},\n\tmethods: {\n\t\tupdateColor(e) {\n\t\t\tthis.color = e\n\t\t}\n\t}\n}\n</script>\n<style>\n.container1 {\n\tdisplay: flex;\n}\n\n.color1 {\n\twidth: 100px;\n\theight: 40px;\n\tmargin-left: 20px;\n\tborder-radius: 6px;\n}\n</style>\n```\n\n* Using advanced fields including HEX, RGB, and HSL:\n\n```vue\n<template>\n\t<div class=\"container0\">\n\t\t<NcColorPicker v-model=\"color\"\n\t\t\t:advanced-fields=\"true\">\n\t\t\t<NcButton> Click Me </NcButton>\n\t\t</NcColorPicker>\n\t\t<div :style=\"{'background-color': color}\" class=\"color0\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tcolor: '#0082c9'\n\t\t}\n\t}\n}\n</script>\n<style>\n.container0 {\n\tdisplay: flex;\n}\n\n.color0 {\n\twidth: 100px;\n\theight: 40px;\n\tmargin-left: 20px;\n\tborder-radius: 6px;\n}\n</style>\n```\n</docs>\n\n<template>\n\t<NcPopover v-bind=\"$attrs\" v-on=\"$listeners\" @apply-hide=\"handleClose\">\n\t\t<template #trigger>\n\t\t\t<slot />\n\t\t</template>\n\t\t<div class=\"color-picker\"\n\t\t\t:class=\"{ 'color-picker--advanced-fields': advanced && advancedFields }\">\n\t\t\t<Transition name=\"slide\" mode=\"out-in\">\n\t\t\t\t<div v-if=\"!advanced\" class=\"color-picker__simple\">\n\t\t\t\t\t<label v-for=\"({ color, name }, index) in normalizedPalette\"\n\t\t\t\t\t\t:key=\"index\"\n\t\t\t\t\t\t:style=\"{ backgroundColor: color }\"\n\t\t\t\t\t\tclass=\"color-picker__simple-color-circle\"\n\t\t\t\t\t\t:class=\"{ 'color-picker__simple-color-circle--active' : color === currentColor }\">\n\t\t\t\t\t\t<Check v-if=\"color === currentColor\" :size=\"20\" />\n\t\t\t\t\t\t<input type=\"radio\"\n\t\t\t\t\t\t\tclass=\"hidden-visually\"\n\t\t\t\t\t\t\t:aria-label=\"name\"\n\t\t\t\t\t\t\t:name=\"`color-picker-${uid}`\"\n\t\t\t\t\t\t\t:checked=\"color === currentColor\"\n\t\t\t\t\t\t\t@click=\"pickColor(color)\">\n\t\t\t\t\t</label>\n\t\t\t\t</div>\n\t\t\t\t<Chrome v-if=\"advanced\"\n\t\t\t\t\tv-model=\"currentColor\"\n\t\t\t\t\tclass=\"color-picker__advanced\"\n\t\t\t\t\t:disable-alpha=\"true\"\n\t\t\t\t\t:disable-fields=\"!advancedFields\"\n\t\t\t\t\t@input=\"pickColor\" />\n\t\t\t</Transition>\n\t\t\t<div class=\"color-picker__navigation\">\n\t\t\t\t<NcButton v-if=\"advanced\"\n\t\t\t\t\ttype=\"tertiary\"\n\t\t\t\t\t:aria-label=\"ariaBack\"\n\t\t\t\t\t@click=\"handleBack\">\n\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t<ArrowLeft :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t</NcButton>\n\t\t\t\t<NcButton v-if=\"!advanced\"\n\t\t\t\t\ttype=\"tertiary\"\n\t\t\t\t\t:aria-label=\"ariaMore\"\n\t\t\t\t\t@click=\"handleMoreSettings\">\n\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t<DotsHorizontal :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t</NcButton>\n\t\t\t\t<NcButton v-if=\"advanced\"\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\t@click=\"handleConfirm\">\n\t\t\t\t\t{{ t('Choose') }}\n\t\t\t\t</NcButton>\n\t\t\t</div>\n\t\t</div>\n\t</NcPopover>\n</template>\n\n<script>\nimport NcButton from '../NcButton/index.js'\nimport NcPopover from '../NcPopover/index.js'\nimport { t } from '../../l10n.js'\nimport GenColors from '../../utils/GenColors.js'\nimport GenRandomId from '../../utils/GenRandomId.js'\n\nimport ArrowLeft from 'vue-material-design-icons/ArrowLeft.vue'\nimport Check from 'vue-material-design-icons/Check.vue'\nimport DotsHorizontal from 'vue-material-design-icons/DotsHorizontal.vue'\n\nimport { Chrome } from 'vue-color'\n\n/**\n * Convert RGB object to a HEX string color\n *\n * @param {object} color - The color to convert\n * @param {string} [color.r] - Red value\n * @param {string} [color.g] - Green value\n * @param {string} [color.b] - Blue value\n * @return {string} The hex value\n */\nexport function rgbToHex({ r, g, b }) {\n\tconst toHex = (number) => number.toString(16).padStart(2, '0')\n\treturn `#${toHex(r)}${toHex(g)}${toHex(b)}`\n}\n\nconst HEX_REGEX = /^#([a-f0-9]{3}|[a-f0-9]{6})$/i\n\nexport default {\n\tname: 'NcColorPicker',\n\n\tcomponents: {\n\t\tArrowLeft,\n\t\tCheck,\n\t\tChrome,\n\t\tDotsHorizontal,\n\t\tNcButton,\n\t\tNcPopover,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * A HEX color that represents the initial value of the picker\n\t\t */\n\t\tvalue: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/**\n\t\t * Set to `true` to enable advanced fields including HEX, RGB, and HSL\n\t\t */\n\t\tadvancedFields: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * Provide a custom array of colors to show.\n\t\t * Can be either an array of string hexadecimal colors,\n\t\t * or an array of object with a `color` property with hexadecimal color string,\n\t\t * and a `name` property for accessibility.\n\t\t *\n\t\t * @type {string[] | {color: string, name: string}[]}\n\t\t */\n\t\tpalette: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => GenColors(4).map(item => ({ color: rgbToHex(item), name: item.name })),\n\t\t\tvalidator: (palette) => palette.every(item =>\n\t\t\t\t(typeof item === 'string' && HEX_REGEX.test(item))\n\t\t\t\t|| (typeof item === 'object' && item.color && HEX_REGEX.test(item.color)),\n\t\t\t),\n\t\t},\n\t},\n\n\temits: [\n\t\t'submit',\n\t\t'close',\n\t\t'update:open',\n\t\t'update:value',\n\t\t'input',\n\t],\n\n\tdata() {\n\t\treturn {\n\t\t\tcurrentColor: this.value,\n\t\t\tadvanced: false,\n\t\t\tariaBack: t('Back'),\n\t\t\tariaMore: t('More options'),\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tnormalizedPalette() {\n\t\t\treturn this.palette.map((item) => ({\n\t\t\t\tcolor: typeof item === 'object' ? item.color : item,\n\t\t\t\tname: typeof item === 'object' && item.name\n\t\t\t\t\t? item.name\n\t\t\t\t\t: t('A color with a HEX value {hex}', { hex: item.color }),\n\t\t\t}))\n\t\t},\n\n\t\tuid() {\n\t\t\treturn GenRandomId()\n\t\t},\n\t},\n\n\twatch: {\n\t\tvalue(color) {\n\t\t\tthis.currentColor = color\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * Submit a picked colour and close picker\n\t\t */\n\t\thandleConfirm() {\n\t\t\t/**\n\t\t\t * Emits a hexadecimal string e.g. '#ffffff'\n\t\t\t */\n\t\t\tthis.$emit('submit', this.currentColor)\n\t\t\tthis.handleClose()\n\n\t\t\tthis.advanced = false\n\t\t},\n\t\thandleClose() {\n\t\t\t/**\n\t\t\t * Emitted after picker close\n\t\t\t */\n\t\t\tthis.$emit('close')\n\t\t\tthis.$emit('update:open', false)\n\t\t},\n\n\t\t/**\n\t\t * Inner navigations\n\t\t */\n\t\thandleBack() {\n\t\t\tthis.advanced = false\n\t\t},\n\t\thandleMoreSettings() {\n\t\t\tthis.advanced = true\n\t\t},\n\n\t\t/**\n\t\t * Pick a colour\n\t\t *\n\t\t * @param {string} color the picked color\n\t\t */\n\t\tpickColor(color) {\n\t\t\tif (typeof color !== 'string') {\n\t\t\t\tcolor = this.currentColor.hex\n\t\t\t}\n\t\t\tthis.currentColor = color\n\n\t\t\t/**\n\t\t\t * Emits a hexadecimal string e.g. '#ffffff'\n\t\t\t */\n\t\t\tthis.$emit('update:value', color)\n\n\t\t\t/**\n\t\t\t * Emits a hexadecimal string e.g. '#ffffff'\n\t\t\t */\n\t\t\tthis.$emit('input', color)\n\n\t\t},\n\t},\n}\n\n</script>\n\n<style lang=\"scss\" scoped>\n.color-picker {\n\tdisplay: flex;\n\toverflow: hidden;\n\talign-content: flex-end;\n\tflex-direction: column;\n\tjustify-content: space-between;\n\tbox-sizing: content-box !important;\n\twidth: 176px;\n\tpadding: 8px;\n\tborder-radius: 3px;\n\n\t&--advanced-fields {\n\t\twidth: 264px;\n\t}\n\n\t&__simple {\n\t\tdisplay: grid;\n\t\tgrid-template-columns: repeat(auto-fit, $clickable-area);\n\t\tgrid-auto-rows: $clickable-area;\n\n\t\t&-color-circle {\n\t\t\tdisplay: flex;\n\t\t\talign-items: center;\n\t\t\tjustify-content: center;\n\t\t\twidth: 34px;\n\t\t\theight: 34px;\n\t\t\tmin-height: 34px;\n\t\t\tmargin: auto;\n\t\t\tpadding: 0;\n\t\t\tcolor: white;\n\t\t\tborder: 1px solid rgba(0, 0, 0, 0.25);\n\t\t\tborder-radius: 50%;\n\t\t\tfont-size: 16px;\n\t\t\t&:focus-within {\n\t\t\t\toutline: 2px solid var(--color-main-text);\n\t\t\t}\n\t\t\t&:hover {\n\t\t\t\topacity: .6;\n\t\t\t}\n\t\t\t&--active {\n\t\t\t\twidth: 38px;\n\t\t\t\theight: 38px;\n\t\t\t\tmin-height: 38px;\n\t\t\t\ttransition: all 100ms ease-in-out;\n\t\t\t\topacity: 1 !important;\n\t\t\t}\n\t\t}\n\t}\n\n\t&__advanced {\n\t\tbox-shadow: none !important;\n\t}\n\n\t&__navigation {\n\t\tdisplay: flex;\n\t\tflex-direction: row;\n\t\tjustify-content: space-between;\n\t\tmargin-top: 10px;\n\t}\n}\n\n:deep() .vc {\n\t&-chrome {\n\t\twidth: unset;\n\t\tbackground-color: var(--color-main-background);\n\n\t\t&-color-wrap {\n\t\t\twidth: 30px;\n\t\t\theight: 30px;\n\t\t}\n\n\t\t&-active-color {\n\t\t\twidth: 34px;\n\t\t\theight: 34px;\n\t\t\tborder-radius: 17px;\n\t\t}\n\n\t\t&-body {\n\t\t\tpadding: 14px 0 0 0;\n\t\t\tbackground-color: var(--color-main-background);\n\t\t\t.vc-input__input {\n\t\t\t\tbox-shadow: none;\n\t\t\t}\n\t\t}\n\n\t\t&-toggle-btn {\n\t\t\tfilter: var(--background-invert-if-dark);\n\t\t}\n\n\t\t&-saturation {\n\t\t\t&-wrap {\n\t\t\t\tborder-radius: 3px;\n\t\t\t}\n\n\t\t\t&-circle {\n\t\t\t\twidth: 20px;\n\t\t\t\theight: 20px;\n\t\t\t}\n\t\t}\n\t}\n}\n\n.slide {\n\t&-enter {\n\t\ttransform: translateX(-50%);\n\t\topacity: 0;\n\t}\n\t&-enter-to {\n\t\ttransform: translateX(0);\n\t\topacity: 1;\n\t}\n\t&-leave {\n\t\ttransform: translateX(0);\n\t\topacity: 1;\n\t}\n\t&-leave-to {\n\t\ttransform: translateX(-50%);\n\t\topacity: 0;\n\t}\n\t&-enter-active,\n\t&-leave-active {\n\t\ttransition: all 50ms ease-in-out;\n\t}\n}\n\n</style>\n"],"names":["rgbToHex","r","g","b","toHex","number","HEX_REGEX","_sfc_main","ArrowLeft","Check","Chrome","DotsHorizontal","NcButton","NcPopover","GenColors","item","palette","t","GenRandomId","color"],"mappings":";;;;;;;;;;;AAgPA,SAAAA,EAAA,EAAA,GAAAC,GAAA,GAAAC,GAAA,GAAAC,EAAA,GAAA;AACA,QAAAC,IAAA,CAAAC,MAAAA,EAAA,SAAA,EAAA,EAAA,SAAA,GAAA,GAAA;AACA,SAAA,IAAAD,EAAAH,CAAA,CAAA,GAAAG,EAAAF,CAAA,CAAA,GAAAE,EAAAD,CAAA,CAAA;AACA;AAEA,MAAAG,IAAA,iCAEAC,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,EACA;AAAA,EAEA,OAAA;AAAA;AAAA;AAAA;AAAA,IAIA,OAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,gBAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA,MAAAC,EAAA,CAAA,EAAA,IAAA,CAAAC,OAAA,EAAA,OAAAf,EAAAe,CAAA,GAAA,MAAAA,EAAA,KAAA,EAAA;AAAA,MACA,WAAA,CAAAC,MAAAA,EAAA;AAAA,QAAA,CAAAD,MACA,OAAAA,KAAA,YAAAT,EAAA,KAAAS,CAAA,KACA,OAAAA,KAAA,YAAAA,EAAA,SAAAT,EAAA,KAAAS,EAAA,KAAA;AAAA,MACA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AACA,WAAA;AAAA,MACA,cAAA,KAAA;AAAA,MACA,UAAA;AAAA,MACA,UAAAE,EAAA,MAAA;AAAA,MACA,UAAAA,EAAA,cAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,UAAA;AAAA,IACA,oBAAA;AACA,aAAA,KAAA,QAAA,IAAA,CAAAF,OAAA;AAAA,QACA,OAAA,OAAAA,KAAA,WAAAA,EAAA,QAAAA;AAAA,QACA,MAAA,OAAAA,KAAA,YAAAA,EAAA,OACAA,EAAA,OACAE,EAAA,kCAAA,EAAA,KAAAF,EAAA,MAAA,CAAA;AAAA,MACA,EAAA;AAAA,IACA;AAAA,IAEA,MAAA;AACA,aAAAG,EAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA,IACA,MAAAC,GAAA;AACA,WAAA,eAAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,SAAA;AAAA,IACA,GAAAF;AAAA;AAAA;AAAA;AAAA,IAKA,gBAAA;AAIA,WAAA,MAAA,UAAA,KAAA,YAAA,GACA,KAAA,YAAA,GAEA,KAAA,WAAA;AAAA,IACA;AAAA,IACA,cAAA;AAIA,WAAA,MAAA,OAAA,GACA,KAAA,MAAA,eAAA,EAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,aAAA;AACA,WAAA,WAAA;AAAA,IACA;AAAA,IACA,qBAAA;AACA,WAAA,WAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,UAAAE,GAAA;AACA,MAAA,OAAAA,KAAA,aACAA,IAAA,KAAA,aAAA,MAEA,KAAA,eAAAA,GAKA,KAAA,MAAA,gBAAAA,CAAA,GAKA,KAAA,MAAA,SAAAA,CAAA;AAAA,IAEA;AAAA,EACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var p = require("../assets/index-6416f636.css");
|
|
2
|
-
const r = require("../chunks/index-
|
|
2
|
+
const r = require("../chunks/index-32c8b581.cjs"), o = require("./NcDashboardWidgetItem.cjs"), a = require("./NcEmptyContent.cjs"), i = require("../chunks/Check-be8cd6af.cjs"), m = require("../chunks/l10n-070da9ad.cjs"), l = require("../chunks/_plugin-vue2_normalizer-7f9efb60.cjs");
|
|
3
3
|
const c = {
|
|
4
4
|
name: "NcDashboardWidget",
|
|
5
5
|
components: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "../assets/index-6416f636.css";
|
|
2
|
-
import { N as r } from "../chunks/index-
|
|
2
|
+
import { N as r } from "../chunks/index-efb07851.mjs";
|
|
3
3
|
import o from "./NcDashboardWidgetItem.mjs";
|
|
4
4
|
import a from "./NcEmptyContent.mjs";
|
|
5
5
|
import { C as i } from "../chunks/Check-2ea0a88a.mjs";
|
|
6
|
-
import { t as m } from "../chunks/l10n-
|
|
6
|
+
import { t as m } from "../chunks/l10n-1b905a9a.mjs";
|
|
7
7
|
import { n as l } from "../chunks/_plugin-vue2_normalizer-71e2aa87.mjs";
|
|
8
8
|
const c = {
|
|
9
9
|
name: "NcDashboardWidget",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var f = require("../assets/index-e7eadba7.css");
|
|
2
|
-
const i = require("../chunks/index-
|
|
2
|
+
const i = require("../chunks/index-32c8b581.cjs"), o = require("./NcActions.cjs"), c = require("./NcActionButton.cjs"), l = require("../chunks/_plugin-vue2_normalizer-7f9efb60.cjs");
|
|
3
3
|
const u = {
|
|
4
4
|
name: "NcDashboardWidgetItem",
|
|
5
5
|
components: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../assets/index-e7eadba7.css";
|
|
2
|
-
import { N as i } from "../chunks/index-
|
|
2
|
+
import { N as i } from "../chunks/index-efb07851.mjs";
|
|
3
3
|
import o from "./NcActions.mjs";
|
|
4
4
|
import l from "./NcActionButton.mjs";
|
|
5
5
|
import { n as u } from "../chunks/_plugin-vue2_normalizer-71e2aa87.mjs";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const l = require("@nextcloud/l10n"),
|
|
3
|
-
long:
|
|
4
|
-
short:
|
|
2
|
+
const l = require("@nextcloud/l10n"), o = require("../chunks/l10n-070da9ad.cjs"), d = require("../chunks/_plugin-vue2_normalizer-7f9efb60.cjs"), u = {
|
|
3
|
+
long: o.t("a few seconds ago"),
|
|
4
|
+
short: o.t("seconds ago"),
|
|
5
5
|
// FOR TRANSLATORS: Shorter version of 'a few seconds ago'
|
|
6
|
-
narrow:
|
|
6
|
+
narrow: o.t("sec. ago")
|
|
7
7
|
// FOR TRANSLATORS: If possible in your language an even shorter version of 'a few seconds ago'
|
|
8
|
-
},
|
|
8
|
+
}, c = {
|
|
9
9
|
name: "NcDateTime",
|
|
10
10
|
props: {
|
|
11
11
|
/**
|
|
@@ -63,18 +63,21 @@ const l = require("@nextcloud/l10n"), s = require("../chunks/l10n-c3dbf018.cjs")
|
|
|
63
63
|
if (this.relativeTime !== !1) {
|
|
64
64
|
const t = new Intl.RelativeTimeFormat(l.getCanonicalLocale(), { numeric: "auto", style: this.relativeTime }), r = (this.dateObject - new Date(this.currentTime)) / 1e3;
|
|
65
65
|
if (Math.abs(r) <= 90)
|
|
66
|
-
return this.ignoreSeconds ?
|
|
66
|
+
return this.ignoreSeconds ? u[this.relativeTime] : t.format(Math.round(r), "second");
|
|
67
67
|
const n = r / 60;
|
|
68
68
|
if (Math.abs(n) <= 90)
|
|
69
69
|
return t.format(Math.round(n), "minute");
|
|
70
70
|
const i = n / 60;
|
|
71
|
-
if (Math.abs(i) <=
|
|
71
|
+
if (Math.abs(i) <= 24)
|
|
72
72
|
return t.format(Math.round(i), "hour");
|
|
73
73
|
const a = i / 24;
|
|
74
74
|
if (Math.abs(a) <= 6)
|
|
75
75
|
return t.format(Math.round(a), "day");
|
|
76
|
-
const
|
|
77
|
-
|
|
76
|
+
const s = a / 7;
|
|
77
|
+
if (Math.abs(s) <= 4)
|
|
78
|
+
return t.format(Math.round(s), "week");
|
|
79
|
+
const m = a / 30;
|
|
80
|
+
return Math.abs(m) <= 12 ? t.format(Math.round(m), "month") : t.format(Math.round(a / 365), "year");
|
|
78
81
|
}
|
|
79
82
|
return this.formattedFullTime;
|
|
80
83
|
},
|
|
@@ -108,18 +111,18 @@ const l = require("@nextcloud/l10n"), s = require("../chunks/l10n-c3dbf018.cjs")
|
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
};
|
|
111
|
-
var
|
|
114
|
+
var f = function() {
|
|
112
115
|
var e = this, r = e._self._c;
|
|
113
116
|
return r("span", { staticClass: "nc-datetime", attrs: { "data-timestamp": e.timestamp, title: e.formattedFullTime } }, [e._v(e._s(e.formattedTime))]);
|
|
114
|
-
},
|
|
115
|
-
u,
|
|
117
|
+
}, h = [], v = /* @__PURE__ */ d.normalizeComponent(
|
|
116
118
|
c,
|
|
117
119
|
f,
|
|
120
|
+
h,
|
|
118
121
|
!1,
|
|
119
122
|
null,
|
|
120
123
|
null,
|
|
121
124
|
null,
|
|
122
125
|
null
|
|
123
126
|
);
|
|
124
|
-
const
|
|
125
|
-
module.exports =
|
|
127
|
+
const T = v.exports;
|
|
128
|
+
module.exports = T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NcDateTime.cjs","sources":["../../src/components/NcDateTime/NcDateTime.vue"],"sourcesContent":["<!--\n - @copyright Copyright (c) 2023 Ferdinand Thiessen <opensource@fthiessen.de>\n -\n - @author Ferdinand Thiessen <opensource@fthiessen.de>\n -\n - @license AGPL-3.0-or-later\n -\n - This program is free software: you can redistribute it and/or modify\n - it under the terms of the GNU Affero General Public License as\n - published by the Free Software Foundation, either version 3 of the\n - License, or (at your option) any later version.\n -\n - This program is distributed in the hope that it will be useful,\n - but WITHOUT ANY WARRANTY; without even the implied warranty of\n - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n - GNU Affero General Public License for more details.\n -\n - You should have received a copy of the GNU Affero General Public License\n - along with this program. If not, see <http://www.gnu.org/licenses/>.\n -\n -->\n\n<docs>\n\n### General description\n\nThis components purpose is to display a timestamp in the users local time format.\nIt also supports relative time, for examples *6 seconds ago*.\n\n#### Standard usage\n\nWithout any optional parameters the timestamp is displayed as a relative datetime and a title with the full date is added.\n\n```vue\n<template>\n\t<NcDateTime :timestamp=\"timestamp\" />\n</template>\n<script>\n\texport default {\n\t\tdata() {\n\t\t\treturn {\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t}\n\t\t},\n\t}\n</script>\n```\n\n#### Ignore seconds\n\nIf you do not want the seconds to be counted up until minutes are reached you can simply use the `ignore-seconds` property.\n\n```vue\n<template>\n\t<NcDateTime :timestamp=\"timestamp\" :ignore-seconds=\"true\" />\n</template>\n<script>\n\texport default {\n\t\tdata() {\n\t\t\treturn {\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t}\n\t\t},\n\t}\n</script>\n```\n\n#### Custom date or time format\n\nThe component allows to format the full date for the title by settings the `format` property.\nIt is also possible to disable relative time by setting the `relativeTime` property to `false`.\n\n```vue\n<template>\n\t<div>\n\t\t<h4>Short relative time</h4>\n\t\t<NcDateTime :timestamp=\"timestamp\" relative-time=\"short\" />\n\n\t\t<h4>Custom title format</h4>\n\t\t<NcDateTime :timestamp=\"timestamp\" :format=\"timeFormat\" />\n\n\t\t<h4>Without relative time</h4>\n\t\t<NcDateTime :timestamp=\"timestamp\" :format=\"timeFormat\" :relative-time=\"false\" />\n\t</div>\n</template>\n<script>\n\texport default {\n\t\tdata() {\n\t\t\treturn {\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t/** For allowed formats see the Intl.DateTimeFormat options */\n\t\t\t\ttimeFormat: {\n\t\t\t\t\tdateStyle: 'short',\n\t\t\t\t\ttimeStyle: 'full'\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t}\n</script>\n<style>\nh4 {\n\tfont-weight: bold;\n\tmargin-top: 12px;\n}\n</style>\n```\n</docs>\n\n<template>\n\t<span class=\"nc-datetime\"\n\t\t:data-timestamp=\"timestamp\"\n\t\t:title=\"formattedFullTime\">{{ formattedTime }}</span>\n</template>\n\n<script>\nimport { getCanonicalLocale } from '@nextcloud/l10n'\nimport { t } from '../../l10n.js'\n\nconst FEW_SECONDS_AGO = {\n\tlong: t('a few seconds ago'),\n\tshort: t('seconds ago'), // FOR TRANSLATORS: Shorter version of 'a few seconds ago'\n\tnarrow: t('sec. ago'), // FOR TRANSLATORS: If possible in your language an even shorter version of 'a few seconds ago'\n}\n\nexport default {\n\tname: 'NcDateTime',\n\n\tprops: {\n\t\t/**\n\t\t * The timestamp to display, either an unix timestamp (in milliseconds) or a Date object\n\t\t */\n\t\ttimestamp: {\n\t\t\ttype: [Date, Number],\n\t\t\trequired: true,\n\t\t},\n\t\t/**\n\t\t * The format used for displaying, or if relative time is used the format used for the title (optional)\n\t\t *\n\t\t * @type {Intl.DateTimeFormatOptions}\n\t\t */\n\t\tformat: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({ timeStyle: 'medium', dateStyle: 'short' }),\n\t\t},\n\t\t/**\n\t\t * Wether to display the timestamp as time from now (optional)\n\t\t *\n\t\t * - `false`: Disable relative time\n\t\t * - `'long'`: Long text, like *2 seconds ago* (default)\n\t\t * - `'short'`: Short text, like *2 sec. ago*\n\t\t * - `'narrow'`: Even shorter text (same as `'short'` on some languages)\n\t\t */\n\t\trelativeTime: {\n\t\t\ttype: [Boolean, String],\n\t\t\tdefault: 'long',\n\t\t\tvalidator: (v) => v === false || ['long', 'short', 'narrow'].includes(v),\n\t\t},\n\t\t/**\n\t\t * Ignore seconds when displaying the relative time and just show `a few seconds ago`\n\t\t */\n\t\tignoreSeconds: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\t/** Current time in ms */\n\t\t\tcurrentTime: Date.now(),\n\t\t\t/** ID of the current time interval */\n\t\t\tintervalId: undefined,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** ECMA Date object of the timestamp */\n\t\tdateObject() {\n\t\t\treturn new Date(this.timestamp)\n\t\t},\n\t\t/** Time string formatted for main text */\n\t\tformattedTime() {\n\t\t\tif (this.relativeTime !== false) {\n\t\t\t\tconst formatter = new Intl.RelativeTimeFormat(getCanonicalLocale(), { numeric: 'auto', style: this.relativeTime })\n\n\t\t\t\tconst diff = this.dateObject - new Date(this.currentTime)\n\t\t\t\tconst seconds = diff / 1000\n\t\t\t\tif (Math.abs(seconds) <= 90) {\n\t\t\t\t\tif (this.ignoreSeconds) {\n\t\t\t\t\t\treturn FEW_SECONDS_AGO[this.relativeTime]\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn formatter.format(Math.round(seconds), 'second')\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst minutes = seconds / 60\n\t\t\t\tif (Math.abs(minutes) <= 90) {\n\t\t\t\t\treturn formatter.format(Math.round(minutes), 'minute')\n\t\t\t\t}\n\t\t\t\tconst hours = minutes / 60\n\t\t\t\tif (Math.abs(hours) <=
|
|
1
|
+
{"version":3,"file":"NcDateTime.cjs","sources":["../../src/components/NcDateTime/NcDateTime.vue"],"sourcesContent":["<!--\n - @copyright Copyright (c) 2023 Ferdinand Thiessen <opensource@fthiessen.de>\n -\n - @author Ferdinand Thiessen <opensource@fthiessen.de>\n -\n - @license AGPL-3.0-or-later\n -\n - This program is free software: you can redistribute it and/or modify\n - it under the terms of the GNU Affero General Public License as\n - published by the Free Software Foundation, either version 3 of the\n - License, or (at your option) any later version.\n -\n - This program is distributed in the hope that it will be useful,\n - but WITHOUT ANY WARRANTY; without even the implied warranty of\n - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n - GNU Affero General Public License for more details.\n -\n - You should have received a copy of the GNU Affero General Public License\n - along with this program. If not, see <http://www.gnu.org/licenses/>.\n -\n -->\n\n<docs>\n\n### General description\n\nThis components purpose is to display a timestamp in the users local time format.\nIt also supports relative time, for examples *6 seconds ago*.\n\n#### Standard usage\n\nWithout any optional parameters the timestamp is displayed as a relative datetime and a title with the full date is added.\n\n```vue\n<template>\n\t<NcDateTime :timestamp=\"timestamp\" />\n</template>\n<script>\n\texport default {\n\t\tdata() {\n\t\t\treturn {\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t}\n\t\t},\n\t}\n</script>\n```\n\n#### Ignore seconds\n\nIf you do not want the seconds to be counted up until minutes are reached you can simply use the `ignore-seconds` property.\n\n```vue\n<template>\n\t<NcDateTime :timestamp=\"timestamp\" :ignore-seconds=\"true\" />\n</template>\n<script>\n\texport default {\n\t\tdata() {\n\t\t\treturn {\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t}\n\t\t},\n\t}\n</script>\n```\n\n#### Custom date or time format\n\nThe component allows to format the full date for the title by settings the `format` property.\nIt is also possible to disable relative time by setting the `relativeTime` property to `false`.\n\n```vue\n<template>\n\t<div>\n\t\t<h4>Short relative time</h4>\n\t\t<NcDateTime :timestamp=\"timestamp\" relative-time=\"short\" />\n\n\t\t<h4>Custom title format</h4>\n\t\t<NcDateTime :timestamp=\"timestamp\" :format=\"timeFormat\" />\n\n\t\t<h4>Without relative time</h4>\n\t\t<NcDateTime :timestamp=\"timestamp\" :format=\"timeFormat\" :relative-time=\"false\" />\n\t</div>\n</template>\n<script>\n\texport default {\n\t\tdata() {\n\t\t\treturn {\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t/** For allowed formats see the Intl.DateTimeFormat options */\n\t\t\t\ttimeFormat: {\n\t\t\t\t\tdateStyle: 'short',\n\t\t\t\t\ttimeStyle: 'full'\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t}\n</script>\n<style>\nh4 {\n\tfont-weight: bold;\n\tmargin-top: 12px;\n}\n</style>\n```\n</docs>\n\n<template>\n\t<span class=\"nc-datetime\"\n\t\t:data-timestamp=\"timestamp\"\n\t\t:title=\"formattedFullTime\">{{ formattedTime }}</span>\n</template>\n\n<script>\nimport { getCanonicalLocale } from '@nextcloud/l10n'\nimport { t } from '../../l10n.js'\n\nconst FEW_SECONDS_AGO = {\n\tlong: t('a few seconds ago'),\n\tshort: t('seconds ago'), // FOR TRANSLATORS: Shorter version of 'a few seconds ago'\n\tnarrow: t('sec. ago'), // FOR TRANSLATORS: If possible in your language an even shorter version of 'a few seconds ago'\n}\n\nexport default {\n\tname: 'NcDateTime',\n\n\tprops: {\n\t\t/**\n\t\t * The timestamp to display, either an unix timestamp (in milliseconds) or a Date object\n\t\t */\n\t\ttimestamp: {\n\t\t\ttype: [Date, Number],\n\t\t\trequired: true,\n\t\t},\n\t\t/**\n\t\t * The format used for displaying, or if relative time is used the format used for the title (optional)\n\t\t *\n\t\t * @type {Intl.DateTimeFormatOptions}\n\t\t */\n\t\tformat: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({ timeStyle: 'medium', dateStyle: 'short' }),\n\t\t},\n\t\t/**\n\t\t * Wether to display the timestamp as time from now (optional)\n\t\t *\n\t\t * - `false`: Disable relative time\n\t\t * - `'long'`: Long text, like *2 seconds ago* (default)\n\t\t * - `'short'`: Short text, like *2 sec. ago*\n\t\t * - `'narrow'`: Even shorter text (same as `'short'` on some languages)\n\t\t */\n\t\trelativeTime: {\n\t\t\ttype: [Boolean, String],\n\t\t\tdefault: 'long',\n\t\t\tvalidator: (v) => v === false || ['long', 'short', 'narrow'].includes(v),\n\t\t},\n\t\t/**\n\t\t * Ignore seconds when displaying the relative time and just show `a few seconds ago`\n\t\t */\n\t\tignoreSeconds: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\t/** Current time in ms */\n\t\t\tcurrentTime: Date.now(),\n\t\t\t/** ID of the current time interval */\n\t\t\tintervalId: undefined,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** ECMA Date object of the timestamp */\n\t\tdateObject() {\n\t\t\treturn new Date(this.timestamp)\n\t\t},\n\t\t/** Time string formatted for main text */\n\t\tformattedTime() {\n\t\t\tif (this.relativeTime !== false) {\n\t\t\t\tconst formatter = new Intl.RelativeTimeFormat(getCanonicalLocale(), { numeric: 'auto', style: this.relativeTime })\n\n\t\t\t\tconst diff = this.dateObject - new Date(this.currentTime)\n\t\t\t\tconst seconds = diff / 1000\n\t\t\t\tif (Math.abs(seconds) <= 90) {\n\t\t\t\t\tif (this.ignoreSeconds) {\n\t\t\t\t\t\treturn FEW_SECONDS_AGO[this.relativeTime]\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn formatter.format(Math.round(seconds), 'second')\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst minutes = seconds / 60\n\t\t\t\tif (Math.abs(minutes) <= 90) {\n\t\t\t\t\treturn formatter.format(Math.round(minutes), 'minute')\n\t\t\t\t}\n\t\t\t\tconst hours = minutes / 60\n\t\t\t\tif (Math.abs(hours) <= 24) {\n\t\t\t\t\treturn formatter.format(Math.round(hours), 'hour')\n\t\t\t\t}\n\t\t\t\tconst days = hours / 24\n\t\t\t\tif (Math.abs(days) <= 6) {\n\t\t\t\t\treturn formatter.format(Math.round(days), 'day')\n\t\t\t\t}\n\t\t\t\tconst weeks = days / 7\n\t\t\t\tif (Math.abs(weeks) <= 4) {\n\t\t\t\t\treturn formatter.format(Math.round(weeks), 'week')\n\t\t\t\t}\n\t\t\t\tconst months = days / 30\n\t\t\t\tif (Math.abs(months) <= 12) {\n\t\t\t\t\treturn formatter.format(Math.round(months), 'month')\n\t\t\t\t}\n\t\t\t\treturn formatter.format(Math.round(days / 365), 'year')\n\t\t\t}\n\t\t\treturn this.formattedFullTime\n\t\t},\n\t\tformattedFullTime() {\n\t\t\tconst formatter = new Intl.DateTimeFormat(getCanonicalLocale(), this.format)\n\t\t\treturn formatter.format(this.dateObject)\n\t\t},\n\t},\n\n\twatch: {\n\t\t/**\n\t\t * Set or clear interval if relative time is dis/enabled\n\t\t *\n\t\t * @param {boolean} newValue The new value of the relativeTime property\n\t\t * @param {boolean} _oldValue The old value of the relativeTime property\n\t\t */\n\t\trelativeTime(newValue, _oldValue) {\n\t\t\twindow.clearInterval(this.intervalId)\n\t\t\tthis.intervalId = undefined\n\t\t\tif (newValue) {\n\t\t\t\tthis.intervalId = window.setInterval(this.setCurrentTime, 1000)\n\t\t\t}\n\t\t},\n\t},\n\n\tmounted() {\n\t\t// Start the interval for setting the current time if relative time is enabled\n\t\tif (this.relativeTime !== false) {\n\t\t\tthis.intervalId = window.setInterval(this.setCurrentTime, 1000)\n\t\t}\n\t},\n\n\tdestroyed() {\n\t\t// ensure interval is cleared\n\t\twindow.clearInterval(this.intervalId)\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Set `currentTime` to the current timestamp, required as Date.now() is not reactive.\n\t\t */\n\t\tsetCurrentTime() {\n\t\t\tthis.currentTime = Date.now()\n\t\t},\n\t},\n}\n</script>\n"],"names":["FEW_SECONDS_AGO","t","_sfc_main","v","formatter","getCanonicalLocale","seconds","minutes","hours","days","weeks","months","newValue","_oldValue"],"mappings":";iJAsHAA,IAAA;AAAA,EACA,MAAAC,EAAA,EAAA,mBAAA;AAAA,EACA,OAAAA,EAAA,EAAA,aAAA;AAAA;AAAA,EACA,QAAAA,EAAA,EAAA,UAAA;AAAA;AACA,GAEAC,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,OAAA;AAAA;AAAA;AAAA;AAAA,IAIA,WAAA;AAAA,MACA,MAAA,CAAA,MAAA,MAAA;AAAA,MACA,UAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,QAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA,OAAA,EAAA,WAAA,UAAA,WAAA,QAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,cAAA;AAAA,MACA,MAAA,CAAA,SAAA,MAAA;AAAA,MACA,SAAA;AAAA,MACA,WAAA,CAAAC,MAAAA,MAAA,MAAA,CAAA,QAAA,SAAA,QAAA,EAAA,SAAAA,CAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAIA,eAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AACA,WAAA;AAAA;AAAA,MAEA,aAAA,KAAA,IAAA;AAAA;AAAA,MAEA,YAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,UAAA;AAAA;AAAA,IAEA,aAAA;AACA,aAAA,IAAA,KAAA,KAAA,SAAA;AAAA,IACA;AAAA;AAAA,IAEA,gBAAA;AACA,UAAA,KAAA,iBAAA,IAAA;AACA,cAAAC,IAAA,IAAA,KAAA,mBAAAC,EAAAA,mBAAA,GAAA,EAAA,SAAA,QAAA,OAAA,KAAA,aAAA,CAAA,GAGAC,KADA,KAAA,aAAA,IAAA,KAAA,KAAA,WAAA,KACA;AACA,YAAA,KAAA,IAAAA,CAAA,KAAA;AACA,iBAAA,KAAA,gBACAN,EAAA,KAAA,YAAA,IAEAI,EAAA,OAAA,KAAA,MAAAE,CAAA,GAAA,QAAA;AAGA,cAAAC,IAAAD,IAAA;AACA,YAAA,KAAA,IAAAC,CAAA,KAAA;AACA,iBAAAH,EAAA,OAAA,KAAA,MAAAG,CAAA,GAAA,QAAA;AAEA,cAAAC,IAAAD,IAAA;AACA,YAAA,KAAA,IAAAC,CAAA,KAAA;AACA,iBAAAJ,EAAA,OAAA,KAAA,MAAAI,CAAA,GAAA,MAAA;AAEA,cAAAC,IAAAD,IAAA;AACA,YAAA,KAAA,IAAAC,CAAA,KAAA;AACA,iBAAAL,EAAA,OAAA,KAAA,MAAAK,CAAA,GAAA,KAAA;AAEA,cAAAC,IAAAD,IAAA;AACA,YAAA,KAAA,IAAAC,CAAA,KAAA;AACA,iBAAAN,EAAA,OAAA,KAAA,MAAAM,CAAA,GAAA,MAAA;AAEA,cAAAC,IAAAF,IAAA;AACA,eAAA,KAAA,IAAAE,CAAA,KAAA,KACAP,EAAA,OAAA,KAAA,MAAAO,CAAA,GAAA,OAAA,IAEAP,EAAA,OAAA,KAAA,MAAAK,IAAA,GAAA,GAAA,MAAA;AAAA,MACA;AACA,aAAA,KAAA;AAAA,IACA;AAAA,IACA,oBAAA;AAEA,aADA,IAAA,KAAA,eAAAJ,EAAAA,mBAAA,GAAA,KAAA,MAAA,EACA,OAAA,KAAA,UAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,aAAAO,GAAAC,GAAA;AACA,aAAA,cAAA,KAAA,UAAA,GACA,KAAA,aAAA,QACAD,MACA,KAAA,aAAA,OAAA,YAAA,KAAA,gBAAA,GAAA;AAAA,IAEA;AAAA,EACA;AAAA,EAEA,UAAA;AAEA,IAAA,KAAA,iBAAA,OACA,KAAA,aAAA,OAAA,YAAA,KAAA,gBAAA,GAAA;AAAA,EAEA;AAAA,EAEA,YAAA;AAEA,WAAA,cAAA,KAAA,UAAA;AAAA,EACA;AAAA,EAEA,SAAA;AAAA;AAAA;AAAA;AAAA,IAIA,iBAAA;AACA,WAAA,cAAA,KAAA,IAAA;AAAA,IACA;AAAA,EACA;AACA;;;;;;;;;;;;;;;;"}
|