@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,194 @@
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
+ <dp-label
13
+ v-if="label !== ''"
14
+ :for="`datePicker:${id}`"
15
+ :hint="hint"
16
+ :required="required"
17
+ :text="label" />
18
+ <div class="o-form__control-wrapper o-form__group">
19
+ <dp-datepicker
20
+ class="o-form__group-item shrink"
21
+ :calendars-after="2"
22
+ :disabled="disabled"
23
+ :id="`datePicker:${id}`"
24
+ :max-date="maxDate"
25
+ :min-date="minDate"
26
+ :required="required"
27
+ v-model="date"
28
+ @input="$emit('input', currentDatetime)" />
29
+ <dp-time-picker
30
+ class="o-form__group-item"
31
+ :disabled="disabled"
32
+ :id="`timePicker:${id}`"
33
+ v-model="time"
34
+ :min-value="minTime"
35
+ @input="$emit('input', currentDatetime)" />
36
+ <input
37
+ type="hidden"
38
+ :disabled="disabled"
39
+ :name="name"
40
+ :value="currentDatetime"
41
+ v-if="hiddenInput && name">
42
+ </div>
43
+ </div>
44
+ </template>
45
+
46
+ <script>
47
+ import customParseFormat from 'dayjs/plugin/customParseFormat'
48
+ import dayjs from 'dayjs'
49
+ import DpDatepicker from './DpDatepicker'
50
+ import DpTimePicker from './DpTimePicker'
51
+
52
+ dayjs.extend(customParseFormat)
53
+
54
+ export default {
55
+ name: 'DpDatetimePicker',
56
+
57
+ components: {
58
+ DpDatepicker,
59
+ DpLabel: async () => {
60
+ const { DpLabel } = await import('demosplan-ui/components')
61
+ return DpLabel
62
+ },
63
+ DpTimePicker
64
+ },
65
+
66
+ props: {
67
+ disabled: {
68
+ type: Boolean,
69
+ required: false,
70
+ default: false
71
+ },
72
+
73
+ /**
74
+ * Add a hidden input field to submit value of `currentDatetime`
75
+ * if used in a form that actually gets submitted.
76
+ */
77
+ hiddenInput: {
78
+ type: Boolean,
79
+ required: false,
80
+ default: false
81
+ },
82
+
83
+ hint: {
84
+ type: String,
85
+ required: false,
86
+ default: ''
87
+ },
88
+
89
+ /*
90
+ * The ids of date and time pickers are derived from this prop.
91
+ */
92
+ id: {
93
+ type: String,
94
+ required: true
95
+ },
96
+
97
+ /*
98
+ * If set, a label is rendered above the datetime picker. However this is not exactly
99
+ * best practice in terms of accessibility right now, since this label points to none
100
+ * of the date or time inputs.
101
+ */
102
+ label: {
103
+ type: String,
104
+ required: false,
105
+ default: ''
106
+ },
107
+
108
+ /*
109
+ * Set a maxDate for the date field. Since this is passed to the datepicker component,
110
+ * in contrast to the `value` field a string in the format of 'dd.mm.yyyy' is expected.
111
+ */
112
+ maxDate: {
113
+ type: String,
114
+ required: false,
115
+ default: ''
116
+ },
117
+
118
+ /*
119
+ * Set a minDate for the date field. Since this is passed to the datepicker component,
120
+ * in contrast to the `value` field a string in the format of 'dd.mm.yyyy' is expected.
121
+ */
122
+ minDate: {
123
+ type: String,
124
+ required: false,
125
+ default: ''
126
+ },
127
+
128
+ // Used in conjunction with `hiddenInput` to render a hidden input field with this name.
129
+ name: {
130
+ type: String,
131
+ required: false,
132
+ default: ''
133
+ },
134
+
135
+ required: {
136
+ type: Boolean,
137
+ required: false,
138
+ default: false
139
+ },
140
+
141
+ // Expects ISO datetime
142
+ value: {
143
+ type: String,
144
+ required: true
145
+ }
146
+ },
147
+
148
+ data () {
149
+ return {
150
+ date: '',
151
+ time: '00:00'
152
+ }
153
+ },
154
+
155
+ computed: {
156
+ currentDatetime () {
157
+ const parsedDateTime = dayjs(`${this.date} ${this.time}`, 'DD.MM.YYYY HH:mm')
158
+ return parsedDateTime.isValid() ? parsedDateTime.format() : ''
159
+ },
160
+
161
+ isCurrentDateSelected () {
162
+ return this.minDate !== '' ? this.date === this.minDate : false
163
+ },
164
+
165
+ /**
166
+ * Set minTime only if the current day is selected in the datepicker
167
+ * @return {string|string}
168
+ */
169
+ minTime () {
170
+ return this.isCurrentDateSelected ? new Date().toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' }) : ''
171
+ }
172
+ },
173
+
174
+ watch: {
175
+ value: function (newVal) {
176
+ this.setDatetime(newVal)
177
+ }
178
+ },
179
+
180
+ methods: {
181
+ setDatetime (datetime) {
182
+ const parsedDateTime = dayjs(datetime)
183
+ if (parsedDateTime.isValid()) {
184
+ this.date = parsedDateTime.format('DD.MM.YYYY')
185
+ this.time = parsedDateTime.format('HH:mm')
186
+ }
187
+ }
188
+ },
189
+
190
+ mounted () {
191
+ this.setDatetime(this.value)
192
+ }
193
+ }
194
+ </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
+ <div class="u-mb-0_75">
12
+ <!-- insert form fields here -->
13
+ <slot />
14
+ </div>
15
+ </template>
16
+
17
+ <script>
18
+ export default {
19
+ name: 'DpFormRow',
20
+
21
+ data () {
22
+ return {
23
+ // Number of elements in the form row
24
+ elementCount: 0,
25
+ // True if the form elements fill the entire row
26
+ isFullRow: true
27
+ }
28
+ },
29
+
30
+ computed: {
31
+ /**
32
+ * Array containing the widths of the form elements
33
+ * @return {Array}
34
+ */
35
+ elementsWidths () {
36
+ return this.$children.map(child => child.$props.width || 'u-1-of-1') || []
37
+ }
38
+ },
39
+
40
+ methods: {
41
+ /**
42
+ * Determine if the given form elements fill the entire row; if not, add padding-right
43
+ */
44
+ determineRowWidth () {
45
+ if (this.elementsWidths.length > 0) {
46
+ // U-firstWidthValue-of-y
47
+ const firstWidthValues = this.elementsWidths.map(width => parseInt(width.match(/\d+/)))
48
+ // Add firstWidthValues together
49
+ const combinedWidth = firstWidthValues.reduce((acc, curr) => {
50
+ return acc + parseInt(curr)
51
+ })
52
+ // U-x-of-completeWidth
53
+ const completeWidth = parseInt(this.elementsWidths[0].match(/\d+$/)[0])
54
+ this.isFullRow = completeWidth === combinedWidth
55
+ }
56
+ },
57
+
58
+ /**
59
+ * Add padding-right to the form element if
60
+ * - it is not the last element in the row or
61
+ * - it is the last element in the row, but the elements don't fill the row
62
+ */
63
+ setPadding () {
64
+ this.$children.forEach(child => {
65
+ const idx = this.$children.indexOf(child)
66
+ if (idx < this.elementCount - 1 || (idx === this.elementCount - 1 && this.isFullRow === false)) {
67
+ child.$el.classList.add('u-pr')
68
+ }
69
+ })
70
+ }
71
+ },
72
+
73
+ mounted () {
74
+ this.elementCount = this.$children.length
75
+ this.determineRowWidth()
76
+ this.setPadding()
77
+ }
78
+ }
79
+ </script>
@@ -0,0 +1,164 @@
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
+ <documentation>
11
+ <!--
12
+ This is the generic multiselect functional component for vue instances. It is a DPlan wrapper for vue-multiselect: https://github.com/shentao/vue-multiselect
13
+ Component props:
14
+ - options - Array of strings/objects
15
+ - v-model - attribute to bind the component's value
16
+ - track-by - for the options that are of type Object
17
+ - searchable="false" – disables the search functionality (by default the search is enabled)
18
+ - close-on-select="false" – the dropdown stays open after selecting an option
19
+ - clear-on-select="false" – the search query stays the same after selecting an option
20
+ - multiple – for multiselect (by default it is single select)
21
+ - allow-empty - allows the value to be deselected (VORSICHT - the component's value is then NULL so any other computed props or functions using the value may fail)
22
+ - label - what should be shown in dropdown (for example if the option is an object with id and name we can define, that 'name' should be a label here), customLabel is a function that has to return a string
23
+
24
+ Groups in select: The options list can also contain groups. It requires passing 3 additional props: group-label, group-values and group-select. group-label is used to locate the group label. group-values should point to the group’s option list. group-select is used to define if selecting the group label should select/unselect all values in the group, or do nothing. Despite that the available options are grouped, the selected options are stored as a flat array of objects.
25
+
26
+ For all possible props see: https://vue-multiselect.js.org/#sub-props
27
+
28
+ The styling for the component can be found in _multiselect.scss
29
+
30
+ -->
31
+ <usage
32
+ :options="optionsArray"
33
+ track-by="id"
34
+ ref="multiselect"
35
+ id=""
36
+ :custom-label="option =>`${option.id} ${option.name ? option.name : ''}`"
37
+ class="custom styling classes"
38
+ :allow-empty="false"
39
+ v-model="selected"
40
+ @input="$emit('whatever you want to emit')">
41
+ <template v-slot:option="{ option }">
42
+ <strong>{{ option.id }}{{ option.name ? ` ${option.name}` : '' }}</strong>
43
+ </template>
44
+ </usage>
45
+ </documentation>
46
+
47
+ <script>
48
+ import VueMultiselect from 'vue-multiselect'
49
+
50
+ export default {
51
+ name: 'DpMultiselect',
52
+
53
+ functional: true,
54
+
55
+ props: {
56
+ required: {
57
+ required: false,
58
+ type: Boolean,
59
+ default: false
60
+ },
61
+
62
+ selectionControls: {
63
+ required: false,
64
+ type: Boolean,
65
+ default: false
66
+ }
67
+ },
68
+
69
+ render: function (createElement, context) {
70
+ const defaults = {
71
+ placeholder: Translator.trans('choose'),
72
+ selectLabel: '',
73
+ selectGroupLabel: '',
74
+ selectedLabel: '',
75
+ deselectLabel: '',
76
+ deselectGroupLabel: '',
77
+ tagPlaceholder: Translator.trans('tag.create')
78
+ }
79
+ context.data.attrs = { ...defaults, ...context.data.attrs }
80
+ if (context.props.required) {
81
+ context.data.directives = [
82
+ {
83
+ name: 'dp-validate-multiselect'
84
+ }
85
+ ]
86
+ context.data.staticClass = context.data.staticClass ? context.data.staticClass + ' is-required' : 'is-required'
87
+ }
88
+
89
+ const functions = {
90
+ noResult: () => createElement('span', Translator.trans('autocomplete.noResults')),
91
+ noOptions: () => createElement('span', Translator.trans('explanation.noentries'))
92
+ }
93
+
94
+ if (context.props.selectionControls) {
95
+ const menuOptions = context.data.attrs.options
96
+ const menuSelectedValue = context.data.model.value
97
+
98
+ // Add disabled attribute for selection Controls Buttons when click.
99
+ const buttonSelectAll = document.querySelector('[data-select-all]')
100
+ const buttonUnselectAll = document.querySelector('[data-unselect-all]')
101
+ if (buttonSelectAll) {
102
+ if (menuSelectedValue.length === menuOptions.length) {
103
+ buttonSelectAll.setAttribute('disabled', 'disabled')
104
+ } else {
105
+ buttonSelectAll.removeAttribute('disabled')
106
+ }
107
+ }
108
+
109
+ if (buttonUnselectAll) {
110
+ if (menuSelectedValue.length === 0) {
111
+ buttonUnselectAll.setAttribute('disabled', 'disabled')
112
+ } else {
113
+ buttonUnselectAll.removeAttribute('disabled')
114
+ }
115
+ }
116
+
117
+ functions.beforeList = () => {
118
+ return createElement('div', {
119
+ attrs: {
120
+ class: 'border--bottom'
121
+ }
122
+ }, [
123
+ createElement(
124
+ 'button',
125
+ {
126
+ domProps: {
127
+ innerHTML: Translator.trans('select.all')
128
+ },
129
+ attrs: {
130
+ class: 'btn--blank weight--bold u-ph-0_5 u-pv-0_25',
131
+ type: 'button',
132
+ 'data-select-all': ''
133
+ },
134
+ on: {
135
+ click: context.listeners['select-all']
136
+ }
137
+ }
138
+ ),
139
+ createElement(
140
+ 'button',
141
+ {
142
+ domProps: {
143
+ innerHTML: Translator.trans('unselect.all')
144
+ },
145
+ attrs: {
146
+ class: 'btn--blank weight--bold u-ph-0_5 u-pv-0_25',
147
+ type: 'button',
148
+ 'data-unselect-all': ''
149
+ },
150
+ on: {
151
+ click: context.listeners['unselect-all']
152
+ }
153
+ }
154
+ )
155
+ ])
156
+ }
157
+ }
158
+
159
+ context.data.scopedSlots = { ...context.data.scopedSlots, ...functions }
160
+
161
+ return createElement(VueMultiselect, context.data, context.children)
162
+ }
163
+ }
164
+ </script>
@@ -0,0 +1,128 @@
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 :class="prefixClass('o-form__element--radio')">
12
+ <input
13
+ :id="id"
14
+ :name="name !== '' ? name : false"
15
+ :class="prefixClass('o-form__control-input')"
16
+ type="radio"
17
+ :required="required"
18
+ :disabled="disabled"
19
+ :readonly="readonly"
20
+ autocomplete="off"
21
+ :checked="checked"
22
+ :value="value"
23
+ :data-cy="dataCy !== '' ? dataCy : false"
24
+ @change="$emit('change', $event.target.checked)"><!--
25
+ --><dp-label
26
+ :class="prefixClass('o-form__label')"
27
+ v-bind="labelProps" />
28
+ </div>
29
+ </template>
30
+
31
+ <script>
32
+ import { DpLabel } from 'demosplan-ui/components'
33
+ import { prefixClassMixin } from 'demosplan-ui/mixins'
34
+
35
+ export default {
36
+ name: 'DpRadio',
37
+
38
+ components: {
39
+ DpLabel
40
+ },
41
+
42
+ mixins: [prefixClassMixin],
43
+
44
+ model: {
45
+ prop: 'checked',
46
+ event: 'change'
47
+ },
48
+
49
+ props: {
50
+ bold: {
51
+ type: Boolean,
52
+ required: false,
53
+ default: true
54
+ },
55
+
56
+ checked: {
57
+ type: Boolean,
58
+ required: false,
59
+ default: false
60
+ },
61
+
62
+ dataCy: {
63
+ type: String,
64
+ required: false,
65
+ default: ''
66
+ },
67
+
68
+ disabled: {
69
+ type: Boolean,
70
+ required: false,
71
+ default: false
72
+ },
73
+
74
+ hint: {
75
+ type: String,
76
+ required: false,
77
+ default: ''
78
+ },
79
+
80
+ id: {
81
+ type: String,
82
+ required: true
83
+ },
84
+
85
+ label: {
86
+ type: String,
87
+ required: false,
88
+ default: ''
89
+ },
90
+
91
+ name: {
92
+ type: String,
93
+ required: false,
94
+ default: ''
95
+ },
96
+
97
+ readonly: {
98
+ type: Boolean,
99
+ required: false,
100
+ default: false
101
+ },
102
+
103
+ required: {
104
+ type: Boolean,
105
+ required: false,
106
+ default: false
107
+ },
108
+
109
+ value: {
110
+ type: String,
111
+ required: false,
112
+ default: '1'
113
+ }
114
+ },
115
+
116
+ computed: {
117
+ labelProps () {
118
+ return {
119
+ for: this.id,
120
+ hint: this.hint,
121
+ text: this.label,
122
+ required: this.required,
123
+ bold: this.bold
124
+ }
125
+ }
126
+ }
127
+ }
128
+ </script>
@@ -0,0 +1,110 @@
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
+ <span :class="{ 'display--inline-block width-100p': inputWidth !== ''}">
12
+ <dp-resettable-input
13
+ id="searchField"
14
+ data-cy="searchField"
15
+ :class="cssClasses"
16
+ :input-attributes="{ placeholder: Translator.trans('search'), type: 'search' }"
17
+ @reset="handleReset"
18
+ @enter="handleSearch"
19
+ v-model="searchTerm" /><!--
20
+
21
+ --><dp-button
22
+ class="u-valign--top"
23
+ data-cy="handleSearch"
24
+ @click="handleSearch"
25
+ :text="Translator.trans('searching')" />
26
+ </span>
27
+ </template>
28
+
29
+ <script>
30
+ import { DpButton } from 'demosplan-ui/components'
31
+ import DpResettableInput from '../DpResettableInput'
32
+
33
+ export default {
34
+ name: 'DpSearchField',
35
+
36
+ components: {
37
+ DpButton,
38
+ DpResettableInput
39
+ },
40
+
41
+ props: {
42
+ initSearchTerm: {
43
+ type: String,
44
+ required: false,
45
+ default: ''
46
+ },
47
+
48
+ /**
49
+ * Value has to be a css class like 'u-1-of-2'
50
+ */
51
+ inputWidth: {
52
+ type: String,
53
+ default: ''
54
+ },
55
+
56
+ placeholder: {
57
+ type: String,
58
+ required: false,
59
+ default: 'search'
60
+ }
61
+ },
62
+
63
+ data () {
64
+ return {
65
+ searchTerm: this.initSearchTerm,
66
+ searchTermApplied: ''
67
+ }
68
+ },
69
+
70
+ computed: {
71
+ cssClasses () {
72
+ return this.inputWidth !== '' ? `display--inline-block u-mr-0_5 ${this.inputWidth}` : 'display--inline-block u-mr-0_5'
73
+ }
74
+ },
75
+
76
+ methods: {
77
+ handleReset () {
78
+ this.searchTerm = ''
79
+
80
+ /*
81
+ * Only emit reset if the searchTerm has been changed
82
+ * The empty string is emitted to stick to only one type.
83
+ */
84
+ if (this.searchTermApplied !== this.searchTerm) {
85
+ this.$emit('reset', '')
86
+ this.searchTermApplied = ''
87
+ }
88
+ },
89
+
90
+ handleSearch () {
91
+ // Prevent emitting a searchTerm twice
92
+ if (this.searchTermApplied === this.searchTerm) {
93
+ return
94
+ }
95
+
96
+ this.searchTermApplied = this.searchTerm
97
+ this.$emit('search', this.searchTerm)
98
+ },
99
+
100
+ reset () {
101
+ this.searchTermApplied = ''
102
+ this.searchTerm = ''
103
+ }
104
+ },
105
+
106
+ mounted () {
107
+ this.searchTermApplied = this.searchTerm
108
+ }
109
+ }
110
+ </script>