@cloudron/pankow 3.5.3 → 3.5.5

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.
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <span class="pankow-radio">
3
- <input :name="name" :id="id || internalId" class="pankow-radio-input" type="radio" v-model="internalValue" :value="value" :disabled="disabled"/>
3
+ <input :name="name" :id="id || internalId" class="pankow-radio-input" type="radio" v-model="internalValue" :value="value" :disabled="disabled" :required="$attrs['required']"/>
4
4
  <slot>
5
5
  <label :for="id || internalId" class="pankow-radio-input-label">{{ label }}</label>
6
6
  </slot>
@@ -74,6 +74,7 @@ const menuModel = computed(() => {
74
74
  });
75
75
  });
76
76
 
77
+ const nativeSelect = useTemplateRef('nativeSelect');
77
78
  function selectIndex(index) {
78
79
  const item = props.options[index];
79
80
 
@@ -84,6 +85,11 @@ function selectIndex(index) {
84
85
 
85
86
  model.value = newValue;
86
87
  emits('select', newValue);
88
+
89
+ // let the browser know about the changes
90
+ nativeSelect.value.value = newValue;
91
+ nativeSelect.value.dispatchEvent(new Event('input', { bubbles: true }));
92
+ nativeSelect.value.dispatchEvent(new Event('change', { bubbles: true }));
87
93
  }
88
94
 
89
95
  function onMenuClosed() {
@@ -163,7 +169,7 @@ onMounted(() => {
163
169
  <template>
164
170
  <div class="pankow-singleselect" :class="{ 'pankow-singleselect-disabled': disabled }" ref="elem" tabindex="0" @click="onClick" @keydown.enter="onOpen" @keydown.down.stop.prevent="onSelectNext" @keydown.up.stop.prevent="onSelectPrev" @keydown.esc.stop="onClose" @keydown.stop="onKeyDown($event)">
165
171
  <!-- native select for required and accessibility handling -->
166
- <select v-model="selectedKey" :required="$attrs['required']" style="display: none">
172
+ <select v-model="selectedKey" ref="nativeSelect" :required="$attrs['required']" style="display: none">
167
173
  <option value=""></option>
168
174
  <option v-for="item in options" :value="optionKey ? item[optionKey] : item">{{ item[optionLabel] }}</option>
169
175
  </select>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudron/pankow",
3
3
  "private": false,
4
- "version": "3.5.3",
4
+ "version": "3.5.5",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "types": "types/index.d.ts",
package/types/utils.d.ts CHANGED
@@ -12,6 +12,7 @@ declare namespace _default {
12
12
  export { prettyLongDate };
13
13
  export { prettyFileSize };
14
14
  export { prettyEmailAddresses };
15
+ export { prettyDuration };
15
16
  export { sanitize };
16
17
  export { pathJoin };
17
18
  export { download };
@@ -39,6 +40,7 @@ export function formatDate(format: any, value: any): any;
39
40
  export function prettyLongDate(value: any): string;
40
41
  export function prettyFileSize(value: any): string;
41
42
  export function prettyEmailAddresses(addresses: any): any;
43
+ export function prettyDuration(ms: any): any;
42
44
  export function sanitize(path: any): any;
43
45
  export function pathJoin(...args: any[]): any;
44
46
  export function download(entries: any, name: any): void;
package/utils.js CHANGED
@@ -183,6 +183,17 @@ function prettyEmailAddresses(addresses) {
183
183
  return addresses.slice(1, -1);
184
184
  }
185
185
 
186
+ function prettyDuration(ms) {
187
+ const totalSeconds = Math.floor(ms / 1000);
188
+ const days = Math.floor(totalSeconds / 86400);
189
+ const hours = Math.floor((totalSeconds % 86400) / 3600);
190
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
191
+ const seconds = totalSeconds % 60;
192
+
193
+ const df = new Intl.DurationFormat(undefined, { style: 'narrow' });
194
+ return df.format({ days, hours, minutes, seconds });
195
+ }
196
+
186
197
  function sanitize(path) {
187
198
  path = '/' + path;
188
199
  return path.replace(/\/+/g, '/');
@@ -432,6 +443,7 @@ export {
432
443
  prettyLongDate,
433
444
  prettyFileSize,
434
445
  prettyEmailAddresses,
446
+ prettyDuration,
435
447
  sanitize,
436
448
  pathJoin,
437
449
  download,
@@ -460,6 +472,7 @@ export default {
460
472
  prettyLongDate,
461
473
  prettyFileSize,
462
474
  prettyEmailAddresses,
475
+ prettyDuration,
463
476
  sanitize,
464
477
  pathJoin,
465
478
  download,