@nextcloud/vue 8.0.0-beta.8 → 8.0.0-beta.9
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 +25 -0
- package/dist/Components/NcActionButton.cjs +8 -8
- package/dist/Components/NcActionButton.cjs.map +1 -1
- package/dist/Components/NcActionButton.mjs +10 -10
- package/dist/Components/NcActionButton.mjs.map +1 -1
- package/dist/Components/NcActionInput.cjs +23 -18
- package/dist/Components/NcActionInput.cjs.map +1 -1
- package/dist/Components/NcActionInput.mjs +20 -14
- package/dist/Components/NcActionInput.mjs.map +1 -1
- package/dist/Components/NcActionLink.cjs +7 -7
- package/dist/Components/NcActionLink.cjs.map +1 -1
- package/dist/Components/NcActionLink.mjs +4 -4
- package/dist/Components/NcActionLink.mjs.map +1 -1
- package/dist/Components/NcActionRouter.cjs +8 -8
- package/dist/Components/NcActionRouter.cjs.map +1 -1
- package/dist/Components/NcActionRouter.mjs +4 -4
- package/dist/Components/NcActionRouter.mjs.map +1 -1
- package/dist/Components/NcActionText.cjs +10 -10
- package/dist/Components/NcActionText.cjs.map +1 -1
- package/dist/Components/NcActionText.mjs +11 -11
- 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 +67 -63
- package/dist/Components/NcActions.cjs.map +1 -1
- package/dist/Components/NcActions.mjs +75 -71
- 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 +1 -1
- package/dist/Components/NcAppNavigation.mjs +1 -1
- package/dist/Components/NcAppNavigationItem.cjs +12 -12
- package/dist/Components/NcAppNavigationItem.cjs.map +1 -1
- package/dist/Components/NcAppNavigationItem.mjs +15 -15
- 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 +57 -108
- package/dist/Components/NcAppSettingsDialog.cjs.map +1 -1
- package/dist/Components/NcAppSettingsDialog.mjs +59 -110
- package/dist/Components/NcAppSettingsDialog.mjs.map +1 -1
- package/dist/Components/NcAppSidebar.cjs +5 -5
- package/dist/Components/NcAppSidebar.cjs.map +1 -1
- package/dist/Components/NcAppSidebar.mjs +5 -5
- package/dist/Components/NcAppSidebar.mjs.map +1 -1
- package/dist/Components/NcAppSidebarTab.cjs +3 -3
- package/dist/Components/NcAppSidebarTab.cjs.map +1 -1
- package/dist/Components/NcAppSidebarTab.mjs +5 -5
- package/dist/Components/NcAppSidebarTab.mjs.map +1 -1
- package/dist/Components/NcAvatar.cjs +1 -1
- package/dist/Components/NcAvatar.mjs +1 -1
- package/dist/Components/NcBreadcrumbs.cjs +2 -2
- package/dist/Components/NcBreadcrumbs.cjs.map +1 -1
- package/dist/Components/NcBreadcrumbs.mjs +2 -2
- package/dist/Components/NcBreadcrumbs.mjs.map +1 -1
- package/dist/Components/NcCheckboxRadioSwitch.cjs +157 -42
- package/dist/Components/NcCheckboxRadioSwitch.cjs.map +1 -1
- package/dist/Components/NcCheckboxRadioSwitch.mjs +168 -53
- package/dist/Components/NcCheckboxRadioSwitch.mjs.map +1 -1
- package/dist/Components/NcColorPicker.cjs +1 -1
- package/dist/Components/NcColorPicker.mjs +1 -1
- package/dist/Components/NcDashboardWidget.cjs +1 -1
- package/dist/Components/NcDashboardWidget.mjs +2 -2
- package/dist/Components/NcDashboardWidgetItem.cjs +11 -11
- package/dist/Components/NcDashboardWidgetItem.cjs.map +1 -1
- package/dist/Components/NcDashboardWidgetItem.mjs +9 -9
- package/dist/Components/NcDashboardWidgetItem.mjs.map +1 -1
- package/dist/Components/NcDateTime.cjs +1 -1
- package/dist/Components/NcDateTime.mjs +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 +171 -0
- package/dist/Components/NcDialog.cjs.map +1 -0
- package/dist/Components/NcDialog.mjs +177 -0
- package/dist/Components/NcDialog.mjs.map +1 -0
- package/dist/Components/NcDialogButton.cjs +69 -0
- package/dist/Components/NcDialogButton.cjs.map +1 -0
- package/dist/Components/NcDialogButton.mjs +74 -0
- package/dist/Components/NcDialogButton.mjs.map +1 -0
- package/dist/Components/NcEmojiPicker.cjs +1 -1
- package/dist/Components/NcEmojiPicker.mjs +1 -1
- package/dist/Components/NcIconSvgWrapper.cjs +29 -14
- package/dist/Components/NcIconSvgWrapper.cjs.map +1 -1
- package/dist/Components/NcIconSvgWrapper.mjs +32 -17
- package/dist/Components/NcIconSvgWrapper.mjs.map +1 -1
- package/dist/Components/NcListItem.cjs +3 -3
- package/dist/Components/NcListItem.cjs.map +1 -1
- package/dist/Components/NcListItem.mjs +3 -3
- package/dist/Components/NcListItem.mjs.map +1 -1
- package/dist/Components/NcListItemIcon.cjs +20 -12
- package/dist/Components/NcListItemIcon.cjs.map +1 -1
- package/dist/Components/NcListItemIcon.mjs +21 -13
- package/dist/Components/NcListItemIcon.mjs.map +1 -1
- package/dist/Components/NcModal.cjs +24 -26
- package/dist/Components/NcModal.cjs.map +1 -1
- package/dist/Components/NcModal.mjs +54 -56
- package/dist/Components/NcModal.mjs.map +1 -1
- package/dist/Components/NcNoteCard.cjs +4 -4
- package/dist/Components/NcNoteCard.cjs.map +1 -1
- package/dist/Components/NcNoteCard.mjs +3 -3
- package/dist/Components/NcNoteCard.mjs.map +1 -1
- package/dist/Components/NcPasswordField.cjs +49 -38
- package/dist/Components/NcPasswordField.cjs.map +1 -1
- package/dist/Components/NcPasswordField.mjs +59 -48
- package/dist/Components/NcPasswordField.mjs.map +1 -1
- package/dist/Components/NcRelatedResourcesPanel.cjs +29 -13
- package/dist/Components/NcRelatedResourcesPanel.cjs.map +1 -1
- package/dist/Components/NcRelatedResourcesPanel.mjs +41 -25
- package/dist/Components/NcRelatedResourcesPanel.mjs.map +1 -1
- package/dist/Components/NcRichContenteditable.cjs +2 -2
- package/dist/Components/NcRichContenteditable.mjs +2 -2
- package/dist/Components/NcRichText.cjs +1 -1
- package/dist/Components/NcRichText.mjs +3 -3
- package/dist/Components/NcSelect.cjs +34 -29
- package/dist/Components/NcSelect.cjs.map +1 -1
- package/dist/Components/NcSelect.mjs +48 -43
- package/dist/Components/NcSelect.mjs.map +1 -1
- 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 +167 -0
- package/dist/Components/NcTextArea.cjs.map +1 -0
- package/dist/Components/NcTextArea.mjs +172 -0
- package/dist/Components/NcTextArea.mjs.map +1 -0
- package/dist/Components/NcTextField.cjs +37 -13
- package/dist/Components/NcTextField.cjs.map +1 -1
- package/dist/Components/NcTextField.mjs +45 -21
- package/dist/Components/NcTextField.mjs.map +1 -1
- package/dist/Components/NcTimezonePicker.cjs +1 -1
- package/dist/Components/NcTimezonePicker.mjs +1 -1
- package/dist/Components/NcUserBubble.cjs +4 -4
- package/dist/Components/NcUserBubble.cjs.map +1 -1
- package/dist/Components/NcUserBubble.mjs +4 -4
- package/dist/Components/NcUserBubble.mjs.map +1 -1
- package/dist/assets/index-236620b0.css +150 -0
- package/dist/assets/{index-03ec5f40.css → index-400b48a6.css} +7 -7
- package/dist/assets/{index-33da80f0.css → index-4611417f.css} +8 -9
- package/dist/assets/{index-01e5adf4.css → index-4b75fe20.css} +11 -11
- package/dist/assets/{index-294382c8.css → index-574438d6.css} +43 -38
- package/dist/assets/{index-c7905a53.css → index-57b305d3.css} +3 -3
- package/dist/assets/{index-de0326c7.css → index-5ee8a575.css} +69 -78
- package/dist/assets/{index-9354264c.css → index-6f721577.css} +16 -16
- package/dist/assets/{index-fec4bb7b.css → index-73867d38.css} +17 -16
- package/dist/assets/{index-becfbea7.css → index-8304db49.css} +23 -22
- package/dist/assets/{index-5eff69c7.css → index-9dcf6260.css} +32 -30
- package/dist/assets/{index-23e64bbb.css → index-9e44e336.css} +9 -9
- package/dist/assets/{index-0557f12a.css → index-9e9587e1.css} +4 -4
- package/dist/assets/index-abb90c97.css +164 -0
- package/dist/assets/{index-5072b6ee.css → index-af72a30b.css} +11 -10
- package/dist/assets/{index-194e9415.css → index-c06ad941.css} +70 -58
- package/dist/assets/{index-fbdeb5ab.css → index-c5ae3bc4.css} +11 -11
- package/dist/assets/index-dc612aa3.css +112 -0
- package/dist/assets/{index-376d2dec.css → index-e7c55791.css} +67 -67
- package/dist/assets/{index-165fce0e.css → index-e7eadba7.css} +13 -13
- package/dist/assets/{index-6405cd50.css → index-e828b286.css} +4 -4
- package/dist/assets/{index-0ab8e182.css → index-eea65531.css} +23 -22
- package/dist/assets/{index-1cf8eeb4.css → index-f85aa003.css} +13 -32
- package/dist/assets/{referencePickerModal-0acecb5e.css → referencePickerModal-3a127978.css} +55 -55
- package/dist/chunks/{NcAppNavigationToggle-960658a0.cjs → NcAppNavigationToggle-841d3015.cjs} +1 -1
- package/dist/chunks/{NcAppNavigationToggle-960658a0.cjs.map → NcAppNavigationToggle-841d3015.cjs.map} +1 -1
- package/dist/chunks/{NcAppNavigationToggle-d868f651.mjs → NcAppNavigationToggle-e358aa47.mjs} +1 -1
- package/dist/chunks/{NcAppNavigationToggle-d868f651.mjs.map → NcAppNavigationToggle-e358aa47.mjs.map} +1 -1
- package/dist/chunks/{NcInputConfirmCancel-f881168d.mjs → NcInputConfirmCancel-44052477.mjs} +16 -9
- package/dist/chunks/NcInputConfirmCancel-44052477.mjs.map +1 -0
- package/dist/chunks/{NcInputConfirmCancel-0c4bee9a.cjs → NcInputConfirmCancel-6bea0fdc.cjs} +11 -4
- package/dist/chunks/NcInputConfirmCancel-6bea0fdc.cjs.map +1 -0
- package/dist/chunks/{NcRichText-d385dc10.cjs → NcRichText-332fe454.cjs} +2 -2
- package/dist/chunks/{NcRichText-1c3d2654.mjs.map → NcRichText-332fe454.cjs.map} +1 -1
- package/dist/chunks/{NcRichText-1c3d2654.mjs → NcRichText-8fda53c8.mjs} +9 -9
- package/dist/chunks/{NcRichText-d385dc10.cjs.map → NcRichText-8fda53c8.mjs.map} +1 -1
- package/dist/chunks/{NcSettingsSelectGroup-47d9c113.cjs → NcSettingsSelectGroup-a5ff8c36.cjs} +1 -1
- package/dist/chunks/{NcSettingsSelectGroup-47d9c113.cjs.map → NcSettingsSelectGroup-a5ff8c36.cjs.map} +1 -1
- package/dist/chunks/{NcSettingsSelectGroup-0f4a0f94.mjs → NcSettingsSelectGroup-fdd3309c.mjs} +2 -2
- package/dist/chunks/{NcSettingsSelectGroup-0f4a0f94.mjs.map → NcSettingsSelectGroup-fdd3309c.mjs.map} +1 -1
- package/dist/chunks/{ScopeComponent-97a014a1.mjs → ScopeComponent-9519afcc.mjs} +1 -1
- package/dist/chunks/{ScopeComponent-97a014a1.mjs.map → ScopeComponent-9519afcc.mjs.map} +1 -1
- package/dist/chunks/{ScopeComponent-1c75ec38.cjs → ScopeComponent-e060526a.cjs} +1 -1
- package/dist/chunks/{ScopeComponent-1c75ec38.cjs.map → ScopeComponent-e060526a.cjs.map} +1 -1
- package/dist/chunks/{actionText-b0bd6eb7.cjs → actionText-54bc24a6.cjs} +1 -1
- package/dist/chunks/{actionText-9f5c55bd.mjs.map → actionText-54bc24a6.cjs.map} +1 -1
- package/dist/chunks/{actionText-9f5c55bd.mjs → actionText-a64be267.mjs} +1 -1
- package/dist/chunks/{actionText-b0bd6eb7.cjs.map → actionText-a64be267.mjs.map} +1 -1
- package/dist/chunks/{index-2a5b8ace.cjs → index-032137a6.cjs} +63 -29
- package/dist/chunks/index-032137a6.cjs.map +1 -0
- package/dist/chunks/{index-6c221fa0.mjs → index-fb2ee22c.mjs} +72 -38
- package/dist/chunks/index-fb2ee22c.mjs.map +1 -0
- package/dist/chunks/l10n-05a09c66.mjs +31 -0
- package/dist/chunks/l10n-05a09c66.mjs.map +1 -0
- package/dist/chunks/{l10n-c5f5f001.mjs → l10n-9aa6482d.mjs} +1 -1
- package/dist/chunks/{l10n-c5f5f001.mjs.map → l10n-9aa6482d.mjs.map} +1 -1
- package/dist/chunks/l10n-b1d264c7.cjs +29 -0
- package/dist/chunks/l10n-b1d264c7.cjs.map +1 -0
- package/dist/chunks/{l10n-4326316a.cjs → l10n-c7bd0ea6.cjs} +1 -1
- package/dist/chunks/{l10n-4326316a.cjs.map → l10n-c7bd0ea6.cjs.map} +1 -1
- package/dist/chunks/{referencePickerModal-9b4ff88d.cjs → referencePickerModal-279a483d.cjs} +2 -2
- package/dist/chunks/{referencePickerModal-9b4ff88d.cjs.map → referencePickerModal-279a483d.cjs.map} +1 -1
- package/dist/chunks/{referencePickerModal-0fde503d.mjs → referencePickerModal-443a4c57.mjs} +2 -2
- package/dist/chunks/{referencePickerModal-0fde503d.mjs.map → referencePickerModal-443a4c57.mjs.map} +1 -1
- package/dist/index.cjs +105 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +138 -129
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
- package/dist/assets/index-7768d5e5.css +0 -148
- package/dist/chunks/NcInputConfirmCancel-0c4bee9a.cjs.map +0 -1
- package/dist/chunks/NcInputConfirmCancel-f881168d.mjs.map +0 -1
- package/dist/chunks/index-2a5b8ace.cjs.map +0 -1
- package/dist/chunks/index-6c221fa0.mjs.map +0 -1
- package/dist/chunks/l10n-27a75c40.mjs +0 -31
- package/dist/chunks/l10n-27a75c40.mjs.map +0 -1
- package/dist/chunks/l10n-903083c4.cjs +0 -29
- package/dist/chunks/l10n-903083c4.cjs.map +0 -1
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
2
|
+
const o = require("vue-material-design-icons/Eye.vue"), l = require("vue-material-design-icons/EyeOff.vue"), a = require("./NcInputField.cjs"), u = require("debounce"), d = require("@nextcloud/axios"), c = require("@nextcloud/initial-state"), p = require("@nextcloud/router"), n = require("../chunks/l10n-b1d264c7.cjs"), f = require("../chunks/logger-4998b668.cjs"), h = require("../chunks/_plugin-vue2_normalizer-7f9efb60.cjs"), r = (t) => t && t.__esModule ? t : { default: t }, _ = /* @__PURE__ */ r(o), g = /* @__PURE__ */ r(l), m = /* @__PURE__ */ r(u), w = /* @__PURE__ */ r(d), s = c.loadState("core", "capabilities", {}).password_policy || null, y = new Set(Object.keys(a.props)), b = {
|
|
3
3
|
name: "NcPasswordField",
|
|
4
4
|
components: {
|
|
5
|
-
NcInputField:
|
|
6
|
-
Eye:
|
|
7
|
-
EyeOff:
|
|
5
|
+
NcInputField: a,
|
|
6
|
+
Eye: _.default,
|
|
7
|
+
EyeOff: g.default
|
|
8
8
|
},
|
|
9
9
|
// Allow forwarding all attributes
|
|
10
10
|
inheritAttrs: !1,
|
|
11
11
|
props: {
|
|
12
|
-
...n.props,
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* This will be displayed beneath the input field
|
|
13
|
+
* Any [NcInputField](#/Components/NcFields?id=ncinputfield) props
|
|
17
14
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
// Not an actual prop but needed to show in vue-styleguidist docs
|
|
16
|
+
// eslint-disable-next-line
|
|
17
|
+
" ": {},
|
|
18
|
+
// Reuse all the props from NcInputField for better typing and documentation
|
|
19
|
+
...a.props,
|
|
20
|
+
// Redefined props
|
|
21
|
+
/**
|
|
22
|
+
* Controls whether to display the trailing button.
|
|
23
|
+
*/
|
|
24
|
+
showTrailingButton: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: !0
|
|
21
27
|
},
|
|
28
|
+
// Removed NcInputField props, defined only by this component
|
|
29
|
+
trailingButtonLabel: void 0,
|
|
30
|
+
// Custom props
|
|
22
31
|
/**
|
|
23
32
|
* Check if the user entered a valid password using the password_policy
|
|
24
33
|
* app if available.
|
|
@@ -45,13 +54,6 @@ const a = require("vue-material-design-icons/Eye.vue"), l = require("vue-materia
|
|
|
45
54
|
maxlength: {
|
|
46
55
|
type: Number,
|
|
47
56
|
default: null
|
|
48
|
-
},
|
|
49
|
-
/**
|
|
50
|
-
* Controls whether to display the trailing button.
|
|
51
|
-
*/
|
|
52
|
-
showTrailingButton: {
|
|
53
|
-
type: Boolean,
|
|
54
|
-
default: !0
|
|
55
57
|
}
|
|
56
58
|
},
|
|
57
59
|
emits: [
|
|
@@ -63,7 +65,6 @@ const a = require("vue-material-design-icons/Eye.vue"), l = require("vue-materia
|
|
|
63
65
|
return {
|
|
64
66
|
isPasswordHidden: !0,
|
|
65
67
|
internalHelpMessage: "",
|
|
66
|
-
passwordPolicy: d.loadState("core", "capabilities", {}).password_policy || null,
|
|
67
68
|
isValid: null
|
|
68
69
|
};
|
|
69
70
|
},
|
|
@@ -78,21 +79,31 @@ const a = require("vue-material-design-icons/Eye.vue"), l = require("vue-materia
|
|
|
78
79
|
return this.helperText.length > 0 ? this.helperText : this.internalHelpMessage;
|
|
79
80
|
},
|
|
80
81
|
rules() {
|
|
81
|
-
const { minlength: t
|
|
82
|
+
const { minlength: t } = this;
|
|
82
83
|
return {
|
|
83
|
-
minlength: t != null ? t :
|
|
84
|
+
minlength: t != null ? t : s == null ? void 0 : s.minLength
|
|
84
85
|
};
|
|
85
86
|
},
|
|
86
87
|
trailingButtonLabelPassword() {
|
|
87
|
-
return this.isPasswordHidden ?
|
|
88
|
+
return this.isPasswordHidden ? n.t("Show password") : n.t("Hide password");
|
|
89
|
+
},
|
|
90
|
+
propsAndAttrsToForward() {
|
|
91
|
+
return {
|
|
92
|
+
// Proxy all the HTML attributes
|
|
93
|
+
...this.$attrs,
|
|
94
|
+
// Proxy original NcInputField's props
|
|
95
|
+
...Object.fromEntries(
|
|
96
|
+
Object.entries(this.$props).filter(([t]) => y.has(t))
|
|
97
|
+
)
|
|
98
|
+
};
|
|
88
99
|
}
|
|
89
100
|
},
|
|
90
101
|
watch: {
|
|
91
102
|
value(t) {
|
|
92
103
|
if (this.checkPasswordStrength) {
|
|
93
|
-
if (
|
|
104
|
+
if (s === null)
|
|
94
105
|
return;
|
|
95
|
-
this.
|
|
106
|
+
this.checkPassword(t);
|
|
96
107
|
}
|
|
97
108
|
}
|
|
98
109
|
},
|
|
@@ -119,34 +130,34 @@ const a = require("vue-material-design-icons/Eye.vue"), l = require("vue-materia
|
|
|
119
130
|
togglePasswordVisibility() {
|
|
120
131
|
this.isPasswordHidden = !this.isPasswordHidden;
|
|
121
132
|
},
|
|
122
|
-
checkPassword:
|
|
133
|
+
checkPassword: m.default(async function(t) {
|
|
123
134
|
try {
|
|
124
|
-
const { data: e } = await w.default.post(
|
|
135
|
+
const { data: e } = await w.default.post(p.generateOcsUrl("apps/password_policy/api/v1/validate"), { password: t });
|
|
125
136
|
if (this.isValid = e.ocs.data.passed, e.ocs.data.passed) {
|
|
126
|
-
this.internalHelpMessage =
|
|
137
|
+
this.internalHelpMessage = n.t("Password is secure"), this.$emit("valid");
|
|
127
138
|
return;
|
|
128
139
|
}
|
|
129
140
|
this.internalHelpMessage = e.ocs.data.reason, this.$emit("invalid");
|
|
130
141
|
} catch (e) {
|
|
131
|
-
|
|
142
|
+
f.logger.error("Password policy returned an error", e);
|
|
132
143
|
}
|
|
133
144
|
}, 500)
|
|
134
145
|
}
|
|
135
146
|
};
|
|
136
|
-
var
|
|
137
|
-
var e = this,
|
|
138
|
-
return
|
|
139
|
-
return [e.isPasswordHidden ?
|
|
140
|
-
}, proxy: !0 }]) }, "NcInputField",
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
y,
|
|
147
|
+
var P = function() {
|
|
148
|
+
var e = this, i = e._self._c;
|
|
149
|
+
return i("NcInputField", e._g(e._b({ ref: "inputField", attrs: { type: e.isPasswordHidden ? "password" : "text", "trailing-button-label": e.trailingButtonLabelPassword, "helper-text": e.computedHelperText, error: e.computedError, success: e.computedSuccess, minlength: e.rules.minlength }, on: { "trailing-button-click": e.togglePasswordVisibility, input: e.handleInput }, scopedSlots: e._u([{ key: "trailing-button-icon", fn: function() {
|
|
150
|
+
return [e.isPasswordHidden ? i("Eye", { attrs: { size: 18 } }) : i("EyeOff", { attrs: { size: 18 } })];
|
|
151
|
+
}, proxy: !0 }]) }, "NcInputField", e.propsAndAttrsToForward, !1), e.$listeners), [e._t("default")], 2);
|
|
152
|
+
}, v = [], F = /* @__PURE__ */ h.normalizeComponent(
|
|
153
|
+
b,
|
|
144
154
|
P,
|
|
155
|
+
v,
|
|
145
156
|
!1,
|
|
146
157
|
null,
|
|
147
158
|
null,
|
|
148
159
|
null,
|
|
149
160
|
null
|
|
150
161
|
);
|
|
151
|
-
const
|
|
152
|
-
module.exports =
|
|
162
|
+
const H = F.exports;
|
|
163
|
+
module.exports = H;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NcPasswordField.cjs","sources":["../../src/components/NcPasswordField/NcPasswordField.vue"],"sourcesContent":["<!--\n - @copyright Copyright (c) 2022 Marco Ambrosini <marcoambrosini@pm.me>\n -\n - @author Marco Ambrosini <marcoambrosini@pm.me>\n - @author Carl Schwan <carl@carlschwan.eu>\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<docs>\n### Description\nSee [NcInputField](#/Components/NcFields?id=ncinputfield) for a list of all available props.\n\nGeneral purpose password field component.\n\n```\n<template>\n\t<div class=\"wrapper\">\n\t\t<NcPasswordField :value.sync=\"text1\"\n\t\t\tlabel=\"Old password\" />\n\t\t<div class=\"external-label\">\n\t\t\t<label for=\"textField\">New password</label>\n\t\t\t<NcPasswordField id=\"textField\"\n\t\t\t\t:value.sync=\"text2\"\n\t\t\t\t:label-outside=\"true\"\n\t\t\t\tplaceholder=\"Min. 12 characters\" />\n\t\t</div>\n\t\t<div class=\"external-label\">\n\t\t\t<label for=\"textField2\">New password</label>\n\t\t\t<NcPasswordField id=\"textField2\"\n\t\t\t\t:value.sync=\"text3\"\n\t\t\t\t:error=\"true\"\n\t\t\t\t:label-outside=\"true\"\n\t\t\t\tplaceholder=\"Min. 12 characters\"\n\t\t\t\thelper-text=\"Password is insecure\" />\n\t\t</div>\n\n\t\t<NcPasswordField :value.sync=\"text4\"\n\t\t\tlabel=\"Good new password\"\n\t\t\t:success=\"true\"\n\t\t\tplaceholder=\"Min. 12 characters\"\n\t\t\thelper-text=\"Password is secure\" />\n\n\t\t<NcPasswordField :value.sync=\"text5\"\n\t\t\t:disabled=\"true\"\n\t\t\tlabel=\"Disabled\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\ttext1: '',\n\t\t\ttext2: '',\n\t\t\ttext3: 'hunter',\n\t\t\ttext4: '',\n\t\t\ttext5: '',\n\t\t}\n\t},\n}\n</script>\n<style lang=\"scss\" scoped>\n.wrapper {\n\tdisplay: flex;\n\tgap: 4px;\n\talign-items: flex-end;\n\tflex-wrap: wrap;\n}\n\n.external-label {\n\tdisplay: flex;\n\twidth: 100%;\n\tmargin-top: 1rem;\n}\n\n.external-label label {\n\tpadding-top: 7px;\n\tpadding-right: 14px;\n\twhite-space: nowrap;\n}\n</style>\n```\n</docs>\n\n<template>\n\t<NcInputField v-bind=\"{...$attrs, ...$props }\"\n\t\tref=\"inputField\"\n\t\t:type=\"isPasswordHidden ? 'password' : 'text'\"\n\t\t:show-trailing-button=\"showTrailingButton && true\"\n\t\t:trailing-button-label=\"trailingButtonLabelPassword\"\n\t\t:helper-text=\"computedHelperText\"\n\t\t:error=\"computedError\"\n\t\t:success=\"computedSuccess\"\n\t\t:minlength=\"rules.minlength\"\n\t\tv-on=\"$listeners\"\n\t\t@trailing-button-click=\"togglePasswordVisibility\"\n\t\t@input=\"handleInput\">\n\t\t<!-- Default slot for the leading icon -->\n\t\t<slot />\n\t\t<template #trailing-button-icon>\n\t\t\t<Eye v-if=\"isPasswordHidden\" :size=\"18\" />\n\t\t\t<EyeOff v-else :size=\"18\" />\n\t\t</template>\n\t</NcInputField>\n</template>\n\n<script>\n\nimport Eye from 'vue-material-design-icons/Eye.vue'\nimport EyeOff from 'vue-material-design-icons/EyeOff.vue'\nimport NcInputField from '../NcInputField/NcInputField.vue'\nimport debounce from 'debounce'\nimport axios from '@nextcloud/axios'\nimport { loadState } from '@nextcloud/initial-state'\nimport { generateOcsUrl } from '@nextcloud/router'\nimport { t } from '../../l10n.js'\nimport logger from '../../utils/logger.js'\n\nexport default {\n\tname: 'NcPasswordField',\n\n\tcomponents: {\n\t\tNcInputField,\n\t\tEye,\n\t\tEyeOff,\n\t},\n\n\t// Allow forwarding all attributes\n\tinheritAttrs: false,\n\n\tprops: {\n\t\t...NcInputField.props,\n\n\t\t/**\n\t\t * Additional error message\n\t\t *\n\t\t * This will be displayed beneath the input field\n\t\t */\n\t\thelperText: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/**\n\t\t * Check if the user entered a valid password using the password_policy\n\t\t * app if available.\n\t\t *\n\t\t * Warning: this doesn't replace server side checking and will do nothing\n\t\t * if the password_policy app is disabled.\n\t\t */\n\t\tcheckPasswordStrength: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * The minlength property defines the minimum number of characters\n\t\t * (as UTF-16 code units) the user can enter\n\t\t */\n\t\tminlength: {\n\t\t\ttype: Number,\n\t\t\tdefault: 0,\n\t\t},\n\n\t\t/**\n\t\t * The maxlength property defines the maximum number of characters\n\t\t * (as UTF-16 code units) the user can enter\n\t\t */\n\t\tmaxlength: {\n\t\t\ttype: Number,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/**\n\t\t * Controls whether to display the trailing button.\n\t\t */\n\t\tshowTrailingButton: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t},\n\t},\n\n\temits: [\n\t\t'valid',\n\t\t'invalid',\n\t\t'update:value',\n\t],\n\n\tdata() {\n\t\treturn {\n\t\t\tisPasswordHidden: true,\n\t\t\tinternalHelpMessage: '',\n\t\t\tpasswordPolicy: loadState('core', 'capabilities', {}).password_policy || null,\n\t\t\tisValid: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tcomputedError() {\n\t\t\treturn this.error || this.isValid === false\n\t\t},\n\t\tcomputedSuccess() {\n\t\t\treturn this.success || this.isValid === true\n\t\t},\n\t\tcomputedHelperText() {\n\t\t\tif (this.helperText.length > 0) {\n\t\t\t\treturn this.helperText\n\t\t\t}\n\t\t\treturn this.internalHelpMessage\n\t\t},\n\n\t\trules() {\n\t\t\tconst { minlength, passwordPolicy } = this\n\t\t\treturn {\n\t\t\t\tminlength: minlength ?? passwordPolicy?.minLength,\n\t\t\t}\n\t\t},\n\n\t\ttrailingButtonLabelPassword() {\n\t\t\treturn this.isPasswordHidden ? t('Show password') : t('Hide password')\n\t\t},\n\t},\n\n\twatch: {\n\t\tvalue(newValue) {\n\t\t\tif (this.checkPasswordStrength) {\n\t\t\t\tif (this.passwordPolicy === null) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif (this.passwordPolicy) {\n\t\t\t\t\tthis.checkPassword(newValue)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Focus the input element\n\t\t *\n\t\t * @public\n\t\t */\n\t\tfocus() {\n\t\t\tthis.$refs.inputField.focus()\n\t\t},\n\n\t\t/**\n\t\t * Select all the text in the input\n\t\t *\n\t\t * @public\n\t\t */\n\t\tselect() {\n\t\t\tthis.$refs.inputField.select()\n\t\t},\n\n\t\thandleInput(event) {\n\t\t\t/**\n\t\t\t * Triggers when the value inside the password field is\n\t\t\t * updated.\n\t\t\t *\n\t\t\t * @property {string} The new value\n\t\t\t */\n\t\t\tthis.$emit('update:value', event.target.value)\n\t\t},\n\t\ttogglePasswordVisibility() {\n\t\t\tthis.isPasswordHidden = !this.isPasswordHidden\n\t\t},\n\t\tcheckPassword: debounce(async function(password) {\n\t\t\ttry {\n\t\t\t\tconst { data } = await axios.post(generateOcsUrl('apps/password_policy/api/v1/validate'), { password })\n\t\t\t\tthis.isValid = data.ocs.data.passed\n\t\t\t\tif (data.ocs.data.passed) {\n\t\t\t\t\tthis.internalHelpMessage = t('Password is secure')\n\t\t\t\t\t/**\n\t\t\t\t\t * Triggers when the internal password_policy detect that the\n\t\t\t\t\t * password entered is valid.\n\t\t\t\t\t */\n\t\t\t\t\tthis.$emit('valid')\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tthis.internalHelpMessage = data.ocs.data.reason\n\t\t\t\t/**\n\t\t\t\t * Triggers when the internal password_policy detect that the\n\t\t\t\t * password entered is invalid.\n\t\t\t\t */\n\t\t\t\tthis.$emit('invalid')\n\t\t\t} catch (e) {\n\t\t\t\tlogger.error('Password policy returned an error', e)\n\t\t\t}\n\t\t}, 500),\n\t},\n}\n</script>\n"],"names":["_sfc_main","NcInputField","Eye","EyeOff","loadState","minlength","passwordPolicy","t","newValue","event","debounce","password","data","axios","generateOcsUrl","logger"],"mappings":";ykBAmIAA,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,cAAAC;AAAAA,IACA,KAAAC,EAAA;AAAA,IACA,QAAAC,EAAA;AAAA,EACA;AAAA;AAAA,EAGA,cAAA;AAAA,EAEA,OAAA;AAAA,IACA,GAAAF,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,YAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,uBAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,WAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,WAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,oBAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AACA,WAAA;AAAA,MACA,kBAAA;AAAA,MACA,qBAAA;AAAA,MACA,gBAAAG,EAAA,UAAA,QAAA,gBAAA,CAAA,CAAA,EAAA,mBAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,UAAA;AAAA,IACA,gBAAA;AACA,aAAA,KAAA,SAAA,KAAA,YAAA;AAAA,IACA;AAAA,IACA,kBAAA;AACA,aAAA,KAAA,WAAA,KAAA,YAAA;AAAA,IACA;AAAA,IACA,qBAAA;AACA,aAAA,KAAA,WAAA,SAAA,IACA,KAAA,aAEA,KAAA;AAAA,IACA;AAAA,IAEA,QAAA;AACA,YAAA,EAAA,WAAAC,GAAA,gBAAAC,EAA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3,"file":"NcPasswordField.cjs","sources":["../../src/components/NcPasswordField/NcPasswordField.vue"],"sourcesContent":["<!--\n - @copyright Copyright (c) 2022 Marco Ambrosini <marcoambrosini@pm.me>\n -\n - @author Marco Ambrosini <marcoambrosini@pm.me>\n - @author Carl Schwan <carl@carlschwan.eu>\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<docs>\n### Description\nSee [NcInputField](#/Components/NcFields?id=ncinputfield) for a list of all available props.\n\nGeneral purpose password field component.\n\n```\n<template>\n\t<div class=\"wrapper\">\n\t\t<NcPasswordField :value.sync=\"text1\"\n\t\t\tlabel=\"Old password\" />\n\t\t<div class=\"external-label\">\n\t\t\t<label for=\"textField\">New password</label>\n\t\t\t<NcPasswordField id=\"textField\"\n\t\t\t\t:value.sync=\"text2\"\n\t\t\t\t:label-outside=\"true\"\n\t\t\t\tplaceholder=\"Min. 12 characters\" />\n\t\t</div>\n\t\t<div class=\"external-label\">\n\t\t\t<label for=\"textField2\">New password</label>\n\t\t\t<NcPasswordField id=\"textField2\"\n\t\t\t\t:value.sync=\"text3\"\n\t\t\t\t:error=\"true\"\n\t\t\t\t:label-outside=\"true\"\n\t\t\t\tplaceholder=\"Min. 12 characters\"\n\t\t\t\thelper-text=\"Password is insecure\" />\n\t\t</div>\n\n\t\t<NcPasswordField :value.sync=\"text4\"\n\t\t\tlabel=\"Good new password\"\n\t\t\t:success=\"true\"\n\t\t\tplaceholder=\"Min. 12 characters\"\n\t\t\thelper-text=\"Password is secure\" />\n\n\t\t<NcPasswordField :value.sync=\"text5\"\n\t\t\t:disabled=\"true\"\n\t\t\tlabel=\"Disabled\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\ttext1: '',\n\t\t\ttext2: '',\n\t\t\ttext3: 'hunter',\n\t\t\ttext4: '',\n\t\t\ttext5: '',\n\t\t}\n\t},\n}\n</script>\n<style lang=\"scss\" scoped>\n.wrapper {\n\tdisplay: flex;\n\tgap: 4px;\n\talign-items: flex-end;\n\tflex-wrap: wrap;\n}\n\n.external-label {\n\tdisplay: flex;\n\twidth: 100%;\n\tmargin-top: 1rem;\n}\n\n.external-label label {\n\tpadding-top: 7px;\n\tpadding-right: 14px;\n\twhite-space: nowrap;\n}\n</style>\n```\n</docs>\n\n<template>\n\t<NcInputField v-bind=\"propsAndAttrsToForward\"\n\t\tref=\"inputField\"\n\t\t:type=\"isPasswordHidden ? 'password' : 'text'\"\n\t\t:trailing-button-label=\"trailingButtonLabelPassword\"\n\t\t:helper-text=\"computedHelperText\"\n\t\t:error=\"computedError\"\n\t\t:success=\"computedSuccess\"\n\t\t:minlength=\"rules.minlength\"\n\t\tv-on=\"$listeners\"\n\t\t@trailing-button-click=\"togglePasswordVisibility\"\n\t\t@input=\"handleInput\">\n\t\t<!-- Default slot for the leading icon -->\n\t\t<slot />\n\t\t<template #trailing-button-icon>\n\t\t\t<Eye v-if=\"isPasswordHidden\" :size=\"18\" />\n\t\t\t<EyeOff v-else :size=\"18\" />\n\t\t</template>\n\t</NcInputField>\n</template>\n\n<script>\n\nimport Eye from 'vue-material-design-icons/Eye.vue'\nimport EyeOff from 'vue-material-design-icons/EyeOff.vue'\nimport NcInputField from '../NcInputField/NcInputField.vue'\nimport debounce from 'debounce'\nimport axios from '@nextcloud/axios'\nimport { loadState } from '@nextcloud/initial-state'\nimport { generateOcsUrl } from '@nextcloud/router'\nimport { t } from '../../l10n.js'\nimport logger from '../../utils/logger.js'\n\n/**\n * @typedef PasswordPolicy\n * @property {object} api - The URLs to the password_policy app methods\n * @property {string} api.generate - The URL to the password generator\n * @property {string} api.validate - The URL to the password validator\n * @property {boolean} enforceNonCommonPassword - Whether to enforce non common passwords\n * @property {boolean} enforceNumericCharacters - Whether to enforce numeric characters\n * @property {boolean} enforceSpecialCharacters - Whether to enforce special characters\n * @property {boolean} enforceUpperLowerCase - Whether to enforce upper and lower case\n * @property {number} minLength - The minimum length of the password\n */\n\n/** @type {PasswordPolicy|null} */\nconst passwordPolicy = loadState('core', 'capabilities', {}).password_policy || null\n\nconst NcInputFieldProps = new Set(Object.keys(NcInputField.props))\n\nexport default {\n\tname: 'NcPasswordField',\n\n\tcomponents: {\n\t\tNcInputField,\n\t\tEye,\n\t\tEyeOff,\n\t},\n\n\t// Allow forwarding all attributes\n\tinheritAttrs: false,\n\n\tprops: {\n\t\t/**\n\t\t * Any [NcInputField](#/Components/NcFields?id=ncinputfield) props\n\t\t */\n\t\t// Not an actual prop but needed to show in vue-styleguidist docs\n\t\t// eslint-disable-next-line\n\t\t' ': {},\n\n\t\t// Reuse all the props from NcInputField for better typing and documentation\n\t\t...NcInputField.props,\n\n\t\t// Redefined props\n\n\t\t/**\n\t\t * Controls whether to display the trailing button.\n\t\t */\n\t\t showTrailingButton: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t},\n\n\t\t// Removed NcInputField props, defined only by this component\n\n\t\ttrailingButtonLabel: undefined,\n\n\t\t// Custom props\n\n\t\t/**\n\t\t * Check if the user entered a valid password using the password_policy\n\t\t * app if available.\n\t\t *\n\t\t * Warning: this doesn't replace server side checking and will do nothing\n\t\t * if the password_policy app is disabled.\n\t\t */\n\t\tcheckPasswordStrength: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * The minlength property defines the minimum number of characters\n\t\t * (as UTF-16 code units) the user can enter\n\t\t */\n\t\tminlength: {\n\t\t\ttype: Number,\n\t\t\tdefault: 0,\n\t\t},\n\n\t\t/**\n\t\t * The maxlength property defines the maximum number of characters\n\t\t * (as UTF-16 code units) the user can enter\n\t\t */\n\t\tmaxlength: {\n\t\t\ttype: Number,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\temits: [\n\t\t'valid',\n\t\t'invalid',\n\t\t'update:value',\n\t],\n\n\tdata() {\n\t\treturn {\n\t\t\tisPasswordHidden: true,\n\t\t\tinternalHelpMessage: '',\n\t\t\tisValid: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tcomputedError() {\n\t\t\treturn this.error || this.isValid === false\n\t\t},\n\t\tcomputedSuccess() {\n\t\t\treturn this.success || this.isValid === true\n\t\t},\n\t\tcomputedHelperText() {\n\t\t\tif (this.helperText.length > 0) {\n\t\t\t\treturn this.helperText\n\t\t\t}\n\t\t\treturn this.internalHelpMessage\n\t\t},\n\n\t\trules() {\n\t\t\tconst { minlength } = this\n\t\t\treturn {\n\t\t\t\tminlength: minlength ?? passwordPolicy?.minLength,\n\t\t\t}\n\t\t},\n\n\t\ttrailingButtonLabelPassword() {\n\t\t\treturn this.isPasswordHidden ? t('Show password') : t('Hide password')\n\t\t},\n\n\t\tpropsAndAttrsToForward() {\n\t\t\treturn {\n\t\t\t\t// Proxy all the HTML attributes\n\t\t\t\t...this.$attrs,\n\t\t\t\t// Proxy original NcInputField's props\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\tObject.entries(this.$props).filter(([key]) => NcInputFieldProps.has(key)),\n\t\t\t\t),\n\t\t\t}\n\t\t},\n\t},\n\n\twatch: {\n\t\tvalue(newValue) {\n\t\t\tif (this.checkPasswordStrength) {\n\t\t\t\tif (passwordPolicy === null) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.checkPassword(newValue)\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Focus the input element\n\t\t *\n\t\t * @public\n\t\t */\n\t\tfocus() {\n\t\t\tthis.$refs.inputField.focus()\n\t\t},\n\n\t\t/**\n\t\t * Select all the text in the input\n\t\t *\n\t\t * @public\n\t\t */\n\t\tselect() {\n\t\t\tthis.$refs.inputField.select()\n\t\t},\n\n\t\thandleInput(event) {\n\t\t\t/**\n\t\t\t * Triggers when the value inside the password field is\n\t\t\t * updated.\n\t\t\t *\n\t\t\t * @property {string} The new value\n\t\t\t */\n\t\t\tthis.$emit('update:value', event.target.value)\n\t\t},\n\t\ttogglePasswordVisibility() {\n\t\t\tthis.isPasswordHidden = !this.isPasswordHidden\n\t\t},\n\t\tcheckPassword: debounce(async function(password) {\n\t\t\ttry {\n\t\t\t\tconst { data } = await axios.post(generateOcsUrl('apps/password_policy/api/v1/validate'), { password })\n\t\t\t\tthis.isValid = data.ocs.data.passed\n\t\t\t\tif (data.ocs.data.passed) {\n\t\t\t\t\tthis.internalHelpMessage = t('Password is secure')\n\t\t\t\t\t/**\n\t\t\t\t\t * Triggers when the internal password_policy detect that the\n\t\t\t\t\t * password entered is valid.\n\t\t\t\t\t */\n\t\t\t\t\tthis.$emit('valid')\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tthis.internalHelpMessage = data.ocs.data.reason\n\t\t\t\t/**\n\t\t\t\t * Triggers when the internal password_policy detect that the\n\t\t\t\t * password entered is invalid.\n\t\t\t\t */\n\t\t\t\tthis.$emit('invalid')\n\t\t\t} catch (e) {\n\t\t\t\tlogger.error('Password policy returned an error', e)\n\t\t\t}\n\t\t}, 500),\n\t},\n}\n</script>\n"],"names":["passwordPolicy","loadState","NcInputFieldProps","NcInputField","_sfc_main","Eye","EyeOff","minlength","t","key","newValue","event","debounce","password","data","axios","generateOcsUrl","logger"],"mappings":";ykBA+IAA,IAAAC,EAAA,UAAA,QAAA,gBAAA,CAAA,CAAA,EAAA,mBAAA,MAEAC,IAAA,IAAA,IAAA,OAAA,KAAAC,EAAA,KAAA,CAAA,GAEAC,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,cAAAD;AAAAA,IACA,KAAAE,EAAA;AAAA,IACA,QAA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|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { loadState as
|
|
7
|
-
import { generateOcsUrl as
|
|
8
|
-
import { t as
|
|
9
|
-
import { l as
|
|
10
|
-
import { n as
|
|
11
|
-
const
|
|
1
|
+
import o from "vue-material-design-icons/Eye.vue";
|
|
2
|
+
import a from "vue-material-design-icons/EyeOff.vue";
|
|
3
|
+
import n from "./NcInputField.mjs";
|
|
4
|
+
import l from "debounce";
|
|
5
|
+
import d from "@nextcloud/axios";
|
|
6
|
+
import { loadState as u } from "@nextcloud/initial-state";
|
|
7
|
+
import { generateOcsUrl as p } from "@nextcloud/router";
|
|
8
|
+
import { t as i } from "../chunks/l10n-05a09c66.mjs";
|
|
9
|
+
import { l as c } from "../chunks/logger-3612e664.mjs";
|
|
10
|
+
import { n as h } from "../chunks/_plugin-vue2_normalizer-71e2aa87.mjs";
|
|
11
|
+
const s = u("core", "capabilities", {}).password_policy || null, m = new Set(Object.keys(n.props)), f = {
|
|
12
12
|
name: "NcPasswordField",
|
|
13
13
|
components: {
|
|
14
|
-
NcInputField:
|
|
15
|
-
Eye:
|
|
16
|
-
EyeOff:
|
|
14
|
+
NcInputField: n,
|
|
15
|
+
Eye: o,
|
|
16
|
+
EyeOff: a
|
|
17
17
|
},
|
|
18
18
|
// Allow forwarding all attributes
|
|
19
19
|
inheritAttrs: !1,
|
|
20
20
|
props: {
|
|
21
|
-
...i.props,
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* This will be displayed beneath the input field
|
|
22
|
+
* Any [NcInputField](#/Components/NcFields?id=ncinputfield) props
|
|
26
23
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
// Not an actual prop but needed to show in vue-styleguidist docs
|
|
25
|
+
// eslint-disable-next-line
|
|
26
|
+
" ": {},
|
|
27
|
+
// Reuse all the props from NcInputField for better typing and documentation
|
|
28
|
+
...n.props,
|
|
29
|
+
// Redefined props
|
|
30
|
+
/**
|
|
31
|
+
* Controls whether to display the trailing button.
|
|
32
|
+
*/
|
|
33
|
+
showTrailingButton: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: !0
|
|
30
36
|
},
|
|
37
|
+
// Removed NcInputField props, defined only by this component
|
|
38
|
+
trailingButtonLabel: void 0,
|
|
39
|
+
// Custom props
|
|
31
40
|
/**
|
|
32
41
|
* Check if the user entered a valid password using the password_policy
|
|
33
42
|
* app if available.
|
|
@@ -54,13 +63,6 @@ const h = {
|
|
|
54
63
|
maxlength: {
|
|
55
64
|
type: Number,
|
|
56
65
|
default: null
|
|
57
|
-
},
|
|
58
|
-
/**
|
|
59
|
-
* Controls whether to display the trailing button.
|
|
60
|
-
*/
|
|
61
|
-
showTrailingButton: {
|
|
62
|
-
type: Boolean,
|
|
63
|
-
default: !0
|
|
64
66
|
}
|
|
65
67
|
},
|
|
66
68
|
emits: [
|
|
@@ -72,7 +74,6 @@ const h = {
|
|
|
72
74
|
return {
|
|
73
75
|
isPasswordHidden: !0,
|
|
74
76
|
internalHelpMessage: "",
|
|
75
|
-
passwordPolicy: d("core", "capabilities", {}).password_policy || null,
|
|
76
77
|
isValid: null
|
|
77
78
|
};
|
|
78
79
|
},
|
|
@@ -87,21 +88,31 @@ const h = {
|
|
|
87
88
|
return this.helperText.length > 0 ? this.helperText : this.internalHelpMessage;
|
|
88
89
|
},
|
|
89
90
|
rules() {
|
|
90
|
-
const { minlength: t
|
|
91
|
+
const { minlength: t } = this;
|
|
91
92
|
return {
|
|
92
|
-
minlength: t != null ? t :
|
|
93
|
+
minlength: t != null ? t : s == null ? void 0 : s.minLength
|
|
93
94
|
};
|
|
94
95
|
},
|
|
95
96
|
trailingButtonLabelPassword() {
|
|
96
|
-
return this.isPasswordHidden ?
|
|
97
|
+
return this.isPasswordHidden ? i("Show password") : i("Hide password");
|
|
98
|
+
},
|
|
99
|
+
propsAndAttrsToForward() {
|
|
100
|
+
return {
|
|
101
|
+
// Proxy all the HTML attributes
|
|
102
|
+
...this.$attrs,
|
|
103
|
+
// Proxy original NcInputField's props
|
|
104
|
+
...Object.fromEntries(
|
|
105
|
+
Object.entries(this.$props).filter(([t]) => m.has(t))
|
|
106
|
+
)
|
|
107
|
+
};
|
|
97
108
|
}
|
|
98
109
|
},
|
|
99
110
|
watch: {
|
|
100
111
|
value(t) {
|
|
101
112
|
if (this.checkPasswordStrength) {
|
|
102
|
-
if (
|
|
113
|
+
if (s === null)
|
|
103
114
|
return;
|
|
104
|
-
this.
|
|
115
|
+
this.checkPassword(t);
|
|
105
116
|
}
|
|
106
117
|
}
|
|
107
118
|
},
|
|
@@ -128,36 +139,36 @@ const h = {
|
|
|
128
139
|
togglePasswordVisibility() {
|
|
129
140
|
this.isPasswordHidden = !this.isPasswordHidden;
|
|
130
141
|
},
|
|
131
|
-
checkPassword:
|
|
142
|
+
checkPassword: l(async function(t) {
|
|
132
143
|
try {
|
|
133
|
-
const { data: e } = await
|
|
144
|
+
const { data: e } = await d.post(p("apps/password_policy/api/v1/validate"), { password: t });
|
|
134
145
|
if (this.isValid = e.ocs.data.passed, e.ocs.data.passed) {
|
|
135
|
-
this.internalHelpMessage =
|
|
146
|
+
this.internalHelpMessage = i("Password is secure"), this.$emit("valid");
|
|
136
147
|
return;
|
|
137
148
|
}
|
|
138
149
|
this.internalHelpMessage = e.ocs.data.reason, this.$emit("invalid");
|
|
139
150
|
} catch (e) {
|
|
140
|
-
|
|
151
|
+
c.error("Password policy returned an error", e);
|
|
141
152
|
}
|
|
142
153
|
}, 500)
|
|
143
154
|
}
|
|
144
155
|
};
|
|
145
|
-
var
|
|
146
|
-
var e = this,
|
|
147
|
-
return
|
|
148
|
-
return [e.isPasswordHidden ?
|
|
149
|
-
}, proxy: !0 }]) }, "NcInputField",
|
|
150
|
-
},
|
|
151
|
-
h,
|
|
152
|
-
m,
|
|
156
|
+
var w = function() {
|
|
157
|
+
var e = this, r = e._self._c;
|
|
158
|
+
return r("NcInputField", e._g(e._b({ ref: "inputField", attrs: { type: e.isPasswordHidden ? "password" : "text", "trailing-button-label": e.trailingButtonLabelPassword, "helper-text": e.computedHelperText, error: e.computedError, success: e.computedSuccess, minlength: e.rules.minlength }, on: { "trailing-button-click": e.togglePasswordVisibility, input: e.handleInput }, scopedSlots: e._u([{ key: "trailing-button-icon", fn: function() {
|
|
159
|
+
return [e.isPasswordHidden ? r("Eye", { attrs: { size: 18 } }) : r("EyeOff", { attrs: { size: 18 } })];
|
|
160
|
+
}, proxy: !0 }]) }, "NcInputField", e.propsAndAttrsToForward, !1), e.$listeners), [e._t("default")], 2);
|
|
161
|
+
}, g = [], _ = /* @__PURE__ */ h(
|
|
153
162
|
f,
|
|
163
|
+
w,
|
|
164
|
+
g,
|
|
154
165
|
!1,
|
|
155
166
|
null,
|
|
156
167
|
null,
|
|
157
168
|
null,
|
|
158
169
|
null
|
|
159
170
|
);
|
|
160
|
-
const
|
|
171
|
+
const k = _.exports;
|
|
161
172
|
export {
|
|
162
|
-
|
|
173
|
+
k as default
|
|
163
174
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NcPasswordField.mjs","sources":["../../src/components/NcPasswordField/NcPasswordField.vue"],"sourcesContent":["<!--\n - @copyright Copyright (c) 2022 Marco Ambrosini <marcoambrosini@pm.me>\n -\n - @author Marco Ambrosini <marcoambrosini@pm.me>\n - @author Carl Schwan <carl@carlschwan.eu>\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<docs>\n### Description\nSee [NcInputField](#/Components/NcFields?id=ncinputfield) for a list of all available props.\n\nGeneral purpose password field component.\n\n```\n<template>\n\t<div class=\"wrapper\">\n\t\t<NcPasswordField :value.sync=\"text1\"\n\t\t\tlabel=\"Old password\" />\n\t\t<div class=\"external-label\">\n\t\t\t<label for=\"textField\">New password</label>\n\t\t\t<NcPasswordField id=\"textField\"\n\t\t\t\t:value.sync=\"text2\"\n\t\t\t\t:label-outside=\"true\"\n\t\t\t\tplaceholder=\"Min. 12 characters\" />\n\t\t</div>\n\t\t<div class=\"external-label\">\n\t\t\t<label for=\"textField2\">New password</label>\n\t\t\t<NcPasswordField id=\"textField2\"\n\t\t\t\t:value.sync=\"text3\"\n\t\t\t\t:error=\"true\"\n\t\t\t\t:label-outside=\"true\"\n\t\t\t\tplaceholder=\"Min. 12 characters\"\n\t\t\t\thelper-text=\"Password is insecure\" />\n\t\t</div>\n\n\t\t<NcPasswordField :value.sync=\"text4\"\n\t\t\tlabel=\"Good new password\"\n\t\t\t:success=\"true\"\n\t\t\tplaceholder=\"Min. 12 characters\"\n\t\t\thelper-text=\"Password is secure\" />\n\n\t\t<NcPasswordField :value.sync=\"text5\"\n\t\t\t:disabled=\"true\"\n\t\t\tlabel=\"Disabled\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\ttext1: '',\n\t\t\ttext2: '',\n\t\t\ttext3: 'hunter',\n\t\t\ttext4: '',\n\t\t\ttext5: '',\n\t\t}\n\t},\n}\n</script>\n<style lang=\"scss\" scoped>\n.wrapper {\n\tdisplay: flex;\n\tgap: 4px;\n\talign-items: flex-end;\n\tflex-wrap: wrap;\n}\n\n.external-label {\n\tdisplay: flex;\n\twidth: 100%;\n\tmargin-top: 1rem;\n}\n\n.external-label label {\n\tpadding-top: 7px;\n\tpadding-right: 14px;\n\twhite-space: nowrap;\n}\n</style>\n```\n</docs>\n\n<template>\n\t<NcInputField v-bind=\"{...$attrs, ...$props }\"\n\t\tref=\"inputField\"\n\t\t:type=\"isPasswordHidden ? 'password' : 'text'\"\n\t\t:show-trailing-button=\"showTrailingButton && true\"\n\t\t:trailing-button-label=\"trailingButtonLabelPassword\"\n\t\t:helper-text=\"computedHelperText\"\n\t\t:error=\"computedError\"\n\t\t:success=\"computedSuccess\"\n\t\t:minlength=\"rules.minlength\"\n\t\tv-on=\"$listeners\"\n\t\t@trailing-button-click=\"togglePasswordVisibility\"\n\t\t@input=\"handleInput\">\n\t\t<!-- Default slot for the leading icon -->\n\t\t<slot />\n\t\t<template #trailing-button-icon>\n\t\t\t<Eye v-if=\"isPasswordHidden\" :size=\"18\" />\n\t\t\t<EyeOff v-else :size=\"18\" />\n\t\t</template>\n\t</NcInputField>\n</template>\n\n<script>\n\nimport Eye from 'vue-material-design-icons/Eye.vue'\nimport EyeOff from 'vue-material-design-icons/EyeOff.vue'\nimport NcInputField from '../NcInputField/NcInputField.vue'\nimport debounce from 'debounce'\nimport axios from '@nextcloud/axios'\nimport { loadState } from '@nextcloud/initial-state'\nimport { generateOcsUrl } from '@nextcloud/router'\nimport { t } from '../../l10n.js'\nimport logger from '../../utils/logger.js'\n\nexport default {\n\tname: 'NcPasswordField',\n\n\tcomponents: {\n\t\tNcInputField,\n\t\tEye,\n\t\tEyeOff,\n\t},\n\n\t// Allow forwarding all attributes\n\tinheritAttrs: false,\n\n\tprops: {\n\t\t...NcInputField.props,\n\n\t\t/**\n\t\t * Additional error message\n\t\t *\n\t\t * This will be displayed beneath the input field\n\t\t */\n\t\thelperText: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/**\n\t\t * Check if the user entered a valid password using the password_policy\n\t\t * app if available.\n\t\t *\n\t\t * Warning: this doesn't replace server side checking and will do nothing\n\t\t * if the password_policy app is disabled.\n\t\t */\n\t\tcheckPasswordStrength: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * The minlength property defines the minimum number of characters\n\t\t * (as UTF-16 code units) the user can enter\n\t\t */\n\t\tminlength: {\n\t\t\ttype: Number,\n\t\t\tdefault: 0,\n\t\t},\n\n\t\t/**\n\t\t * The maxlength property defines the maximum number of characters\n\t\t * (as UTF-16 code units) the user can enter\n\t\t */\n\t\tmaxlength: {\n\t\t\ttype: Number,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/**\n\t\t * Controls whether to display the trailing button.\n\t\t */\n\t\tshowTrailingButton: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t},\n\t},\n\n\temits: [\n\t\t'valid',\n\t\t'invalid',\n\t\t'update:value',\n\t],\n\n\tdata() {\n\t\treturn {\n\t\t\tisPasswordHidden: true,\n\t\t\tinternalHelpMessage: '',\n\t\t\tpasswordPolicy: loadState('core', 'capabilities', {}).password_policy || null,\n\t\t\tisValid: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tcomputedError() {\n\t\t\treturn this.error || this.isValid === false\n\t\t},\n\t\tcomputedSuccess() {\n\t\t\treturn this.success || this.isValid === true\n\t\t},\n\t\tcomputedHelperText() {\n\t\t\tif (this.helperText.length > 0) {\n\t\t\t\treturn this.helperText\n\t\t\t}\n\t\t\treturn this.internalHelpMessage\n\t\t},\n\n\t\trules() {\n\t\t\tconst { minlength, passwordPolicy } = this\n\t\t\treturn {\n\t\t\t\tminlength: minlength ?? passwordPolicy?.minLength,\n\t\t\t}\n\t\t},\n\n\t\ttrailingButtonLabelPassword() {\n\t\t\treturn this.isPasswordHidden ? t('Show password') : t('Hide password')\n\t\t},\n\t},\n\n\twatch: {\n\t\tvalue(newValue) {\n\t\t\tif (this.checkPasswordStrength) {\n\t\t\t\tif (this.passwordPolicy === null) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif (this.passwordPolicy) {\n\t\t\t\t\tthis.checkPassword(newValue)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Focus the input element\n\t\t *\n\t\t * @public\n\t\t */\n\t\tfocus() {\n\t\t\tthis.$refs.inputField.focus()\n\t\t},\n\n\t\t/**\n\t\t * Select all the text in the input\n\t\t *\n\t\t * @public\n\t\t */\n\t\tselect() {\n\t\t\tthis.$refs.inputField.select()\n\t\t},\n\n\t\thandleInput(event) {\n\t\t\t/**\n\t\t\t * Triggers when the value inside the password field is\n\t\t\t * updated.\n\t\t\t *\n\t\t\t * @property {string} The new value\n\t\t\t */\n\t\t\tthis.$emit('update:value', event.target.value)\n\t\t},\n\t\ttogglePasswordVisibility() {\n\t\t\tthis.isPasswordHidden = !this.isPasswordHidden\n\t\t},\n\t\tcheckPassword: debounce(async function(password) {\n\t\t\ttry {\n\t\t\t\tconst { data } = await axios.post(generateOcsUrl('apps/password_policy/api/v1/validate'), { password })\n\t\t\t\tthis.isValid = data.ocs.data.passed\n\t\t\t\tif (data.ocs.data.passed) {\n\t\t\t\t\tthis.internalHelpMessage = t('Password is secure')\n\t\t\t\t\t/**\n\t\t\t\t\t * Triggers when the internal password_policy detect that the\n\t\t\t\t\t * password entered is valid.\n\t\t\t\t\t */\n\t\t\t\t\tthis.$emit('valid')\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tthis.internalHelpMessage = data.ocs.data.reason\n\t\t\t\t/**\n\t\t\t\t * Triggers when the internal password_policy detect that the\n\t\t\t\t * password entered is invalid.\n\t\t\t\t */\n\t\t\t\tthis.$emit('invalid')\n\t\t\t} catch (e) {\n\t\t\t\tlogger.error('Password policy returned an error', e)\n\t\t\t}\n\t\t}, 500),\n\t},\n}\n</script>\n"],"names":["_sfc_main","NcInputField","Eye","EyeOff","loadState","minlength","passwordPolicy","t","newValue","event","debounce","password","data","axios","generateOcsUrl","logger"],"mappings":";;;;;;;;;;AAmIA,MAAAA,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,cAAAC;AAAA,IACA,KAAAC;AAAA,IACA,QAAAC;AAAA,EACA;AAAA;AAAA,EAGA,cAAA;AAAA,EAEA,OAAA;AAAA,IACA,GAAAF,EA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KAAA,uBAAA;AACA,YAAA,KAAA,mBAAA;AACA;AAEA,QAAA,KAAA,kBACA,KAAA,cAAAA,CAAA;AAAA,MAEA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,QAAA;AACA,WAAA,MAAA,WAAA,MAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,SAAA;AACA,WAAA,MAAA,WAAA,OAAA;AAAA,IACA;AAAA,IAEA,YAAAC,GAAA;AAOA,WAAA,MAAA,gBAAAA,EAAA,OAAA,KAAA;AAAA,IACA;AAAA,IACA,2BAAA;AACA,WAAA,mBAAA,CAAA,KAAA;AAAA,IACA;AAAA,IACA,eAAAC,EAAA,eAAAC,GAAA;AACA,UAAA;AACA,cAAA,EAAA,MAAAC,MAAA,MAAAC,EAAA,KAAAC,EAAA,sCAAA,GAAA,EAAA,UAAAH,GAAA;AAEA,YADA,KAAA,UAAAC,EAAA,IAAA,KAAA,QACAA,EAAA,IAAA,KAAA,QAAA;AACA,eAAA,sBAAAL,EAAA,oBAAA,GAKA,KAAA,MAAA,OAAA;AACA;AAAA,QACA;AAEA,aAAA,sBAAAK,EAAA,IAAA,KAAA,QAKA,KAAA,MAAA,SAAA;AAAA,MACA,SAAA,GAAA;AACA,QAAAG,EAAA,MAAA,qCAAA,CAAA;AAAA,MACA;AAAA,IACA,GAAA,GAAA;AAAA,EACA;AACA;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"NcPasswordField.mjs","sources":["../../src/components/NcPasswordField/NcPasswordField.vue"],"sourcesContent":["<!--\n - @copyright Copyright (c) 2022 Marco Ambrosini <marcoambrosini@pm.me>\n -\n - @author Marco Ambrosini <marcoambrosini@pm.me>\n - @author Carl Schwan <carl@carlschwan.eu>\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<docs>\n### Description\nSee [NcInputField](#/Components/NcFields?id=ncinputfield) for a list of all available props.\n\nGeneral purpose password field component.\n\n```\n<template>\n\t<div class=\"wrapper\">\n\t\t<NcPasswordField :value.sync=\"text1\"\n\t\t\tlabel=\"Old password\" />\n\t\t<div class=\"external-label\">\n\t\t\t<label for=\"textField\">New password</label>\n\t\t\t<NcPasswordField id=\"textField\"\n\t\t\t\t:value.sync=\"text2\"\n\t\t\t\t:label-outside=\"true\"\n\t\t\t\tplaceholder=\"Min. 12 characters\" />\n\t\t</div>\n\t\t<div class=\"external-label\">\n\t\t\t<label for=\"textField2\">New password</label>\n\t\t\t<NcPasswordField id=\"textField2\"\n\t\t\t\t:value.sync=\"text3\"\n\t\t\t\t:error=\"true\"\n\t\t\t\t:label-outside=\"true\"\n\t\t\t\tplaceholder=\"Min. 12 characters\"\n\t\t\t\thelper-text=\"Password is insecure\" />\n\t\t</div>\n\n\t\t<NcPasswordField :value.sync=\"text4\"\n\t\t\tlabel=\"Good new password\"\n\t\t\t:success=\"true\"\n\t\t\tplaceholder=\"Min. 12 characters\"\n\t\t\thelper-text=\"Password is secure\" />\n\n\t\t<NcPasswordField :value.sync=\"text5\"\n\t\t\t:disabled=\"true\"\n\t\t\tlabel=\"Disabled\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\ttext1: '',\n\t\t\ttext2: '',\n\t\t\ttext3: 'hunter',\n\t\t\ttext4: '',\n\t\t\ttext5: '',\n\t\t}\n\t},\n}\n</script>\n<style lang=\"scss\" scoped>\n.wrapper {\n\tdisplay: flex;\n\tgap: 4px;\n\talign-items: flex-end;\n\tflex-wrap: wrap;\n}\n\n.external-label {\n\tdisplay: flex;\n\twidth: 100%;\n\tmargin-top: 1rem;\n}\n\n.external-label label {\n\tpadding-top: 7px;\n\tpadding-right: 14px;\n\twhite-space: nowrap;\n}\n</style>\n```\n</docs>\n\n<template>\n\t<NcInputField v-bind=\"propsAndAttrsToForward\"\n\t\tref=\"inputField\"\n\t\t:type=\"isPasswordHidden ? 'password' : 'text'\"\n\t\t:trailing-button-label=\"trailingButtonLabelPassword\"\n\t\t:helper-text=\"computedHelperText\"\n\t\t:error=\"computedError\"\n\t\t:success=\"computedSuccess\"\n\t\t:minlength=\"rules.minlength\"\n\t\tv-on=\"$listeners\"\n\t\t@trailing-button-click=\"togglePasswordVisibility\"\n\t\t@input=\"handleInput\">\n\t\t<!-- Default slot for the leading icon -->\n\t\t<slot />\n\t\t<template #trailing-button-icon>\n\t\t\t<Eye v-if=\"isPasswordHidden\" :size=\"18\" />\n\t\t\t<EyeOff v-else :size=\"18\" />\n\t\t</template>\n\t</NcInputField>\n</template>\n\n<script>\n\nimport Eye from 'vue-material-design-icons/Eye.vue'\nimport EyeOff from 'vue-material-design-icons/EyeOff.vue'\nimport NcInputField from '../NcInputField/NcInputField.vue'\nimport debounce from 'debounce'\nimport axios from '@nextcloud/axios'\nimport { loadState } from '@nextcloud/initial-state'\nimport { generateOcsUrl } from '@nextcloud/router'\nimport { t } from '../../l10n.js'\nimport logger from '../../utils/logger.js'\n\n/**\n * @typedef PasswordPolicy\n * @property {object} api - The URLs to the password_policy app methods\n * @property {string} api.generate - The URL to the password generator\n * @property {string} api.validate - The URL to the password validator\n * @property {boolean} enforceNonCommonPassword - Whether to enforce non common passwords\n * @property {boolean} enforceNumericCharacters - Whether to enforce numeric characters\n * @property {boolean} enforceSpecialCharacters - Whether to enforce special characters\n * @property {boolean} enforceUpperLowerCase - Whether to enforce upper and lower case\n * @property {number} minLength - The minimum length of the password\n */\n\n/** @type {PasswordPolicy|null} */\nconst passwordPolicy = loadState('core', 'capabilities', {}).password_policy || null\n\nconst NcInputFieldProps = new Set(Object.keys(NcInputField.props))\n\nexport default {\n\tname: 'NcPasswordField',\n\n\tcomponents: {\n\t\tNcInputField,\n\t\tEye,\n\t\tEyeOff,\n\t},\n\n\t// Allow forwarding all attributes\n\tinheritAttrs: false,\n\n\tprops: {\n\t\t/**\n\t\t * Any [NcInputField](#/Components/NcFields?id=ncinputfield) props\n\t\t */\n\t\t// Not an actual prop but needed to show in vue-styleguidist docs\n\t\t// eslint-disable-next-line\n\t\t' ': {},\n\n\t\t// Reuse all the props from NcInputField for better typing and documentation\n\t\t...NcInputField.props,\n\n\t\t// Redefined props\n\n\t\t/**\n\t\t * Controls whether to display the trailing button.\n\t\t */\n\t\t showTrailingButton: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t},\n\n\t\t// Removed NcInputField props, defined only by this component\n\n\t\ttrailingButtonLabel: undefined,\n\n\t\t// Custom props\n\n\t\t/**\n\t\t * Check if the user entered a valid password using the password_policy\n\t\t * app if available.\n\t\t *\n\t\t * Warning: this doesn't replace server side checking and will do nothing\n\t\t * if the password_policy app is disabled.\n\t\t */\n\t\tcheckPasswordStrength: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * The minlength property defines the minimum number of characters\n\t\t * (as UTF-16 code units) the user can enter\n\t\t */\n\t\tminlength: {\n\t\t\ttype: Number,\n\t\t\tdefault: 0,\n\t\t},\n\n\t\t/**\n\t\t * The maxlength property defines the maximum number of characters\n\t\t * (as UTF-16 code units) the user can enter\n\t\t */\n\t\tmaxlength: {\n\t\t\ttype: Number,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\temits: [\n\t\t'valid',\n\t\t'invalid',\n\t\t'update:value',\n\t],\n\n\tdata() {\n\t\treturn {\n\t\t\tisPasswordHidden: true,\n\t\t\tinternalHelpMessage: '',\n\t\t\tisValid: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tcomputedError() {\n\t\t\treturn this.error || this.isValid === false\n\t\t},\n\t\tcomputedSuccess() {\n\t\t\treturn this.success || this.isValid === true\n\t\t},\n\t\tcomputedHelperText() {\n\t\t\tif (this.helperText.length > 0) {\n\t\t\t\treturn this.helperText\n\t\t\t}\n\t\t\treturn this.internalHelpMessage\n\t\t},\n\n\t\trules() {\n\t\t\tconst { minlength } = this\n\t\t\treturn {\n\t\t\t\tminlength: minlength ?? passwordPolicy?.minLength,\n\t\t\t}\n\t\t},\n\n\t\ttrailingButtonLabelPassword() {\n\t\t\treturn this.isPasswordHidden ? t('Show password') : t('Hide password')\n\t\t},\n\n\t\tpropsAndAttrsToForward() {\n\t\t\treturn {\n\t\t\t\t// Proxy all the HTML attributes\n\t\t\t\t...this.$attrs,\n\t\t\t\t// Proxy original NcInputField's props\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\tObject.entries(this.$props).filter(([key]) => NcInputFieldProps.has(key)),\n\t\t\t\t),\n\t\t\t}\n\t\t},\n\t},\n\n\twatch: {\n\t\tvalue(newValue) {\n\t\t\tif (this.checkPasswordStrength) {\n\t\t\t\tif (passwordPolicy === null) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.checkPassword(newValue)\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Focus the input element\n\t\t *\n\t\t * @public\n\t\t */\n\t\tfocus() {\n\t\t\tthis.$refs.inputField.focus()\n\t\t},\n\n\t\t/**\n\t\t * Select all the text in the input\n\t\t *\n\t\t * @public\n\t\t */\n\t\tselect() {\n\t\t\tthis.$refs.inputField.select()\n\t\t},\n\n\t\thandleInput(event) {\n\t\t\t/**\n\t\t\t * Triggers when the value inside the password field is\n\t\t\t * updated.\n\t\t\t *\n\t\t\t * @property {string} The new value\n\t\t\t */\n\t\t\tthis.$emit('update:value', event.target.value)\n\t\t},\n\t\ttogglePasswordVisibility() {\n\t\t\tthis.isPasswordHidden = !this.isPasswordHidden\n\t\t},\n\t\tcheckPassword: debounce(async function(password) {\n\t\t\ttry {\n\t\t\t\tconst { data } = await axios.post(generateOcsUrl('apps/password_policy/api/v1/validate'), { password })\n\t\t\t\tthis.isValid = data.ocs.data.passed\n\t\t\t\tif (data.ocs.data.passed) {\n\t\t\t\t\tthis.internalHelpMessage = t('Password is secure')\n\t\t\t\t\t/**\n\t\t\t\t\t * Triggers when the internal password_policy detect that the\n\t\t\t\t\t * password entered is valid.\n\t\t\t\t\t */\n\t\t\t\t\tthis.$emit('valid')\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tthis.internalHelpMessage = data.ocs.data.reason\n\t\t\t\t/**\n\t\t\t\t * Triggers when the internal password_policy detect that the\n\t\t\t\t * password entered is invalid.\n\t\t\t\t */\n\t\t\t\tthis.$emit('invalid')\n\t\t\t} catch (e) {\n\t\t\t\tlogger.error('Password policy returned an error', e)\n\t\t\t}\n\t\t}, 500),\n\t},\n}\n</script>\n"],"names":["passwordPolicy","loadState","NcInputFieldProps","NcInputField","_sfc_main","Eye","EyeOff","minlength","t","key","newValue","event","debounce","password","data","axios","generateOcsUrl","logger"],"mappings":";;;;;;;;;;AA+IA,MAAAA,IAAAC,EAAA,QAAA,gBAAA,CAAA,CAAA,EAAA,mBAAA,MAEAC,IAAA,IAAA,IAAA,OAAA,KAAAC,EAAA,KAAA,CAAA,GAEAC,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,cAAAD;AAAA,IACA,KAAAE;AAAA,IACA,QAAAC;AAAA,EACA;AAAA;AAAA,EAGA,cAAA;AAAA,EAEA,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,KAAA,CAAA;AAAA;AAAA,IAGA,GAAAH,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,oBAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA,IAIA,qBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AAA;AAAA,MACA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,QAAA;AACA,WAAA,MAAA,WAAA,MAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,SAAA;AACA,WAAA,MAAA,WAAA,OAAA;AAAA,IACA;AAAA,IAEA,YAAAC,GAAA;AAOA,WAAA,MAAA,gBAAAA,EAAA,OAAA,KAAA;AAAA,IACA;AAAA,IACA,2BAAA;AACA,WAAA,mBAAA,CAAA,KAAA;AAAA,IACA;AAAA,IACA,eAAAC,EAAA,eAAAC,GAAA;AACA,UAAA;AACA,cAAA,EAAA,MAAAC,MAAA,MAAAC,EAAA,KAAAC,EAAA,sCAAA,GAAA,EAAA,UAAAH,GAAA;AAEA,YADA,KAAA,UAAAC,EAAA,IAAA,KAAA,QACAA,EAAA,IAAA,KAAA,QAAA;AACA,eAAA,sBAAAN,EAAA,oBAAA,GAKA,KAAA,MAAA,OAAA;AACA;AAAA,QACA;AAEA,aAAA,sBAAAM,EAAA,IAAA,KAAA,QAKA,KAAA,MAAA,SAAA;AAAA,MACA,SAAA,GAAA;AACA,QAAAG,EAAA,MAAA,qCAAA,CAAA;AAAA,MACA;AAAA,IACA,GAAA,GAAA;AAAA,EACA;AACA;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var I = require("../assets/index-
|
|
2
|
-
const o = require("@nextcloud/axios"),
|
|
1
|
+
var I = require("../assets/index-e828b286.css");
|
|
2
|
+
const o = require("@nextcloud/axios"), l = require("@nextcloud/router"), a = require("./NcButton.cjs"), s = require("../chunks/l10n-b1d264c7.cjs"), i = require("../chunks/_plugin-vue2_normalizer-7f9efb60.cjs"), u = (r) => r && r.__esModule ? r : { default: r }, c = /* @__PURE__ */ u(o);
|
|
3
3
|
const d = {
|
|
4
4
|
name: "NcResource",
|
|
5
5
|
components: {
|
|
6
|
-
NcButton:
|
|
6
|
+
NcButton: a
|
|
7
7
|
},
|
|
8
8
|
props: {
|
|
9
9
|
icon: {
|
|
@@ -33,7 +33,7 @@ var _ = function() {
|
|
|
33
33
|
return t("li", { staticClass: "resource" }, [t("NcButton", { staticClass: "resource__button", attrs: { "aria-label": e.labelTranslated, type: "tertiary", href: e.url }, scopedSlots: e._u([{ key: "icon", fn: function() {
|
|
34
34
|
return [t("div", { staticClass: "resource__icon" }, [t("img", { attrs: { src: e.icon } })])];
|
|
35
35
|
}, proxy: !0 }]) }, [e._v(" " + e._s(e.name) + " ")])], 1);
|
|
36
|
-
}, f = [],
|
|
36
|
+
}, f = [], p = /* @__PURE__ */ i.normalizeComponent(
|
|
37
37
|
d,
|
|
38
38
|
_,
|
|
39
39
|
f,
|
|
@@ -43,11 +43,11 @@ var _ = function() {
|
|
|
43
43
|
null,
|
|
44
44
|
null
|
|
45
45
|
);
|
|
46
|
-
const
|
|
46
|
+
const h = p.exports;
|
|
47
47
|
const m = {
|
|
48
48
|
name: "NcRelatedResourcesPanel",
|
|
49
49
|
components: {
|
|
50
|
-
NcResource:
|
|
50
|
+
NcResource: h
|
|
51
51
|
},
|
|
52
52
|
props: {
|
|
53
53
|
/**
|
|
@@ -64,6 +64,20 @@ const m = {
|
|
|
64
64
|
type: [String, Number],
|
|
65
65
|
default: null
|
|
66
66
|
},
|
|
67
|
+
/**
|
|
68
|
+
* Limits to specific resource type. i.e. any provider id implemented with `\OCA\RelatedResources\IRelatedResourceProvider::getProviderId()`
|
|
69
|
+
*/
|
|
70
|
+
resourceType: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: null
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Set the maximum number of resources to load
|
|
76
|
+
*/
|
|
77
|
+
limit: {
|
|
78
|
+
type: Number,
|
|
79
|
+
default: null
|
|
80
|
+
},
|
|
67
81
|
/**
|
|
68
82
|
* Only used by the files sidebar
|
|
69
83
|
*
|
|
@@ -105,9 +119,11 @@ const m = {
|
|
|
105
119
|
},
|
|
106
120
|
url() {
|
|
107
121
|
let r = null, e = null;
|
|
108
|
-
return this.isFiles ? (r = "files", e = this.fileInfo.id) : (r = this.providerId, e = this.itemId),
|
|
122
|
+
return this.isFiles ? (r = "files", e = this.fileInfo.id) : (r = this.providerId, e = this.itemId), l.generateOcsUrl("/apps/related_resources/related/{providerId}?itemId={itemId}&resourceType={resourceType}&limit={limit}&format=json", {
|
|
109
123
|
providerId: r,
|
|
110
|
-
itemId: e
|
|
124
|
+
itemId: e,
|
|
125
|
+
resourceType: this.resourceType,
|
|
126
|
+
limit: this.limit
|
|
111
127
|
});
|
|
112
128
|
}
|
|
113
129
|
},
|
|
@@ -149,20 +165,20 @@ const m = {
|
|
|
149
165
|
}
|
|
150
166
|
}
|
|
151
167
|
};
|
|
152
|
-
var
|
|
168
|
+
var y = function() {
|
|
153
169
|
var e = this, t = e._self._c;
|
|
154
170
|
return e.appEnabled && e.isVisible ? t("div", { staticClass: "related-resources" }, [t("div", { staticClass: "related-resources__header" }, [t("h5", [e._v(e._s(e.headerTranslated))]), t("p", [e._v(e._s(e.description))])]), e._l(e.resources, function(n) {
|
|
155
171
|
return t("NcResource", { key: n.itemId, staticClass: "related-resources__entry", attrs: { icon: n.icon, name: n.title, url: n.url } });
|
|
156
172
|
})], 2) : e._e();
|
|
157
|
-
},
|
|
173
|
+
}, v = [], R = /* @__PURE__ */ i.normalizeComponent(
|
|
158
174
|
m,
|
|
175
|
+
y,
|
|
159
176
|
v,
|
|
160
|
-
R,
|
|
161
177
|
!1,
|
|
162
178
|
null,
|
|
163
|
-
"
|
|
179
|
+
"01cfeb01",
|
|
164
180
|
null,
|
|
165
181
|
null
|
|
166
182
|
);
|
|
167
|
-
const g =
|
|
183
|
+
const g = R.exports;
|
|
168
184
|
module.exports = g;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NcRelatedResourcesPanel.cjs","sources":["../../src/components/NcRelatedResourcesPanel/NcResource.vue","../../src/components/NcRelatedResourcesPanel/NcRelatedResourcesPanel.vue"],"sourcesContent":["<!--\n - @copyright 2022 Christopher Ng <chrng8@gmail.com>\n -\n - @author Christopher Ng <chrng8@gmail.com>\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<template>\n\t<li class=\"resource\">\n\t\t<NcButton class=\"resource__button\"\n\t\t\t:aria-label=\"labelTranslated\"\n\t\t\ttype=\"tertiary\"\n\t\t\t:href=\"url\">\n\t\t\t<template #icon>\n\t\t\t\t<div class=\"resource__icon\">\n\t\t\t\t\t<img :src=\"icon\">\n\t\t\t\t</div>\n\t\t\t</template>\n\t\t\t{{ name }}\n\t\t</NcButton>\n\t</li>\n</template>\n\n<script>\nimport NcButton from '../NcButton/index.js'\n\nimport { t } from '../../l10n.js'\n\nexport default {\n\tname: 'NcResource',\n\n\tcomponents: {\n\t\tNcButton,\n\t},\n\n\tprops: {\n\t\ticon: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tname: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\turl: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\tlabelTranslated: t('Open link to \"{resourceName}\"', { resourceName: this.name }),\n\t\t}\n\t},\n\n\tmethods: {\n\t\tt,\n\t},\n}\n</script>\n\n<style lang=\"scss\" scoped>\n.resource {\n\tdisplay: flex;\n\talign-items: center;\n\theight: 44px;\n\n\t// Override default NcButton styles\n\t&__button {\n\t\twidth: 100% !important;\n\t\tjustify-content: flex-start !important;\n\t\tpadding: 0 !important;\n\n\t\t&:deep {\n\t\t\t.button-vue__wrapper {\n\t\t\t\tjustify-content: flex-start !important;\n\n\t\t\t\t.button-vue__text {\n\t\t\t\t\tfont-weight: normal !important;\n\t\t\t\t\tmargin-left: 2px !important;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t&__icon {\n\t\twidth: 32px;\n\t\theight: 32px;\n\t\tbackground-color: var(--color-text-maxcontrast);\n\t\tborder-radius: 50%;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\n\t\timg {\n\t\t\twidth: 16px;\n\t\t\theight: 16px;\n\t\t\tfilter: var(--background-invert-if-dark);\n\t\t}\n\t}\n}\n</style>\n","<!--\n - @copyright 2022 Christopher Ng <chrng8@gmail.com>\n -\n - @author Christopher Ng <chrng8@gmail.com>\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### Usage\n\nUse this component to display the related resources of a given item.\n\n```\n<template>\n\t<NcRelatedResourcesPanel provider-id=\"talk\"\n\t\t:item-id=\"conversationId\" />\n</template>\n\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tconversationId: 1,\n\t\t}\n\t},\n}\n</script>\n```\n</docs>\n\n<template>\n\t<div v-if=\"appEnabled && isVisible\" class=\"related-resources\">\n\t\t<div class=\"related-resources__header\">\n\t\t\t<h5>{{ headerTranslated }}</h5>\n\t\t\t<p>{{ description }}</p>\n\t\t</div>\n\n\t\t<NcResource v-for=\"resource in resources\"\n\t\t\t:key=\"resource.itemId\"\n\t\t\tclass=\"related-resources__entry\"\n\t\t\t:icon=\"resource.icon\"\n\t\t\t:name=\"resource.title\"\n\t\t\t:url=\"resource.url\" />\n\t</div>\n</template>\n\n<script>\nimport axios from '@nextcloud/axios'\nimport { generateOcsUrl } from '@nextcloud/router'\n\nimport NcResource from './NcResource.vue'\n\nimport { t } from '../../l10n.js'\n\nexport default {\n\tname: 'NcRelatedResourcesPanel',\n\n\tcomponents: {\n\t\tNcResource,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The provider id implemented with `\\OCA\\RelatedResources\\IRelatedResourceProvider::getProviderId()`\n\t\t */\n\t\tproviderId: {\n\t\t\ttype: String,\n\t\t\tdefault: null,\n\t\t},\n\t\t/**\n\t\t * The item id which uniquely identities the e.g. Calendar event, Deck board, file, Talk room, etc.\n\t\t */\n\t\titemId: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: null,\n\t\t},\n\t\t/**\n\t\t * Only used by the files sidebar\n\t\t *\n\t\t * File info is passed when registered with `OCA.Sharing.ShareTabSections.registerSection()`\n\t\t */\n\t\tfileInfo: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\temits: [\n\t\t'has-error',\n\t\t'has-resources',\n\t],\n\n\tdata() {\n\t\treturn {\n\t\t\tappEnabled: OC?.appswebroots?.related_resources !== undefined,\n\t\t\theaderTranslated: t('Related resources'),\n\t\t\tloading: false,\n\t\t\terror: null,\n\t\t\tresources: [],\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tisVisible() {\n\t\t\tif (this.loading) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn this.error ?? this.resources.length > 0\n\t\t},\n\n\t\tdescription() {\n\t\t\tif (this.error) {\n\t\t\t\treturn t('Error getting related resources. Please contact your system administrator if you have any questions.')\n\t\t\t}\n\t\t\treturn t('Anything shared with the same group of people will show up here')\n\t\t},\n\n\t\thasResourceInfo() {\n\t\t\tif (this.providerId !== null && this.itemId !== null) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (this.fileInfo !== null) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn false\n\t\t},\n\n\t\tisFiles() {\n\t\t\treturn this.fileInfo?.id !== undefined\n\t\t},\n\n\t\turl() {\n\t\t\tlet providerId = null\n\t\t\tlet itemId = null\n\n\t\t\tif (this.isFiles) {\n\t\t\t\tproviderId = 'files'\n\t\t\t\titemId = this.fileInfo.id\n\t\t\t} else {\n\t\t\t\tproviderId = this.providerId\n\t\t\t\titemId = this.itemId\n\t\t\t}\n\n\t\t\treturn generateOcsUrl('/apps/related_resources/related/{providerId}?itemId={itemId}&format=json', {\n\t\t\t\tproviderId,\n\t\t\t\titemId,\n\t\t\t})\n\t\t},\n\t},\n\n\twatch: {\n\t\tproviderId() {\n\t\t\tthis.fetchRelatedResources()\n\t\t},\n\t\titemId() {\n\t\t\tthis.fetchRelatedResources()\n\t\t},\n\t\tfileInfo() {\n\t\t\tthis.fetchRelatedResources()\n\t\t},\n\t\terror(error) {\n\t\t\t/**\n\t\t\t * Emitted when the error value changes\n\t\t\t *\n\t\t\t * @type {boolean}\n\t\t\t */\n\t\t\tthis.$emit('has-error', Boolean(error))\n\t\t},\n\t\tresources(resources) {\n\t\t\t/**\n\t\t\t * Emitted when the resources value changes\n\t\t\t *\n\t\t\t * @type {boolean}\n\t\t\t */\n\t\t\tthis.$emit('has-resources', resources.length > 0)\n\t\t},\n\t},\n\n\tcreated() {\n\t\tthis.fetchRelatedResources()\n\t},\n\n\tmethods: {\n\t\tt,\n\t\tasync fetchRelatedResources() {\n\t\t\tif (!this.appEnabled || !this.hasResourceInfo) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.loading = true\n\t\t\tthis.error = null\n\t\t\tthis.resources = []\n\t\t\ttry {\n\t\t\t\tconst response = await axios.get(this.url)\n\t\t\t\tthis.resources = response.data.ocs?.data\n\t\t\t} catch (e) {\n\t\t\t\tthis.error = e\n\t\t\t\tconsole.error(e)\n\t\t\t} finally {\n\t\t\t\tthis.loading = false\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style lang=\"scss\" scoped>\n.related-resources {\n\t&__header {\n\t\tmargin: 0 0 10px 46px;\n\n\t\th5 {\n\t\t\tfont-weight: bold;\n\t\t}\n\n\t\tp {\n\t\t\tcolor: var(--color-text-maxcontrast);\n\t\t}\n\t}\n}\n</style>\n"],"names":["_sfc_main$1","Components_NcButton","l10n","_sfc_main","NcResource","_a","providerId","itemId","router","error","resources","response","axios__default"],"mappings":";;AA2CA,MAAAA,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,UAAAC;AAAA,EACA;AAAA,EAEA,OAAA;AAAA,IACA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,IACA;AAAA,IACA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,IACA;AAAA,IACA,KAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AACA,WAAA;AAAA,MACA,iBAAAC,EAAA,EAAA,iCAAA,EAAA,cAAA,KAAA,KAAA,CAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,SAAA;AAAA,IACA,GAAAA,EAAA;AAAA,EACA;AACA;;;;;;;;;;;;;;;;;ACLA,MAAAC,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,YAAAC;AAAA,EACA;AAAA,EAEA,OAAA;AAAA;AAAA;AAAA;AAAA,IAIA,YAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAIA,QAAA;AAAA,MACA,MAAA,CAAA,QAAA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,UAAA;AAAA,MACA,MAAA;AAAA,MACA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A,EACA;AAAA,EAEA,UAAA;AACA,SAAA,sBAAA;AAAA,EACA;AAAA,EAEA,SAAA;AAAA,IACA,GAAAR,EAAA;AAAA,IACA,MAAA,wBAAA;;AACA,UAAA,GAAA,KAAA,cAAA,CAAA,KAAA,kBAIA;AAAA,aAAA,UAAA,IACA,KAAA,QAAA,MACA,KAAA,YAAA,CAAA;AACA,YAAA;AACA,gBAAAS,IAAA,MAAAC,EAAA,QAAA,IAAA,KAAA,GAAA;AACA,eAAA,aAAAP,IAAAM,EAAA,KAAA,QAAA,gBAAAN,EAAA;AAAA,QACA,SAAA,GAAA;AACA,eAAA,QAAA,GACA,QAAA,MAAA,CAAA;AAAA,QACA,UAAA;AACA,eAAA,UAAA;AAAA,QACA;AAAA;AAAA,IACA;AAAA,EACA;AACA;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"NcRelatedResourcesPanel.cjs","sources":["../../src/components/NcRelatedResourcesPanel/NcResource.vue","../../src/components/NcRelatedResourcesPanel/NcRelatedResourcesPanel.vue"],"sourcesContent":["<!--\n - @copyright 2022 Christopher Ng <chrng8@gmail.com>\n -\n - @author Christopher Ng <chrng8@gmail.com>\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<template>\n\t<li class=\"resource\">\n\t\t<NcButton class=\"resource__button\"\n\t\t\t:aria-label=\"labelTranslated\"\n\t\t\ttype=\"tertiary\"\n\t\t\t:href=\"url\">\n\t\t\t<template #icon>\n\t\t\t\t<div class=\"resource__icon\">\n\t\t\t\t\t<img :src=\"icon\">\n\t\t\t\t</div>\n\t\t\t</template>\n\t\t\t{{ name }}\n\t\t</NcButton>\n\t</li>\n</template>\n\n<script>\nimport NcButton from '../NcButton/index.js'\n\nimport { t } from '../../l10n.js'\n\nexport default {\n\tname: 'NcResource',\n\n\tcomponents: {\n\t\tNcButton,\n\t},\n\n\tprops: {\n\t\ticon: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tname: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\turl: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\tlabelTranslated: t('Open link to \"{resourceName}\"', { resourceName: this.name }),\n\t\t}\n\t},\n\n\tmethods: {\n\t\tt,\n\t},\n}\n</script>\n\n<style lang=\"scss\" scoped>\n.resource {\n\tdisplay: flex;\n\talign-items: center;\n\theight: 44px;\n\n\t// Override default NcButton styles\n\t&__button {\n\t\twidth: 100% !important;\n\t\tjustify-content: flex-start !important;\n\t\tpadding: 0 !important;\n\n\t\t&:deep {\n\t\t\t.button-vue__wrapper {\n\t\t\t\tjustify-content: flex-start !important;\n\n\t\t\t\t.button-vue__text {\n\t\t\t\t\tfont-weight: normal !important;\n\t\t\t\t\tmargin-left: 2px !important;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t&__icon {\n\t\twidth: 32px;\n\t\theight: 32px;\n\t\tbackground-color: var(--color-text-maxcontrast);\n\t\tborder-radius: 50%;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\n\t\timg {\n\t\t\twidth: 16px;\n\t\t\theight: 16px;\n\t\t\tfilter: var(--background-invert-if-dark);\n\t\t}\n\t}\n}\n</style>\n","<!--\n - @copyright 2022 Christopher Ng <chrng8@gmail.com>\n -\n - @author Christopher Ng <chrng8@gmail.com>\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### Usage\n\nUse this component to display the related resources of a given item.\n\n```\n<template>\n\t<NcRelatedResourcesPanel provider-id=\"talk\"\n\t\t:item-id=\"conversationId\" />\n</template>\n\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tconversationId: 1,\n\t\t}\n\t},\n}\n</script>\n```\n</docs>\n\n<template>\n\t<div v-if=\"appEnabled && isVisible\" class=\"related-resources\">\n\t\t<div class=\"related-resources__header\">\n\t\t\t<h5>{{ headerTranslated }}</h5>\n\t\t\t<p>{{ description }}</p>\n\t\t</div>\n\n\t\t<NcResource v-for=\"resource in resources\"\n\t\t\t:key=\"resource.itemId\"\n\t\t\tclass=\"related-resources__entry\"\n\t\t\t:icon=\"resource.icon\"\n\t\t\t:name=\"resource.title\"\n\t\t\t:url=\"resource.url\" />\n\t</div>\n</template>\n\n<script>\nimport axios from '@nextcloud/axios'\nimport { generateOcsUrl } from '@nextcloud/router'\n\nimport NcResource from './NcResource.vue'\n\nimport { t } from '../../l10n.js'\n\nexport default {\n\tname: 'NcRelatedResourcesPanel',\n\n\tcomponents: {\n\t\tNcResource,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The provider id implemented with `\\OCA\\RelatedResources\\IRelatedResourceProvider::getProviderId()`\n\t\t */\n\t\tproviderId: {\n\t\t\ttype: String,\n\t\t\tdefault: null,\n\t\t},\n\t\t/**\n\t\t * The item id which uniquely identities the e.g. Calendar event, Deck board, file, Talk room, etc.\n\t\t */\n\t\titemId: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: null,\n\t\t},\n\t\t/**\n\t\t * Limits to specific resource type. i.e. any provider id implemented with `\\OCA\\RelatedResources\\IRelatedResourceProvider::getProviderId()`\n\t\t */\n\t\tresourceType: {\n\t\t\ttype: String,\n\t\t\tdefault: null,\n\t\t},\n\t\t/**\n\t\t * Set the maximum number of resources to load\n\t\t */\n\t\tlimit: {\n\t\t\ttype: Number,\n\t\t\tdefault: null,\n\t\t},\n\t\t/**\n\t\t * Only used by the files sidebar\n\t\t *\n\t\t * File info is passed when registered with `OCA.Sharing.ShareTabSections.registerSection()`\n\t\t */\n\t\tfileInfo: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\temits: [\n\t\t'has-error',\n\t\t'has-resources',\n\t],\n\n\tdata() {\n\t\treturn {\n\t\t\tappEnabled: OC?.appswebroots?.related_resources !== undefined,\n\t\t\theaderTranslated: t('Related resources'),\n\t\t\tloading: false,\n\t\t\terror: null,\n\t\t\tresources: [],\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tisVisible() {\n\t\t\tif (this.loading) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn this.error ?? this.resources.length > 0\n\t\t},\n\n\t\tdescription() {\n\t\t\tif (this.error) {\n\t\t\t\treturn t('Error getting related resources. Please contact your system administrator if you have any questions.')\n\t\t\t}\n\t\t\treturn t('Anything shared with the same group of people will show up here')\n\t\t},\n\n\t\thasResourceInfo() {\n\t\t\tif (this.providerId !== null && this.itemId !== null) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (this.fileInfo !== null) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn false\n\t\t},\n\n\t\tisFiles() {\n\t\t\treturn this.fileInfo?.id !== undefined\n\t\t},\n\n\t\turl() {\n\t\t\tlet providerId = null\n\t\t\tlet itemId = null\n\n\t\t\tif (this.isFiles) {\n\t\t\t\tproviderId = 'files'\n\t\t\t\titemId = this.fileInfo.id\n\t\t\t} else {\n\t\t\t\tproviderId = this.providerId\n\t\t\t\titemId = this.itemId\n\t\t\t}\n\n\t\t\treturn generateOcsUrl('/apps/related_resources/related/{providerId}?itemId={itemId}&resourceType={resourceType}&limit={limit}&format=json', {\n\t\t\t\tproviderId,\n\t\t\t\titemId,\n\t\t\t\tresourceType: this.resourceType,\n\t\t\t\tlimit: this.limit,\n\t\t\t})\n\t\t},\n\t},\n\n\twatch: {\n\t\tproviderId() {\n\t\t\tthis.fetchRelatedResources()\n\t\t},\n\t\titemId() {\n\t\t\tthis.fetchRelatedResources()\n\t\t},\n\t\tfileInfo() {\n\t\t\tthis.fetchRelatedResources()\n\t\t},\n\t\terror(error) {\n\t\t\t/**\n\t\t\t * Emitted when the error value changes\n\t\t\t *\n\t\t\t * @type {boolean}\n\t\t\t */\n\t\t\tthis.$emit('has-error', Boolean(error))\n\t\t},\n\t\tresources(resources) {\n\t\t\t/**\n\t\t\t * Emitted when the resources value changes\n\t\t\t *\n\t\t\t * @type {boolean}\n\t\t\t */\n\t\t\tthis.$emit('has-resources', resources.length > 0)\n\t\t},\n\t},\n\n\tcreated() {\n\t\tthis.fetchRelatedResources()\n\t},\n\n\tmethods: {\n\t\tt,\n\t\tasync fetchRelatedResources() {\n\t\t\tif (!this.appEnabled || !this.hasResourceInfo) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.loading = true\n\t\t\tthis.error = null\n\t\t\tthis.resources = []\n\t\t\ttry {\n\t\t\t\tconst response = await axios.get(this.url)\n\t\t\t\tthis.resources = response.data.ocs?.data\n\t\t\t} catch (e) {\n\t\t\t\tthis.error = e\n\t\t\t\tconsole.error(e)\n\t\t\t} finally {\n\t\t\t\tthis.loading = false\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style lang=\"scss\" scoped>\n.related-resources {\n\t&__header {\n\t\tmargin: 0 0 10px 46px;\n\n\t\th5 {\n\t\t\tfont-weight: bold;\n\t\t}\n\n\t\tp {\n\t\t\tcolor: var(--color-text-maxcontrast);\n\t\t}\n\t}\n}\n</style>\n"],"names":["_sfc_main$1","Components_NcButton","l10n","_sfc_main","NcResource","_a","providerId","itemId","router","error","resources","response","axios__default"],"mappings":";;AA2CA,MAAAA,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,UAAAC;AAAA,EACA;AAAA,EAEA,OAAA;AAAA,IACA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,IACA;AAAA,IACA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,IACA;AAAA,IACA,KAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AACA,WAAA;AAAA,MACA,iBAAAC,EAAA,EAAA,iCAAA,EAAA,cAAA,KAAA,KAAA,CAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,SAAA;AAAA,IACA,GAAAA,EAAA;AAAA,EACA;AACA;;;;;;;;;;;;;;;;;ACLA,MAAAC,IAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,YAAAC;AAAA,EACA;AAAA,EAEA,OAAA;AAAA;AAAA;AAAA;AAAA,IAIA,YAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAIA,QAAA;AAAA,MACA,MAAA,CAAA,QAAA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAIA,cAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAIA,OAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,UAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA,IACA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;;AACA,WAAA;AAAA,MACA,cAAAC,IAAA,yBAAA,iBA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