@demos-europe/demosplan-ui 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/LICENSE +21 -0
  2. package/buildTokens.js +59 -0
  3. package/components/DpButton/DpButton.stories.mdx +136 -0
  4. package/components/DpButton/DpButton.vue +118 -0
  5. package/components/DpDetails/DpDetails.stories.mdx +55 -0
  6. package/components/DpDetails/DpDetails.vue +58 -0
  7. package/components/DpIcon/DpIcon.stories.mdx +396 -0
  8. package/components/DpIcon/DpIcon.vue +51 -0
  9. package/components/DpIcon/util/iconVariables.js +148 -0
  10. package/components/DpInput/DpInput.stories.mdx +127 -0
  11. package/components/DpInput/DpInput.vue +284 -0
  12. package/components/DpLabel/DpLabel.stories.mdx +103 -0
  13. package/components/DpLabel/DpLabel.vue +112 -0
  14. package/components/DpLoading/DpLoading.stories.mdx +63 -0
  15. package/components/DpLoading/DpLoading.vue +63 -0
  16. package/components/core/DpAccordion.vue +108 -0
  17. package/components/core/DpAnonymizeText.vue +136 -0
  18. package/components/core/DpAutocomplete.vue +133 -0
  19. package/components/core/DpBulkEditHeader.vue +53 -0
  20. package/components/core/DpButtonIcon.vue +47 -0
  21. package/components/core/DpButtonRow.vue +155 -0
  22. package/components/core/DpCard.vue +54 -0
  23. package/components/core/DpChangeStateAtDate.vue +223 -0
  24. package/components/core/DpCheckboxGroup.vue +93 -0
  25. package/components/core/DpContextualHelp.vue +54 -0
  26. package/components/core/DpCopyPasteButton.vue +47 -0
  27. package/components/core/DpDashboardTaskCard.vue +123 -0
  28. package/components/core/DpDataTable/DataTableSearch.js +44 -0
  29. package/components/core/DpDataTable/DpColumnSelector.vue +133 -0
  30. package/components/core/DpDataTable/DpDataTable.vue +647 -0
  31. package/components/core/DpDataTable/DpDataTableExtended.vue +377 -0
  32. package/components/core/DpDataTable/DpResizeHandle.vue +37 -0
  33. package/components/core/DpDataTable/DpSelectPageItemCount.vue +70 -0
  34. package/components/core/DpDataTable/DpTableHeader.vue +197 -0
  35. package/components/core/DpDataTable/DpTableRow.vue +355 -0
  36. package/components/core/DpDataTable/DpWrapTrigger.vue +48 -0
  37. package/components/core/DpDataTable/lib/ResizableColumns.js +83 -0
  38. package/components/core/DpEditableList.vue +161 -0
  39. package/components/core/DpEditor/DpBoilerPlate.vue +140 -0
  40. package/components/core/DpEditor/DpBoilerPlateModal.vue +166 -0
  41. package/components/core/DpEditor/DpEditor.vue +1281 -0
  42. package/components/core/DpEditor/DpLinkModal.vue +117 -0
  43. package/components/core/DpEditor/DpRecommendationModal/DpInsertableRecommendation.vue +137 -0
  44. package/components/core/DpEditor/DpRecommendationModal.vue +283 -0
  45. package/components/core/DpEditor/DpResizableImage.vue +121 -0
  46. package/components/core/DpEditor/DpUploadModal.vue +121 -0
  47. package/components/core/DpEditor/libs/Decoration.js +66 -0
  48. package/components/core/DpEditor/libs/SegmentRangeChangePlugin.js +35 -0
  49. package/components/core/DpEditor/libs/editorAnonymize.js +66 -0
  50. package/components/core/DpEditor/libs/editorBuildSuggestion.js +269 -0
  51. package/components/core/DpEditor/libs/editorCustomDelete.js +32 -0
  52. package/components/core/DpEditor/libs/editorCustomImage.js +100 -0
  53. package/components/core/DpEditor/libs/editorCustomInsert.js +32 -0
  54. package/components/core/DpEditor/libs/editorCustomLink.js +46 -0
  55. package/components/core/DpEditor/libs/editorCustomMark.js +32 -0
  56. package/components/core/DpEditor/libs/editorInsertAtCursorPos.js +41 -0
  57. package/components/core/DpEditor/libs/editorObscure.js +60 -0
  58. package/components/core/DpEditor/libs/editorUnAnonymize.js +56 -0
  59. package/components/core/DpEditor/libs/handleWordPaste.js +360 -0
  60. package/components/core/DpEditor/libs/preventDrop.js +31 -0
  61. package/components/core/DpEditor/libs/preventKeyboardInput.js +27 -0
  62. package/components/core/DpEditor/libs/preventPaste.js +28 -0
  63. package/components/core/DpFlyout.vue +119 -0
  64. package/components/core/DpInlineNotification.vue +116 -0
  65. package/components/core/DpModal.vue +208 -0
  66. package/components/core/DpObscure.vue +29 -0
  67. package/components/core/DpPager.vue +139 -0
  68. package/components/core/DpProgressBar.vue +67 -0
  69. package/components/core/DpRegisterFlyout.vue +58 -0
  70. package/components/core/DpResettableInput.vue +140 -0
  71. package/components/core/DpSkeletonBox.vue +32 -0
  72. package/components/core/DpSlidebar.vue +86 -0
  73. package/components/core/DpSlidingPagination.vue +45 -0
  74. package/components/core/DpSplitButton.vue +77 -0
  75. package/components/core/DpSwitcher.vue +62 -0
  76. package/components/core/DpTableCardList/DpTableCard.vue +61 -0
  77. package/components/core/DpTableCardList/DpTableCardListHeader.vue +83 -0
  78. package/components/core/DpTabs/DpTab.vue +52 -0
  79. package/components/core/DpTabs/DpTabs.vue +165 -0
  80. package/components/core/DpTextWrapper.vue +65 -0
  81. package/components/core/DpToggleForm.vue +72 -0
  82. package/components/core/DpTooltipIcon.vue +52 -0
  83. package/components/core/DpTransitionExpand.vue +87 -0
  84. package/components/core/DpTreeList/DpTreeList.vue +334 -0
  85. package/components/core/DpTreeList/DpTreeListCheckbox.vue +79 -0
  86. package/components/core/DpTreeList/DpTreeListNode.vue +348 -0
  87. package/components/core/DpTreeList/DpTreeListToggle.vue +71 -0
  88. package/components/core/DpTreeList/utils/constants.js +14 -0
  89. package/components/core/DpUpload/DpUpload.vue +223 -0
  90. package/components/core/DpUpload/DpUploadFiles.vue +269 -0
  91. package/components/core/DpUpload/DpUploadedFile.vue +80 -0
  92. package/components/core/DpUpload/DpUploadedFileList.vue +56 -0
  93. package/components/core/DpUpload/utils/GetFileIdsByHash.js +42 -0
  94. package/components/core/DpUpload/utils/UppyTranslations.js +31 -0
  95. package/components/core/DpVideoPlayer.vue +115 -0
  96. package/components/core/HeightLimit.vue +121 -0
  97. package/components/core/MultistepNav.vue +89 -0
  98. package/components/core/form/DpCheckbox.vue +108 -0
  99. package/components/core/form/DpDateRangePicker.vue +186 -0
  100. package/components/core/form/DpDatepicker.vue +160 -0
  101. package/components/core/form/DpDatetimePicker.vue +194 -0
  102. package/components/core/form/DpFormRow.vue +79 -0
  103. package/components/core/form/DpMultiselect.vue +164 -0
  104. package/components/core/form/DpRadio.vue +128 -0
  105. package/components/core/form/DpSearchField.vue +110 -0
  106. package/components/core/form/DpSelect.vue +149 -0
  107. package/components/core/form/DpTextArea.vue +152 -0
  108. package/components/core/form/DpTimePicker.vue +374 -0
  109. package/components/core/form/DpToggle.vue +78 -0
  110. package/components/core/index.js +132 -0
  111. package/components/core/notify/DpNotifyContainer.vue +122 -0
  112. package/components/core/notify/DpNotifyMessage.vue +95 -0
  113. package/components/core/shared/DpStickyElement.vue +95 -0
  114. package/components/index.js +24 -0
  115. package/components/shared/translations.js +15 -0
  116. package/directives/CleanHtml/CleanHtml.js +50 -0
  117. package/directives/CleanHtml/CleanHtml.stories.mdx +64 -0
  118. package/directives/Tooltip/Tooltip.js +40 -0
  119. package/directives/Tooltip/Tooltip.stories.mdx +42 -0
  120. package/directives/index.js +17 -0
  121. package/lib/index.js +14 -0
  122. package/lib/prefixClass.js +47 -0
  123. package/mixins/index.js +14 -0
  124. package/mixins/prefixClassMixin.js +22 -0
  125. package/package.json +52 -0
  126. package/shared/props.js +86 -0
  127. package/style/index.css +7 -0
  128. package/tailwind.config.js +24 -0
  129. package/tokens/color.json +358 -0
  130. package/tokens/color.stories.mdx +45 -0
  131. package/tokens/fontSize.json +100 -0
  132. package/tokens/space.json +33 -0
  133. package/utils/lengthHint.js +69 -0
