@onereach/ui-components 2.74.1 → 2.74.2-beta.2297.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'],
@@ -134,7 +135,7 @@ var script = defineComponent({
134
135
  const confirmationButton = ref();
135
136
  // State
136
137
  const touched = ref(false);
137
- const isActive = ref(false);
138
+ const isActive = ref(props.isOpen || false);
138
139
  const isInputActive = ref(false);
139
140
  const confirmationValue = ref('');
140
141
  const {
@@ -149,9 +150,16 @@ var script = defineComponent({
149
150
  // Methods
150
151
  function open() {
151
152
  isActive.value = true;
153
+ emit('open');
152
154
  }
153
155
  function close() {
154
- isActive.value = false;
156
+ // In case if component opened by isOpen - only event can be emited, app will catch it and flip reference
157
+ if (props.isOpen === true) {
158
+ emit('close');
159
+ } else {
160
+ isActive.value = false;
161
+ emit('close');
162
+ }
155
163
  }
156
164
  function confirm() {
157
165
  if (!props.disabled && !isInvalid.value) emit('confirm');
@@ -164,12 +172,10 @@ var script = defineComponent({
164
172
  touched.value = true;
165
173
  }
166
174
  // Events
167
- watch(isActive, value => emit(value ? 'open' : 'close'));
168
- watch(() => props.isOpen, newIsOpen => {
169
- if (newIsOpen) {
170
- open();
171
- } else {
172
- close();
175
+ watch(() => props.isOpen, value => {
176
+ // In case if component opened by isOpen - no need to emmit events, we need just sync local state
177
+ if (value != undefined) {
178
+ isActive.value = value;
173
179
  }
174
180
  }, {
175
181
  immediate: true
@@ -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-36302f66.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-36302f66.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-36302f66.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'],
@@ -135,7 +136,7 @@ var script = defineComponent({
135
136
  const confirmationButton = ref();
136
137
  // State
137
138
  const touched = ref(false);
138
- const isActive = ref(false);
139
+ const isActive = ref(props.isOpen || false);
139
140
  const isInputActive = ref(false);
140
141
  const confirmationValue = ref('');
141
142
  const {
@@ -150,9 +151,16 @@ var script = defineComponent({
150
151
  // Methods
151
152
  function open() {
152
153
  isActive.value = true;
154
+ emit('open');
153
155
  }
154
156
  function close() {
155
- isActive.value = false;
157
+ // In case if component opened by isOpen - only event can be emited, app will catch it and flip reference
158
+ if (props.isOpen === true) {
159
+ emit('close');
160
+ } else {
161
+ isActive.value = false;
162
+ emit('close');
163
+ }
156
164
  }
157
165
  function confirm() {
158
166
  if (!props.disabled && !isInvalid.value) emit('confirm');
@@ -165,12 +173,10 @@ var script = defineComponent({
165
173
  touched.value = true;
166
174
  }
167
175
  // Events
168
- watch(isActive, value => emit(value ? 'open' : 'close'));
169
- watch(() => props.isOpen, newIsOpen => {
170
- if (newIsOpen) {
171
- open();
172
- } else {
173
- close();
176
+ watch(() => props.isOpen, value => {
177
+ // In case if component opened by isOpen - no need to emmit events, we need just sync local state
178
+ if (value != undefined) {
179
+ isActive.value = value;
174
180
  }
175
181
  }, {
176
182
  immediate: true
@@ -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-4a2b7647.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-4a2b7647.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-4a2b7647.js';
43
+ export { C as ConfirmType, s as OrConfirmV3 } from './OrConfirm.vue_vue_type_script_lang-4a2b7647.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'],
@@ -133,7 +134,7 @@ var script = defineComponent({
133
134
  const confirmationButton = ref();
134
135
  // State
135
136
  const touched = ref(false);
136
- const isActive = ref(false);
137
+ const isActive = ref(props.isOpen || false);
137
138
  const isInputActive = ref(false);
138
139
  const confirmationValue = ref('');
139
140
  const {
@@ -148,9 +149,16 @@ var script = defineComponent({
148
149
  // Methods
149
150
  function open() {
150
151
  isActive.value = true;
152
+ emit('open');
151
153
  }
152
154
  function close() {
153
- isActive.value = false;
155
+ // In case if component opened by isOpen - only event can be emited, app will catch it and flip reference
156
+ if (props.isOpen === true) {
157
+ emit('close');
158
+ } else {
159
+ isActive.value = false;
160
+ emit('close');
161
+ }
154
162
  }
155
163
  function confirm() {
156
164
  if (!props.disabled && !isInvalid.value) emit('confirm');
@@ -163,12 +171,10 @@ var script = defineComponent({
163
171
  touched.value = true;
164
172
  }
165
173
  // Events
166
- watch(isActive, value => emit(value ? 'open' : 'close'));
167
- watch(() => props.isOpen, newIsOpen => {
168
- if (newIsOpen) {
169
- open();
170
- } else {
171
- close();
174
+ watch(() => props.isOpen, value => {
175
+ // In case if component opened by isOpen - no need to emmit events, we need just sync local state
176
+ if (value != undefined) {
177
+ isActive.value = value;
172
178
  }
173
179
  }, {
174
180
  immediate: true
@@ -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-ea7fc8e7.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-ea7fc8e7.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-ea7fc8e7.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'],
@@ -133,7 +134,7 @@ var script = defineComponent({
133
134
  const confirmationButton = ref();
134
135
  // State
135
136
  const touched = ref(false);
136
- const isActive = ref(false);
137
+ const isActive = ref(props.isOpen || false);
137
138
  const isInputActive = ref(false);
138
139
  const confirmationValue = ref('');
139
140
  const {
@@ -148,9 +149,16 @@ var script = defineComponent({
148
149
  // Methods
149
150
  function open() {
150
151
  isActive.value = true;
152
+ emit('open');
151
153
  }
152
154
  function close() {
153
- isActive.value = false;
155
+ // In case if component opened by isOpen - only event can be emited, app will catch it and flip reference
156
+ if (props.isOpen === true) {
157
+ emit('close');
158
+ } else {
159
+ isActive.value = false;
160
+ emit('close');
161
+ }
154
162
  }
155
163
  function confirm() {
156
164
  if (!props.disabled && !isInvalid.value) emit('confirm');
@@ -163,12 +171,10 @@ var script = defineComponent({
163
171
  touched.value = true;
164
172
  }
165
173
  // Events
166
- watch(isActive, value => emit(value ? 'open' : 'close'));
167
- watch(() => props.isOpen, newIsOpen => {
168
- if (newIsOpen) {
169
- open();
170
- } else {
171
- close();
174
+ watch(() => props.isOpen, value => {
175
+ // In case if component opened by isOpen - no need to emmit events, we need just sync local state
176
+ if (value != undefined) {
177
+ isActive.value = value;
172
178
  }
173
179
  }, {
174
180
  immediate: true
@@ -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-75813c12.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-75813c12.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-75813c12.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.2297.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
 
@@ -173,7 +174,7 @@ export default defineComponent({
173
174
 
174
175
  // State
175
176
  const touched = ref(false);
176
- const isActive = ref(false);
177
+ const isActive = ref(props.isOpen || false);
177
178
  const isInputActive = ref(false);
178
179
  const confirmationValue = ref<string>('');
179
180
 
@@ -192,10 +193,17 @@ export default defineComponent({
192
193
  // Methods
193
194
  function open(): void {
194
195
  isActive.value = true;
196
+ emit('open');
195
197
  }
196
198
 
197
199
  function close(): void {
198
- isActive.value = false;
200
+ // In case if component opened by isOpen - only event can be emited, app will catch it and flip reference
201
+ if (props.isOpen === true) {
202
+ emit('close');
203
+ } else {
204
+ isActive.value = false;
205
+ emit('close');
206
+ }
199
207
  }
200
208
 
201
209
  function confirm(): void {
@@ -212,13 +220,10 @@ export default defineComponent({
212
220
  }
213
221
 
214
222
  // Events
215
- watch(isActive, (value: boolean) => emit(value ? 'open' : 'close'));
216
-
217
- watch(() => props.isOpen, (newIsOpen) => {
218
- if (newIsOpen) {
219
- open();
220
- } else {
221
- close();
223
+ watch(() => props.isOpen, (value) => {
224
+ // In case if component opened by isOpen - no need to emmit events, we need just sync local state
225
+ if (value != undefined) {
226
+ isActive.value = value;
222
227
  }
223
228
  }, { immediate: true });
224
229