@onereach/ui-components 2.74.1 → 2.74.2-beta.2295.0

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.
@@ -120,7 +120,8 @@ var script = defineComponent({
120
120
  },
121
121
  isOpen: {
122
122
  type: Boolean,
123
- default: false
123
+ required: false,
124
+ default: undefined
124
125
  }
125
126
  },
126
127
  emits: ['open', 'close', 'confirm'],
@@ -149,9 +150,15 @@ var script = defineComponent({
149
150
  // Methods
150
151
  function open() {
151
152
  isActive.value = true;
153
+ if (props.isOpen === undefined) {
154
+ emit('open');
155
+ }
152
156
  }
153
157
  function close() {
154
- isActive.value = false;
158
+ if (props.isOpen === undefined) {
159
+ isActive.value = false;
160
+ }
161
+ emit('close');
155
162
  }
156
163
  function confirm() {
157
164
  if (!props.disabled && !isInvalid.value) emit('confirm');
@@ -164,11 +171,10 @@ var script = defineComponent({
164
171
  touched.value = true;
165
172
  }
166
173
  // Events
167
- watch(isActive, value => emit(value ? 'open' : 'close'));
168
- watch(() => props.isOpen, newIsOpen => {
169
- if (newIsOpen) {
174
+ watch(() => props.isOpen, value => {
175
+ if (value === true) {
170
176
  open();
171
- } else {
177
+ } else if (value === false) {
172
178
  close();
173
179
  }
174
180
  }, {
@@ -19,7 +19,7 @@ export { _ as OrCode, O as OrCodeLanguages } from '../OrCode-fc6876ec.js';
19
19
  export { O as OrCollapse } from '../OrCollapse-3aa9a9b7.js';
20
20
  export { _ as OrColorPicker, h as amber, n as black, b as blue, m as blueGrey, k as brown, c as cyan, j as deepOrange, d as deepPurple, g as green, i as indigo, l as lightBlue, e as lightGreen, f as lime, o as orange, p as pink, a as purple, r as red, t as teal, w as white, y as yellow } from '../OrColorPicker-a1a37e83.js';
21
21
  export { _ as OrConfirm } from '../OrConfirm-55b89b17.js';
22
- export { C as ConfirmType, _ as OrConfirmV3 } from '../OrConfirm-d3a9f7b9.js';
22
+ export { C as ConfirmType, _ as OrConfirmV3 } from '../OrConfirm-1fe4088c.js';
23
23
  export { D as DEFAULT_TEXT, _ as OrDateTimePicker, a as OrDateTimePickerItemTypes, O as OrDateTimePickerTypes } from '../OrDateTimePicker-e212f892.js';
24
24
  export { O as OrError } from '../OrError-31503e4c.js';
25
25
  export { _ as OrErrorTagV3 } from '../OrErrorTag-4675604d.js';
@@ -84,7 +84,8 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
84
84
  };
85
85
  isOpen: {
86
86
  type: BooleanConstructor;
87
- default: boolean;
87
+ required: false;
88
+ default: undefined;
88
89
  };
89
90
  }, import("@vue/composition-api").ExtractPropTypes<{
90
91
  titleText: {
@@ -139,7 +140,8 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
139
140
  };
140
141
  isOpen: {
141
142
  type: BooleanConstructor;
142
- default: boolean;
143
+ required: false;
144
+ default: undefined;
143
145
  };
144
146
  }>> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
145
147
  titleText: string;
@@ -1,4 +1,4 @@
1
- export { C as ConfirmType, _ as OrConfirmV3 } from '../../OrConfirm-d3a9f7b9.js';
1
+ export { C as ConfirmType, _ as OrConfirmV3 } from '../../OrConfirm-1fe4088c.js';
2
2
  import '@vueuse/core';
3
3
  import '../../index-17f264f9.js';
4
4
  import '../../index-fa6eb4ca.js';
@@ -24,7 +24,7 @@ export { _ as OrCode, O as OrCodeLanguages } from './OrCode-fc6876ec.js';
24
24
  export { O as OrCollapse } from './OrCollapse-3aa9a9b7.js';
25
25
  export { _ as OrColorPicker, h as amber, n as black, b as blue, m as blueGrey, k as brown, c as cyan, j as deepOrange, d as deepPurple, g as green, i as indigo, l as lightBlue, e as lightGreen, f as lime, o as orange, p as pink, a as purple, r as red, t as teal, w as white, y as yellow } from './OrColorPicker-a1a37e83.js';
26
26
  export { _ as OrConfirm } from './OrConfirm-55b89b17.js';
27
- export { C as ConfirmType, _ as OrConfirmV3 } from './OrConfirm-d3a9f7b9.js';
27
+ export { C as ConfirmType, _ as OrConfirmV3 } from './OrConfirm-1fe4088c.js';
28
28
  export { D as DEFAULT_TEXT, _ as OrDateTimePicker, a as OrDateTimePickerItemTypes, O as OrDateTimePickerTypes } from './OrDateTimePicker-e212f892.js';
29
29
  export { O as OrError } from './OrError-31503e4c.js';
30
30
  export { _ as OrErrorTagV3 } from './OrErrorTag-4675604d.js';
@@ -121,7 +121,8 @@ var script = defineComponent({
121
121
  },
122
122
  isOpen: {
123
123
  type: Boolean,
124
- default: false
124
+ required: false,
125
+ default: undefined
125
126
  }
126
127
  },
127
128
  emits: ['open', 'close', 'confirm'],
@@ -150,9 +151,15 @@ var script = defineComponent({
150
151
  // Methods
151
152
  function open() {
152
153
  isActive.value = true;
154
+ if (props.isOpen === undefined) {
155
+ emit('open');
156
+ }
153
157
  }
154
158
  function close() {
155
- isActive.value = false;
159
+ if (props.isOpen === undefined) {
160
+ isActive.value = false;
161
+ }
162
+ emit('close');
156
163
  }
157
164
  function confirm() {
158
165
  if (!props.disabled && !isInvalid.value) emit('confirm');
@@ -165,11 +172,10 @@ var script = defineComponent({
165
172
  touched.value = true;
166
173
  }
167
174
  // Events
168
- watch(isActive, value => emit(value ? 'open' : 'close'));
169
- watch(() => props.isOpen, newIsOpen => {
170
- if (newIsOpen) {
175
+ watch(() => props.isOpen, value => {
176
+ if (value === true) {
171
177
  open();
172
- } else {
178
+ } else if (value === false) {
173
179
  close();
174
180
  }
175
181
  }, {
@@ -19,7 +19,7 @@ export { s as OrCode, O as OrCodeLanguages } from '../OrCode.vue_vue_type_script
19
19
  export { s as OrCollapse } from '../OrCollapse.vue_vue_type_script_lang-65cbb754.js';
20
20
  export { s as OrColorPicker, h as amber, n as black, b as blue, m as blueGrey, k as brown, c as cyan, j as deepOrange, d as deepPurple, g as green, i as indigo, l as lightBlue, e as lightGreen, f as lime, o as orange, p as pink, a as purple, r as red, t as teal, w as white, y as yellow } from '../OrColorPicker.vue_vue_type_script_lang-4141378d.js';
21
21
  export { s as OrConfirm } from '../OrConfirm.vue_vue_type_script_lang-41b4d791.js';
22
- export { C as ConfirmType, s as OrConfirmV3 } from '../OrConfirm.vue_vue_type_script_lang-20309110.js';
22
+ export { C as ConfirmType, s as OrConfirmV3 } from '../OrConfirm.vue_vue_type_script_lang-1bcc55ff.js';
23
23
  export { D as DEFAULT_TEXT, s as OrDateTimePicker, a as OrDateTimePickerItemTypes, O as OrDateTimePickerTypes } from '../OrDateTimePicker.vue_vue_type_script_lang-7bfe5005.js';
24
24
  export { s as OrError } from '../OrError.vue_vue_type_script_lang-7c39e012.js';
25
25
  export { s as OrErrorTagV3 } from '../OrErrorTag.vue_vue_type_script_lang-bfa4c580.js';
@@ -84,7 +84,8 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
84
84
  };
85
85
  isOpen: {
86
86
  type: BooleanConstructor;
87
- default: boolean;
87
+ required: false;
88
+ default: undefined;
88
89
  };
89
90
  }, import("@vue/composition-api").ExtractPropTypes<{
90
91
  titleText: {
@@ -139,7 +140,8 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
139
140
  };
140
141
  isOpen: {
141
142
  type: BooleanConstructor;
142
- default: boolean;
143
+ required: false;
144
+ default: undefined;
143
145
  };
144
146
  }>> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
145
147
  titleText: string;
@@ -1,4 +1,4 @@
1
- export { C as ConfirmType, s as OrConfirmV3 } from '../../OrConfirm.vue_vue_type_script_lang-20309110.js';
1
+ export { C as ConfirmType, s as OrConfirmV3 } from '../../OrConfirm.vue_vue_type_script_lang-1bcc55ff.js';
2
2
  import '@vueuse/core';
3
3
  import '../../index-01519e46.js';
4
4
  import 'vue';
@@ -39,8 +39,8 @@ import { s as script$8 } from './OrColorPicker.vue_vue_type_script_lang-4141378d
39
39
  export { s as OrColorPicker, h as amber, n as black, b as blue, m as blueGrey, k as brown, c as cyan, j as deepOrange, d as deepPurple, g as green, i as indigo, l as lightBlue, e as lightGreen, f as lime, o as orange, p as pink, a as purple, r as red, t as teal, w as white, y as yellow } from './OrColorPicker.vue_vue_type_script_lang-4141378d.js';
40
40
  import { s as script$9 } from './OrConfirm.vue_vue_type_script_lang-41b4d791.js';
41
41
  export { s as OrConfirm } from './OrConfirm.vue_vue_type_script_lang-41b4d791.js';
42
- import { s as script$a } from './OrConfirm.vue_vue_type_script_lang-20309110.js';
43
- export { C as ConfirmType, s as OrConfirmV3 } from './OrConfirm.vue_vue_type_script_lang-20309110.js';
42
+ import { s as script$a } from './OrConfirm.vue_vue_type_script_lang-1bcc55ff.js';
43
+ export { C as ConfirmType, s as OrConfirmV3 } from './OrConfirm.vue_vue_type_script_lang-1bcc55ff.js';
44
44
  import { s as script$b } from './OrDateTimePicker.vue_vue_type_script_lang-7bfe5005.js';
45
45
  export { D as DEFAULT_TEXT, s as OrDateTimePicker, a as OrDateTimePickerItemTypes, O as OrDateTimePickerTypes } from './OrDateTimePicker.vue_vue_type_script_lang-7bfe5005.js';
46
46
  import { s as script$c } from './OrErrorTag.vue_vue_type_script_lang-bfa4c580.js';
@@ -119,7 +119,8 @@ var script = defineComponent({
119
119
  },
120
120
  isOpen: {
121
121
  type: Boolean,
122
- default: false
122
+ required: false,
123
+ default: undefined
123
124
  }
124
125
  },
125
126
  emits: ['open', 'close', 'confirm'],
@@ -148,9 +149,15 @@ var script = defineComponent({
148
149
  // Methods
149
150
  function open() {
150
151
  isActive.value = true;
152
+ if (props.isOpen === undefined) {
153
+ emit('open');
154
+ }
151
155
  }
152
156
  function close() {
153
- isActive.value = false;
157
+ if (props.isOpen === undefined) {
158
+ isActive.value = false;
159
+ }
160
+ emit('close');
154
161
  }
155
162
  function confirm() {
156
163
  if (!props.disabled && !isInvalid.value) emit('confirm');
@@ -163,11 +170,10 @@ var script = defineComponent({
163
170
  touched.value = true;
164
171
  }
165
172
  // Events
166
- watch(isActive, value => emit(value ? 'open' : 'close'));
167
- watch(() => props.isOpen, newIsOpen => {
168
- if (newIsOpen) {
173
+ watch(() => props.isOpen, value => {
174
+ if (value === true) {
169
175
  open();
170
- } else {
176
+ } else if (value === false) {
171
177
  close();
172
178
  }
173
179
  }, {
@@ -19,7 +19,7 @@ export { _ as OrCode, O as OrCodeLanguages } from '../OrCode-d4400b42.js';
19
19
  export { _ as OrCollapse } from '../OrCollapse-4d892ca3.js';
20
20
  export { _ as OrColorPicker, h as amber, n as black, b as blue, m as blueGrey, k as brown, c as cyan, j as deepOrange, d as deepPurple, g as green, i as indigo, l as lightBlue, e as lightGreen, f as lime, o as orange, p as pink, a as purple, r as red, t as teal, w as white, y as yellow } from '../OrColorPicker-75abefdd.js';
21
21
  export { _ as OrConfirm } from '../OrConfirm-ede619eb.js';
22
- export { C as ConfirmType, _ as OrConfirmV3 } from '../OrConfirm-d2aec18c.js';
22
+ export { C as ConfirmType, _ as OrConfirmV3 } from '../OrConfirm-4566d105.js';
23
23
  export { D as DEFAULT_TEXT, _ as OrDateTimePicker, a as OrDateTimePickerItemTypes, O as OrDateTimePickerTypes } from '../OrDateTimePicker-349df9b2.js';
24
24
  export { _ as OrError } from '../OrError-081130bb.js';
25
25
  export { _ as OrErrorTagV3 } from '../OrErrorTag-7cd5dc68.js';
@@ -84,7 +84,8 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
84
84
  };
85
85
  isOpen: {
86
86
  type: BooleanConstructor;
87
- default: boolean;
87
+ required: false;
88
+ default: undefined;
88
89
  };
89
90
  }, import("@vue/composition-api").ExtractPropTypes<{
90
91
  titleText: {
@@ -139,7 +140,8 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
139
140
  };
140
141
  isOpen: {
141
142
  type: BooleanConstructor;
142
- default: boolean;
143
+ required: false;
144
+ default: undefined;
143
145
  };
144
146
  }>> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
145
147
  titleText: string;
@@ -1,4 +1,4 @@
1
- export { C as ConfirmType, _ as OrConfirmV3 } from '../../OrConfirm-d2aec18c.js';
1
+ export { C as ConfirmType, _ as OrConfirmV3 } from '../../OrConfirm-4566d105.js';
2
2
  import '@vueuse/core';
3
3
  import '@vueuse/math';
4
4
  import 'vue-demi';
@@ -19,7 +19,7 @@ export { _ as OrCode, O as OrCodeLanguages } from './OrCode-d4400b42.js';
19
19
  export { _ as OrCollapse } from './OrCollapse-4d892ca3.js';
20
20
  export { _ as OrColorPicker, h as amber, n as black, b as blue, m as blueGrey, k as brown, c as cyan, j as deepOrange, d as deepPurple, g as green, i as indigo, l as lightBlue, e as lightGreen, f as lime, o as orange, p as pink, a as purple, r as red, t as teal, w as white, y as yellow } from './OrColorPicker-75abefdd.js';
21
21
  export { _ as OrConfirm } from './OrConfirm-ede619eb.js';
22
- export { C as ConfirmType, _ as OrConfirmV3 } from './OrConfirm-d2aec18c.js';
22
+ export { C as ConfirmType, _ as OrConfirmV3 } from './OrConfirm-4566d105.js';
23
23
  export { D as DEFAULT_TEXT, _ as OrDateTimePicker, a as OrDateTimePickerItemTypes, O as OrDateTimePickerTypes } from './OrDateTimePicker-349df9b2.js';
24
24
  export { _ as OrError } from './OrError-081130bb.js';
25
25
  export { _ as OrErrorTagV3 } from './OrErrorTag-7cd5dc68.js';
@@ -119,7 +119,8 @@ var script = defineComponent({
119
119
  },
120
120
  isOpen: {
121
121
  type: Boolean,
122
- default: false
122
+ required: false,
123
+ default: undefined
123
124
  }
124
125
  },
125
126
  emits: ['open', 'close', 'confirm'],
@@ -148,9 +149,15 @@ var script = defineComponent({
148
149
  // Methods
149
150
  function open() {
150
151
  isActive.value = true;
152
+ if (props.isOpen === undefined) {
153
+ emit('open');
154
+ }
151
155
  }
152
156
  function close() {
153
- isActive.value = false;
157
+ if (props.isOpen === undefined) {
158
+ isActive.value = false;
159
+ }
160
+ emit('close');
154
161
  }
155
162
  function confirm() {
156
163
  if (!props.disabled && !isInvalid.value) emit('confirm');
@@ -163,11 +170,10 @@ var script = defineComponent({
163
170
  touched.value = true;
164
171
  }
165
172
  // Events
166
- watch(isActive, value => emit(value ? 'open' : 'close'));
167
- watch(() => props.isOpen, newIsOpen => {
168
- if (newIsOpen) {
173
+ watch(() => props.isOpen, value => {
174
+ if (value === true) {
169
175
  open();
170
- } else {
176
+ } else if (value === false) {
171
177
  close();
172
178
  }
173
179
  }, {
@@ -16,7 +16,7 @@ export { s as OrCode, O as OrCodeLanguages } from '../OrCode-5ed69c23.js';
16
16
  export { s as OrCollapse } from '../OrCollapse-445141ab.js';
17
17
  export { s as OrColorPicker, h as amber, n as black, b as blue, m as blueGrey, k as brown, c as cyan, j as deepOrange, d as deepPurple, g as green, i as indigo, l as lightBlue, e as lightGreen, f as lime, o as orange, p as pink, a as purple, r as red, t as teal, w as white, y as yellow } from '../OrColorPicker-189cb097.js';
18
18
  export { s as OrConfirm } from '../OrConfirm-c11ee2ec.js';
19
- export { C as ConfirmType, s as OrConfirmV3 } from '../OrConfirm-a7f9404b.js';
19
+ export { C as ConfirmType, s as OrConfirmV3 } from '../OrConfirm-ea316da1.js';
20
20
  export { D as DEFAULT_TEXT, s as OrDateTimePicker, a as OrDateTimePickerItemTypes, O as OrDateTimePickerTypes } from '../OrDateTimePicker-f2e08564.js';
21
21
  export { s as OrError } from '../OrError-f90296db.js';
22
22
  export { s as OrErrorTagV3 } from '../OrErrorTag-0025b17c.js';
@@ -84,7 +84,8 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
84
84
  };
85
85
  isOpen: {
86
86
  type: BooleanConstructor;
87
- default: boolean;
87
+ required: false;
88
+ default: undefined;
88
89
  };
89
90
  }, import("@vue/composition-api").ExtractPropTypes<{
90
91
  titleText: {
@@ -139,7 +140,8 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
139
140
  };
140
141
  isOpen: {
141
142
  type: BooleanConstructor;
142
- default: boolean;
143
+ required: false;
144
+ default: undefined;
143
145
  };
144
146
  }>> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
145
147
  titleText: string;
@@ -1,4 +1,4 @@
1
- export { C as ConfirmType, s as OrConfirmV3 } from '../../OrConfirm-a7f9404b.js';
1
+ export { C as ConfirmType, s as OrConfirmV3 } from '../../OrConfirm-ea316da1.js';
2
2
  import '@vueuse/core';
3
3
  import '@vueuse/math';
4
4
  import 'vue-demi';
@@ -16,7 +16,7 @@ export { s as OrCode, O as OrCodeLanguages } from './OrCode-5ed69c23.js';
16
16
  export { s as OrCollapse } from './OrCollapse-445141ab.js';
17
17
  export { s as OrColorPicker, h as amber, n as black, b as blue, m as blueGrey, k as brown, c as cyan, j as deepOrange, d as deepPurple, g as green, i as indigo, l as lightBlue, e as lightGreen, f as lime, o as orange, p as pink, a as purple, r as red, t as teal, w as white, y as yellow } from './OrColorPicker-189cb097.js';
18
18
  export { s as OrConfirm } from './OrConfirm-c11ee2ec.js';
19
- export { C as ConfirmType, s as OrConfirmV3 } from './OrConfirm-a7f9404b.js';
19
+ export { C as ConfirmType, s as OrConfirmV3 } from './OrConfirm-ea316da1.js';
20
20
  export { D as DEFAULT_TEXT, s as OrDateTimePicker, a as OrDateTimePickerItemTypes, O as OrDateTimePickerTypes } from './OrDateTimePicker-f2e08564.js';
21
21
  export { s as OrError } from './OrError-f90296db.js';
22
22
  export { s as OrErrorTagV3 } from './OrErrorTag-0025b17c.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/ui-components",
3
- "version": "2.74.1",
3
+ "version": "2.74.2-beta.2295.0",
4
4
  "description": "Vue components library for v2/3",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/auto/index.js",
@@ -124,6 +124,5 @@
124
124
  "default": "./dist/bundled/v3/components/*/index.js"
125
125
  },
126
126
  "./package.json": "./package.json"
127
- },
128
- "gitHead": "17399f3f28f7d2e50877067e710703993cc06a59"
127
+ }
129
128
  }
@@ -81,10 +81,6 @@ export default {
81
81
  textConfirmationError: {
82
82
  control: { type: 'text' },
83
83
  },
84
-
85
- isOpen: {
86
- control: { type: 'boolean' },
87
- },
88
84
  },
89
85
 
90
86
  parameters: {
@@ -115,10 +111,7 @@ const Template: StoryFn<typeof OrConfirm> = (args) => ({
115
111
  confirm,
116
112
  onOpen: action('open'),
117
113
  onClose: action('close'),
118
- onConfirm: (event: any) => {
119
- action('confirm')(event);
120
- confirm.value?.close(); // you should close OrConfirm manually or you can set loading=true before closing
121
- },
114
+ onConfirm: action('confirm'),
122
115
  };
123
116
  },
124
117
 
@@ -147,54 +140,6 @@ const Template: StoryFn<typeof OrConfirm> = (args) => ({
147
140
  `,
148
141
  });
149
142
 
150
- const TemplateIsOpen: StoryFn<typeof OrConfirm> = (args) => ({
151
- components: {
152
- OrConfirm,
153
- OrButton,
154
- },
155
-
156
- setup() {
157
- const isOpen = ref(args.isOpen);
158
- return {
159
- args,
160
- isOpen,
161
- onOpen: action('open'),
162
- onClose: () => {
163
- isOpen.value = false;
164
- action('close');
165
- },
166
- onConfirm: (event: any) => {
167
- isOpen.value = false;
168
- action('confirm')(event);
169
- },
170
- };
171
- },
172
-
173
- template: `
174
- <div class="contents">
175
- <OrButton @click="isOpen = true">Confirmation modal</OrButton>
176
-
177
- <OrConfirm
178
- v-bind="args"
179
- :is-open="isOpen"
180
- @open="onOpen"
181
- @close="onClose"
182
- @confirm="onConfirm"
183
- >
184
- <template #default v-if="args.default">
185
- ${args.default}
186
- </template>
187
- <template #header v-if="args.header">
188
- ${args.header}
189
- </template>
190
- <template #footer v-if="args.footer">
191
- ${args.footer}
192
- </template>
193
- </OrConfirm>
194
- </div>
195
- `,
196
- });
197
-
198
143
  export const Default = Template.bind({});
199
144
  Default.args = {
200
145
  titleText: 'Delete permanently',
@@ -244,8 +189,61 @@ ConfirmButtonColor.args = {
244
189
  confirmButtonText: 'Yes',
245
190
  cancelButtonText: 'No',
246
191
  };
192
+
193
+
194
+ const TemplateIsOpen: StoryFn<typeof OrConfirm> = (args) => ({
195
+ components: {
196
+ OrConfirm,
197
+ OrButton,
198
+ },
199
+
200
+ setup() {
201
+ const isOpen = ref(args.isOpen);
202
+ return {
203
+ args,
204
+ isOpen,
205
+ onClose: () => {
206
+ isOpen.value = false;
207
+ action('close')();
208
+ },
209
+ onConfirm: () => {
210
+ action('confirm')();
211
+ },
212
+ };
213
+ },
214
+
215
+ template: `
216
+ <div class="contents">
217
+ <OrButton @click="() => isOpen = true">Confirmation modal</OrButton>
218
+
219
+ <OrConfirm
220
+ v-bind="args"
221
+ :is-open="isOpen"
222
+ @close="onClose"
223
+ @confirm="onConfirm"
224
+ >
225
+ <template #default v-if="args.default">
226
+ ${args.default}
227
+ </template>
228
+ <template #header v-if="args.header">
229
+ ${args.header}
230
+ </template>
231
+ <template #footer v-if="args.footer">
232
+ ${args.footer}
233
+ </template>
234
+ </OrConfirm>
235
+ </div>
236
+ `,
237
+ });
247
238
  export const UsingIsOpenProp = TemplateIsOpen.bind({});
239
+ UsingIsOpenProp.argTypes = {
240
+ isOpen: {
241
+ control: { type: 'boolean' },
242
+ },
243
+ };
244
+
248
245
  UsingIsOpenProp.args = {
246
+ isOpen: 'true',
249
247
  titleText: 'Confirm',
250
248
  default: `Are you sure you want to <i>${Faker.hacker.verb()}</i> the <b>${Faker.hacker.noun()}</b>?`,
251
249
  confirmType: ConfirmType.C,
@@ -148,7 +148,8 @@ export default defineComponent({
148
148
 
149
149
  isOpen: {
150
150
  type: Boolean,
151
- default: false,
151
+ required: false,
152
+ default: undefined,
152
153
  },
153
154
  },
154
155
 
@@ -192,10 +193,16 @@ export default defineComponent({
192
193
  // Methods
193
194
  function open(): void {
194
195
  isActive.value = true;
196
+ if (props.isOpen === undefined) {
197
+ emit('open');
198
+ }
195
199
  }
196
200
 
197
201
  function close(): void {
198
- isActive.value = false;
202
+ if (props.isOpen === undefined) {
203
+ isActive.value = false;
204
+ }
205
+ emit('close');
199
206
  }
200
207
 
201
208
  function confirm(): void {
@@ -212,12 +219,10 @@ export default defineComponent({
212
219
  }
213
220
 
214
221
  // Events
215
- watch(isActive, (value: boolean) => emit(value ? 'open' : 'close'));
216
-
217
- watch(() => props.isOpen, (newIsOpen) => {
218
- if (newIsOpen) {
222
+ watch(() => props.isOpen, (value) => {
223
+ if (value === true) {
219
224
  open();
220
- } else {
225
+ } else if (value === false) {
221
226
  close();
222
227
  }
223
228
  }, { immediate: true });