@@ -0,0 +1,334 @@
1
+ <license>
2
+ (c) 2010-present DEMOS E-Partizipation GmbH.
3
+
4
+ This file is part of the package @demos-europe/demosplan-ui,
5
+ for more information see the license file.
6
+
7
+ All rights reserved
8
+ </license>
9
+
10
+ <template>
11
+ <div
12
+ class="c-treelist"
13
+ :class="{ 'is-dragging': dragging }">
14
+ <!-- Header -->
15
+ <div
16
+ ref="header"
17
+ class="c-treelist__header o-sticky line-height--2"
18
+ :class="{ 'has-checkbox': checkAll }">
19
+ <div class="flex bg-color--white">
20
+ <dp-tree-list-checkbox
21
+ v-if="checkAll"
22
+ name="checkAll"
23
+ v-model="allElementsSelected"
24
+ check-all
25
+ :style="checkboxIndentationStyle" />
26
+ <div class="flex-grow color--grey">
27
+ <slot name="header" />
28
+ </div>
29
+ <dp-tree-list-toggle
30
+ class="color--grey"
31
+ @input="toggleAll"
32
+ :value="allElementsExpanded"
33
+ toggle-all />
34
+ </div>
35
+ </div>
36
+
37
+ <!-- Tree List -->
38
+ <draggable
39
+ ref="treeList"
40
+ v-model="tree"
41
+ v-bind="opts.draggable"
42
+ class="list-style-none u-mb-0 u-1-of-1"
43
+ :disabled="false === draggable"
44
+ :group="true === opts.dragAcrossBranches ? 'treelistgroup' : 'noIdGiven'"
45
+ :move="onMove"
46
+ tag="ul"
47
+ @end="handleDrag('end')"
48
+ @start="handleDrag('start')"
49
+ @change="(action) => handleChange(action, null)">
50
+ <dp-tree-list-node
51
+ v-for="node in treeData"
52
+ :ref="`node_${node.id}`"
53
+ :key="node.id"
54
+ :check-branch="branchIdentifier"
55
+ :children="node.children || []"
56
+ :draggable="draggable"
57
+ :handle-change="handleChange"
58
+ :handle-drag="handleDrag"
59
+ :level="0"
60
+ :node="node"
61
+ :node-id="node.id"
62
+ :on-move="onMove"
63
+ :options="opts"
64
+ :parent-selected="allElementsSelected"
65
+ @draggable-change="bubbleDraggableChange"
66
+ @end="handleDrag('end')"
67
+ @node-selected="handleSelectEvent"
68
+ @start="handleDrag('start')"
69
+ @tree-data-change="bubbleChangeEvent">
70
+ <template
71
+ v-for="slot in Object.keys($scopedSlots)"
72
+ v-slot:[slot]="scope">
73
+ <slot
74
+ :name="slot"
75
+ v-bind="scope" />
76
+ </template>
77
+ </dp-tree-list-node>
78
+ </draggable>
79
+
80
+ <!-- Footer -->
81
+ <div
82
+ v-if="$slots['footer']"
83
+ ref="footer"
84
+ class="c-treelist__footer o-sticky">
85
+ <div class="u-p-0_5 bg-color--white">
86
+ <slot name="footer" />
87
+ </div>
88
+ </div>
89
+ </div>
90
+ </template>
91
+
92
+ <script>
93
+ import { deepMerge, hasOwnProp, Stickier } from 'demosplan-utils'
94
+ import DpTreeListCheckbox from './DpTreeListCheckbox'
95
+ import DpTreeListNode from './DpTreeListNode'
96
+ import DpTreeListToggle from './DpTreeListToggle'
97
+ import draggable from 'vuedraggable'
98
+ import { dragHandleWidth } from './utils/constants'
99
+
100
+ export default {
101
+ name: 'DpTreeList',
102
+
103
+ components: {
104
+ DpTreeListCheckbox,
105
+ DpTreeListNode,
106
+ DpTreeListToggle,
107
+ draggable
108
+ },
109
+
110
+ props: {
111
+ branchIdentifier: {
112
+ type: Function,
113
+ required: true
114
+ },
115
+
116
+ draggable: {
117
+ type: Boolean,
118
+ required: false,
119
+ default: true
120
+ },
121
+
122
+ /*
123
+ * Callback to be executed on move event of draggable.
124
+ * It can be used to cancel drag by returning false.
125
+ */
126
+ onMove: {
127
+ type: Function,
128
+ required: false,
129
+ default: () => true
130
+ },
131
+
132
+ options: {
133
+ type: Object,
134
+ required: false,
135
+ default: () => ({})
136
+ },
137
+
138
+ treeData: {
139
+ type: Array,
140
+ required: true
141
+ }
142
+ },
143
+
144
+ data () {
145
+ return {
146
+ allElementsExpanded: false,
147
+ allElementsSelected: false,
148
+
149
+ /*
150
+ * To be able to control the appearance of nodes when hovered vs. when dragged,
151
+ * the outermost container receives an `is-dragging` class if a node is dragged.
152
+ */
153
+ dragging: false,
154
+
155
+ opts: {},
156
+ selectedNodesObject: {}
157
+ }
158
+ },
159
+
160
+ computed: {
161
+ checkAll () {
162
+ return this.opts.branchesSelectable || this.opts.leavesSelectable
163
+ },
164
+
165
+ checkboxIndentationStyle () {
166
+ const margin = this.opts.dragBranches || this.opts.dragLeaves ? dragHandleWidth : 0
167
+ return `margin-left: ${margin}px;`
168
+ },
169
+
170
+ selectedNodes () {
171
+ return Object.keys(this.selectedNodesObject).map(id => this.selectedNodesObject[id])
172
+ },
173
+
174
+ /**
175
+ * The `tree` getter is called whenever this.treeData is changed from outside DpTreeList.
176
+ * The setter is called whenever the tree structure is changed from within the draggable instance.
177
+ * It emits the changed structure, which may be used in the parent component to update treeData accordingly.
178
+ */
179
+ tree: {
180
+ get () {
181
+ return this.treeData
182
+ },
183
+
184
+ set (val) {
185
+ this.$emit('tree-data-change', { nodeId: null, newOrder: val })
186
+ }
187
+ }
188
+ },
189
+
190
+ methods: {
191
+ bubbleChangeEvent (payload) {
192
+ this.$emit('tree-data-change', payload)
193
+ },
194
+
195
+ bubbleDraggableChange (payload) {
196
+ this.$emit('draggable-change', payload)
197
+ },
198
+
199
+ destroyFixedControls () {
200
+ this.stickyHeader.destroy()
201
+ this.stickyFooter.destroy()
202
+ },
203
+
204
+ filterSelectableNodes (selectedNodes) {
205
+ if (this.opts.branchesSelectable && this.opts.leavesSelectable) return selectedNodes
206
+
207
+ return selectedNodes.filter(({ nodeType }) => {
208
+ let nodeSelectable = false
209
+ if ((this.opts.branchesSelectable && nodeType === 'branch') ||
210
+ (this.opts.leavesSelectable && nodeType === 'leaf')) {
211
+ nodeSelectable = true
212
+ }
213
+
214
+ return nodeSelectable
215
+ })
216
+ },
217
+
218
+ /**
219
+ * Handler for the draggable `change` event.
220
+ * The change event fires whenever the order of items is changed by a drag interaction.
221
+ * The handler then emits an event that is being bubbled up the tree.
222
+ * @see https://github.com/SortableJS/Vue.Draggable#events
223
+ * @param action
224
+ * @param nodeId
225
+ * @emits draggable-change
226
+ */
227
+ handleChange (action, nodeId) {
228
+ // The event should only be emitted if an element is moved inside or into a folder.
229
+ if (hasOwnProp(action, 'added') || hasOwnProp(action, 'moved')) {
230
+ const { element, newIndex } = hasOwnProp(action, 'moved') ? action.moved : action.added
231
+ const payload = {
232
+ elementId: element.id,
233
+ newIndex: newIndex,
234
+ parentId: nodeId
235
+ }
236
+ this.$emit('draggable-change', payload)
237
+ }
238
+ },
239
+
240
+ /**
241
+ * Set `dragging` to true if called via `start` event of draggable, else to false.
242
+ * @param eventType
243
+ * @emits <start|end>
244
+ */
245
+ handleDrag (eventType) {
246
+ this.$emit(eventType)
247
+ this.dragging = (eventType === 'start')
248
+ },
249
+
250
+ handleSelectEvent (selections) {
251
+ const filteredSelections = this.filterSelectableNodes(selections)
252
+
253
+ filteredSelections.forEach(selection => this.setSelectionState(selection))
254
+
255
+ this.$emit('node-selection-change', this.selectedNodes)
256
+ },
257
+
258
+ // Header and Footer should be fixed to the top/bottom of the page when the TreeList exceeds the viewport height.
259
+ initFixedControls () {
260
+ this.stickyHeader = new Stickier(this.$refs.header, this.$refs.treeList.$el, 0)
261
+
262
+ if (this.$slots.footer) {
263
+ this.stickyFooter = new Stickier(this.$refs.footer, this.$refs.treeList.$el, 0, 'bottom')
264
+ }
265
+ },
266
+
267
+ setSelectionState (elem) {
268
+ if (elem.selectionState === true) {
269
+ this.selectedNodesObject = { ...this.selectedNodesObject, ...{ [elem.nodeId]: elem } }
270
+ }
271
+
272
+ if (elem.selectionState === false) {
273
+ const selectionCpy = { ...this.selectedNodesObject }
274
+ delete selectionCpy[elem.nodeId]
275
+ this.selectedNodesObject = selectionCpy
276
+ }
277
+ },
278
+
279
+ toggleAll () {
280
+ this.$root.$emit('treelist:toggle-all', !this.allElementsExpanded)
281
+ this.allElementsExpanded = !this.allElementsExpanded
282
+ },
283
+
284
+ unselectAll () {
285
+ this.selectedNodes.forEach(node => {
286
+ if (this.$refs['node_' + node.id]) {
287
+ this.$refs['node_' + node.id][0].setSelectionState(false)
288
+ }
289
+ })
290
+
291
+ this.selectedNodesObject = {}
292
+ this.allElementsSelected = false
293
+
294
+ this.$emit('node-selection-change', this.selectedNodes)
295
+ }
296
+ },
297
+
298
+ mounted () {
299
+ const defaults = {
300
+ branchesSelectable: false,
301
+ leavesSelectable: false,
302
+ rootDraggable: false,
303
+ dragAcrossBranches: false,
304
+ dragBranches: false,
305
+ dragLeaves: false,
306
+ // Options that are directly bound to the instances of vuedraggable
307
+ draggable: {
308
+ /*
309
+ * The `handle` property is used both to style the handle and as a DOM hook for draggable,
310
+ * that's why it is noted with the leading dot here. This is to be refactored later.
311
+ */
312
+ handle: '.c-treelist__drag-handle',
313
+ ghostClass: 'c-treelist__node-ghost',
314
+ chosenClass: 'c-treelist__node-chosen'
315
+ },
316
+ checkboxIdentifier: {
317
+ branch: 'nodeSelected',
318
+ leaf: 'nodeSelected'
319
+ },
320
+ selectOn: {
321
+ childSelect: false,
322
+ parentSelect: false
323
+ },
324
+ deselectOn: {
325
+ childDeselect: false,
326
+ parentDeselect: false
327
+ }
328
+ }
329
+ this.opts = deepMerge(defaults, this.options)
330
+
331
+ this.initFixedControls()
332
+ }
333
+ }
334
+ </script>
@@ -0,0 +1,79 @@
1
+ <license>
2
+ (c) 2010-present DEMOS E-Partizipation GmbH.
3
+
4
+ This file is part of the package @demos-europe/demosplan-ui,
5
+ for more information see the license file.
6
+
7
+ All rights reserved
8
+ </license>
9
+
10
+ <template>
11
+ <label class="u-mb-0">
12
+ <input
13
+ class="u-m-0_5 u-ml-0_25"
14
+ type="checkbox"
15
+ :name="name"
16
+ :id="name"
17
+ :checked="checked"
18
+ :value="stringValue"
19
+ @click="check">
20
+ <span class="hide-visually">{{ label }}</span>
21
+ </label>
22
+ </template>
23
+
24
+ <script>
25
+ export default {
26
+ name: 'DpTreeListCheckbox',
27
+
28
+ model: {
29
+ prop: 'checked',
30
+ event: 'check'
31
+ },
32
+
33
+ props: {
34
+ checked: {
35
+ type: Boolean,
36
+ required: false,
37
+ default: false
38
+ },
39
+
40
+ checkAll: {
41
+ type: Boolean,
42
+ required: false,
43
+ default: false
44
+ },
45
+
46
+ name: {
47
+ type: String,
48
+ required: true
49
+ },
50
+
51
+ // Some implementations may require to set a custom value, eg. when submitting DpTreeList as a whole form.
52
+ stringValue: {
53
+ type: String,
54
+ required: false,
55
+ default: 'on'
56
+ }
57
+ },
58
+
59
+ computed: {
60
+ label () {
61
+ if (this.checkAll) {
62
+ return this.toggleCheckedStatus('aria.deselect_all', 'aria.select.all')
63
+ }
64
+
65
+ return this.toggleCheckedStatus('aria.deselect', 'aria.select')
66
+ }
67
+ },
68
+
69
+ methods: {
70
+ check () {
71
+ this.$emit('check', !this.checked)
72
+ },
73
+
74
+ toggleCheckedStatus (deselect, select) {
75
+ return Translator.trans(this.checked ? deselect : select)
76
+ }
77
+ }
78
+ }
79
+ </script>