sprintify-ui 0.0.48 → 0.0.50

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.0.48",
3
+ "version": "0.0.50",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -12,7 +12,7 @@ export default {
12
12
  const Template = (args) => ({
13
13
  components: { BaseDatePicker, ShowValue },
14
14
  setup() {
15
- const value = ref(null);
15
+ const value = ref('2022-11-16T10:00:00Z');
16
16
  return { value, args };
17
17
  },
18
18
  template: `
@@ -41,10 +41,34 @@ MaxDate.args = {
41
41
 
42
42
  export const Disabled = Template.bind({});
43
43
  Disabled.args = {
44
- modelValue: '2022-11-16',
45
44
  disabled: true,
46
45
  };
47
46
 
47
+ export const DateTimeConversion = (args) => {
48
+ return {
49
+ components: { BaseDatePicker, ShowValue },
50
+ setup() {
51
+ const updatedValue = ref(null);
52
+ return { args, updatedValue };
53
+ },
54
+ template: `
55
+ <BaseDatePicker v-bind="args" @update:modelValue="(v) => updatedValue = v">
56
+ </BaseDatePicker>
57
+
58
+ <p class="mt-2"></p>
59
+ <small>Original props</small>
60
+ <ShowValue class='mt-1' :value="args.modelValue" />
61
+
62
+ <p class="mt-2"></p>
63
+ <small>Updated value</small>
64
+ <ShowValue class='mt-1' :value="updatedValue" />
65
+ `,
66
+ };
67
+ };
68
+ DateTimeConversion.args = {
69
+ modelValue: '2022-11-05T10:00:00Z',
70
+ };
71
+
48
72
  export const Field = createFieldStory({
49
73
  component: BaseDatePicker,
50
74
  componentName: 'BaseDatePicker',
@@ -10,7 +10,7 @@
10
10
  </div>
11
11
  <input
12
12
  ref="datepicker"
13
- :value="modelValue"
13
+ :value="modelValueFormatted"
14
14
  type="text"
15
15
  readonly
16
16
  :disabled="disabled"
@@ -19,7 +19,7 @@
19
19
  :placeholder="$t('sui.click_or_select_date')"
20
20
  />
21
21
  <div
22
- v-if="modelValue && !disabled"
22
+ v-if="modelValueFormatted && !disabled"
23
23
  class="absolute top-0 right-0 flex h-full items-center justify-center p-1"
24
24
  >
25
25
  <button
@@ -105,6 +105,24 @@ const weekdaysShort = arrayRotate(
105
105
  true
106
106
  );
107
107
 
108
+ const modelValueFormatted = computed((): string | null => {
109
+ if (!props.modelValue) {
110
+ return null;
111
+ }
112
+ return DateTime.fromISO(props.modelValue).toISODate() ?? null;
113
+ });
114
+
115
+ // Make sure the model value is always formatted on the parent component
116
+ watch(
117
+ () => modelValueFormatted.value,
118
+ () => {
119
+ if (props.modelValue !== modelValueFormatted.value) {
120
+ emitUpdate(modelValueFormatted.value);
121
+ }
122
+ },
123
+ { immediate: true }
124
+ );
125
+
108
126
  let picker = null as Pikaday | null;
109
127
 
110
128
  onMounted(() => {