@plaidev/karte-action-sdk 1.1.108-27919072.89513d87 → 1.1.108-27919404.8048beda

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/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { writable, get } from 'svelte/store';
2
2
  import { linear, elasticOut, cubicOut } from 'svelte/easing';
3
3
  import { SvelteComponent, init, safe_not_equal, append_styles, create_slot, create_component, space, mount_component, insert, update_slot_base, get_all_dirty_from_scope, get_slot_changes, transition_in, transition_out, destroy_component, detach, empty, group_outros, check_outros, component_subscribe, element, attr, noop, listen, is_function, append, add_render_callback, create_in_transition, svg_element, binding_callbacks, destroy_each, text, set_data, null_to_empty, src_url_equal, set_style } from 'svelte/internal';
4
- import { createEventDispatcher, onMount, onDestroy as onDestroy$1, setContext, getContext } from 'svelte';
4
+ import { setContext, getContext, createEventDispatcher, onMount, onDestroy as onDestroy$1 } from 'svelte';
5
5
 
6
6
  /**
7
7
  * 内部的に使われている、UIから選択できない関数
@@ -461,6 +461,10 @@ function updateCustomVariables(variables) {
461
461
  });
462
462
  return getCustomVariables();
463
463
  }
464
+ /**
465
+ * Store for form data
466
+ */
467
+ const formData = writable({});
464
468
 
465
469
  const ALL_ACTION_ID = 'KARTE_ALL_ACTION_ID';
466
470
  const ALL_ACTION_SHORTEN_ID = 'KARTE_ALL_ACTION_SHORTEN_ID';
@@ -1821,8 +1825,8 @@ function add_css$j(target) {
1821
1825
  append_styles(target, "svelte-2qb6dm", ".state-item.svelte-2qb6dm{position:absolute;display:none}");
1822
1826
  }
1823
1827
 
1824
- // (11:0) {#if $state === path}
1825
- function create_if_block$3(ctx) {
1828
+ // (23:0) {#if $state === path}
1829
+ function create_if_block$4(ctx) {
1826
1830
  let div;
1827
1831
  let t;
1828
1832
  let current;
@@ -1887,7 +1891,7 @@ function create_if_block$3(ctx) {
1887
1891
  function create_fragment$n(ctx) {
1888
1892
  let if_block_anchor;
1889
1893
  let current;
1890
- let if_block = /*$state*/ ctx[1] === /*path*/ ctx[0] && create_if_block$3(ctx);
1894
+ let if_block = /*$state*/ ctx[1] === /*path*/ ctx[0] && create_if_block$4(ctx);
1891
1895
 
1892
1896
  return {
1893
1897
  c() {
@@ -1908,7 +1912,7 @@ function create_fragment$n(ctx) {
1908
1912
  transition_in(if_block, 1);
1909
1913
  }
1910
1914
  } else {
1911
- if_block = create_if_block$3(ctx);
1915
+ if_block = create_if_block$4(ctx);
1912
1916
  if_block.c();
1913
1917
  transition_in(if_block, 1);
1914
1918
  if_block.m(if_block_anchor.parentNode, if_block_anchor);
@@ -1939,11 +1943,18 @@ function create_fragment$n(ctx) {
1939
1943
  };
1940
1944
  }
1941
1945
 
1946
+ const STATE_ITEM_CONTEXT_KEY = Symbol();
1947
+
1948
+ function getStateItemContext() {
1949
+ return getContext(STATE_ITEM_CONTEXT_KEY);
1950
+ }
1951
+
1942
1952
  function instance$n($$self, $$props, $$invalidate) {
1943
1953
  let $state;
1944
1954
  component_subscribe($$self, state, $$value => $$invalidate(1, $state = $$value));
1945
1955
  let { $$slots: slots = {}, $$scope } = $$props;
1946
1956
  let { path } = $$props;
1957
+ setContext(STATE_ITEM_CONTEXT_KEY, { path });
1947
1958
 
1948
1959
  $$self.$$set = $$props => {
1949
1960
  if ('path' in $$props) $$invalidate(0, path = $$props.path);
@@ -1975,7 +1986,7 @@ function add_css$i(target) {
1975
1986
  }
1976
1987
 
1977
1988
  // (9:0) {#if backgroundOverray}
1978
- function create_if_block$2(ctx) {
1989
+ function create_if_block$3(ctx) {
1979
1990
  let div;
1980
1991
  let mounted;
1981
1992
  let dispose;
@@ -2004,7 +2015,7 @@ function create_if_block$2(ctx) {
2004
2015
 
2005
2016
  function create_fragment$m(ctx) {
2006
2017
  let if_block_anchor;
2007
- let if_block = /*backgroundOverray*/ ctx[0] && create_if_block$2(ctx);
2018
+ let if_block = /*backgroundOverray*/ ctx[0] && create_if_block$3(ctx);
2008
2019
 
2009
2020
  return {
2010
2021
  c() {
@@ -2020,7 +2031,7 @@ function create_fragment$m(ctx) {
2020
2031
  if (if_block) {
2021
2032
  if_block.p(ctx, dirty);
2022
2033
  } else {
2023
- if_block = create_if_block$2(ctx);
2034
+ if_block = create_if_block$3(ctx);
2024
2035
  if_block.c();
2025
2036
  if_block.m(if_block_anchor.parentNode, if_block_anchor);
2026
2037
  }
@@ -2064,7 +2075,7 @@ function add_css$h(target) {
2064
2075
  }
2065
2076
 
2066
2077
  // (142:0) {#if visible}
2067
- function create_if_block$1(ctx) {
2078
+ function create_if_block$2(ctx) {
2068
2079
  let div1;
2069
2080
  let t;
2070
2081
  let div0;
@@ -2258,7 +2269,7 @@ function create_fragment$l(ctx) {
2258
2269
  if (is_function(/*backgroundClick*/ ctx[12])) /*backgroundClick*/ ctx[12].apply(this, arguments);
2259
2270
  });
2260
2271
 
2261
- let if_block = /*visible*/ ctx[6] && create_if_block$1(ctx);
2272
+ let if_block = /*visible*/ ctx[6] && create_if_block$2(ctx);
2262
2273
 
2263
2274
  return {
2264
2275
  c() {
@@ -2296,7 +2307,7 @@ function create_fragment$l(ctx) {
2296
2307
  transition_in(if_block, 1);
2297
2308
  }
2298
2309
  } else {
2299
- if_block = create_if_block$1(ctx);
2310
+ if_block = create_if_block$2(ctx);
2300
2311
  if_block.c();
2301
2312
  transition_in(if_block, 1);
2302
2313
  if_block.m(if_block_anchor.parentNode, if_block_anchor);
@@ -3331,14 +3342,14 @@ class FlexItem extends SvelteComponent {
3331
3342
 
3332
3343
  /* src/components/RenderText.svelte generated by Svelte v3.53.1 */
3333
3344
 
3334
- function get_each_context$1(ctx, list, i) {
3345
+ function get_each_context$2(ctx, list, i) {
3335
3346
  const child_ctx = ctx.slice();
3336
3347
  child_ctx[2] = list[i];
3337
3348
  return child_ctx;
3338
3349
  }
3339
3350
 
3340
3351
  // (12:2) {:else}
3341
- function create_else_block(ctx) {
3352
+ function create_else_block$1(ctx) {
3342
3353
  let t_value = /*item*/ ctx[2] + "";
3343
3354
  let t;
3344
3355
 
@@ -3359,7 +3370,7 @@ function create_else_block(ctx) {
3359
3370
  }
3360
3371
 
3361
3372
  // (10:2) {#if item.match(regexp)}
3362
- function create_if_block(ctx) {
3373
+ function create_if_block$1(ctx) {
3363
3374
  let br;
3364
3375
 
3365
3376
  return {
@@ -3377,15 +3388,15 @@ function create_if_block(ctx) {
3377
3388
  }
3378
3389
 
3379
3390
  // (9:0) {#each items as item}
3380
- function create_each_block$1(ctx) {
3391
+ function create_each_block$2(ctx) {
3381
3392
  let show_if;
3382
3393
  let if_block_anchor;
3383
3394
 
3384
3395
  function select_block_type(ctx, dirty) {
3385
3396
  if (dirty & /*items*/ 1) show_if = null;
3386
3397
  if (show_if == null) show_if = !!/*item*/ ctx[2].match(regexp);
3387
- if (show_if) return create_if_block;
3388
- return create_else_block;
3398
+ if (show_if) return create_if_block$1;
3399
+ return create_else_block$1;
3389
3400
  }
3390
3401
 
3391
3402
  let current_block_type = select_block_type(ctx, -1);
@@ -3426,7 +3437,7 @@ function create_fragment$f(ctx) {
3426
3437
  let each_blocks = [];
3427
3438
 
3428
3439
  for (let i = 0; i < each_value.length; i += 1) {
3429
- each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i));
3440
+ each_blocks[i] = create_each_block$2(get_each_context$2(ctx, each_value, i));
3430
3441
  }
3431
3442
 
3432
3443
  return {
@@ -3450,12 +3461,12 @@ function create_fragment$f(ctx) {
3450
3461
  let i;
3451
3462
 
3452
3463
  for (i = 0; i < each_value.length; i += 1) {
3453
- const child_ctx = get_each_context$1(ctx, each_value, i);
3464
+ const child_ctx = get_each_context$2(ctx, each_value, i);
3454
3465
 
3455
3466
  if (each_blocks[i]) {
3456
3467
  each_blocks[i].p(child_ctx, dirty);
3457
3468
  } else {
3458
- each_blocks[i] = create_each_block$1(child_ctx);
3469
+ each_blocks[i] = create_each_block$2(child_ctx);
3459
3470
  each_blocks[i].c();
3460
3471
  each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
3461
3472
  }
@@ -4652,180 +4663,103 @@ class MovieVimeoElement extends SvelteComponent {
4652
4663
  }
4653
4664
  }
4654
4665
 
4655
- /* src/components/Form.svelte generated by Svelte v3.53.1 */
4656
-
4657
- function add_css$5(target) {
4658
- append_styles(target, "svelte-1il0aow", ".form.svelte-1il0aow{width:100%;height:100%}");
4659
- }
4660
-
4661
- function create_fragment$6(ctx) {
4662
- let div;
4663
- let current;
4664
- const default_slot_template = /*#slots*/ ctx[4].default;
4665
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[3], null);
4666
-
4667
- return {
4668
- c() {
4669
- div = element("div");
4670
- if (default_slot) default_slot.c();
4671
- attr(div, "class", "form svelte-1il0aow");
4672
- },
4673
- m(target, anchor) {
4674
- insert(target, div, anchor);
4675
-
4676
- if (default_slot) {
4677
- default_slot.m(div, null);
4678
- }
4679
-
4680
- current = true;
4681
- },
4682
- p(ctx, [dirty]) {
4683
- if (default_slot) {
4684
- if (default_slot.p && (!current || dirty & /*$$scope*/ 8)) {
4685
- update_slot_base(
4686
- default_slot,
4687
- default_slot_template,
4688
- ctx,
4689
- /*$$scope*/ ctx[3],
4690
- !current
4691
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[3])
4692
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[3], dirty, null),
4693
- null
4694
- );
4695
- }
4696
- }
4697
- },
4698
- i(local) {
4699
- if (current) return;
4700
- transition_in(default_slot, local);
4701
- current = true;
4702
- },
4703
- o(local) {
4704
- transition_out(default_slot, local);
4705
- current = false;
4706
- },
4707
- d(detaching) {
4708
- if (detaching) detach(div);
4709
- if (default_slot) default_slot.d(detaching);
4710
- }
4711
- };
4712
- }
4713
-
4714
- const FORM_CONTEXT_KEY = Symbol();
4715
-
4716
- function getValue($formData, name) {
4717
- return $formData._data[name];
4718
- }
4719
-
4720
- function updateValue(data, name, update) {
4721
- data.update(prev => {
4722
- const { value, isValid } = update(prev._data[name]);
4723
- prev._data[name] = value;
4724
- prev._isValidMap[name] = isValid;
4725
- return { ...prev };
4726
- });
4727
- }
4728
-
4729
- function checkIfDataAreValid($formData) {
4730
- const dataAreValid = Object.entries($formData._data).reduce(
4731
- (dataAreValid, [name]) => {
4732
- return dataAreValid && ($formData._isValidMap[name] ?? true);
4733
- },
4734
- true
4735
- );
4736
-
4737
- return dataAreValid;
4666
+ function registerInput({ name, statePath, validator = () => true, initialValue, }) {
4667
+ const writableValue = {
4668
+ subscribe(run) {
4669
+ return formData.subscribe(formData => {
4670
+ run(formData[name]?.value);
4671
+ });
4672
+ },
4673
+ set(value) {
4674
+ formData.update(prev => ({
4675
+ ...prev,
4676
+ [name]: {
4677
+ statePath,
4678
+ value,
4679
+ isValid: validator(value),
4680
+ },
4681
+ }));
4682
+ },
4683
+ update(updater) {
4684
+ formData.update(prev => {
4685
+ const prevValue = prev[name]?.value;
4686
+ return {
4687
+ ...prev,
4688
+ [name]: {
4689
+ statePath,
4690
+ value: updater(prevValue),
4691
+ isValid: validator(prevValue),
4692
+ },
4693
+ };
4694
+ });
4695
+ },
4696
+ };
4697
+ writableValue.set(initialValue);
4698
+ return writableValue;
4699
+ }
4700
+ function deleteValues(statePath) {
4701
+ formData.update(prev => {
4702
+ const targetNames = Object.entries(prev)
4703
+ .filter(([_, { statePath: s }]) => s === statePath)
4704
+ .map(([name]) => name);
4705
+ targetNames.forEach(name => {
4706
+ delete prev[name];
4707
+ });
4708
+ return { ...prev };
4709
+ });
4738
4710
  }
4739
-
4740
- const createFormDataAccessor = formId => {
4741
- const variableKey = `_form_${formId}`;
4742
-
4743
- const update = updater => {
4744
- customVariables.update(prev => {
4745
- const updatedFormData = updater(prev[variableKey] ?? {});
4746
- return { ...prev, [variableKey]: updatedFormData };
4747
- });
4748
- };
4749
-
4750
- const subscribe = run => {
4751
- return customVariables.subscribe(value => {
4752
- const formData = value[variableKey] ?? {};
4753
- run(formData);
4754
- });
4755
- };
4756
-
4757
- const set = value => {
4758
- customVariables.update(prev => {
4759
- return { ...prev, [variableKey]: value };
4760
- });
4761
- };
4762
-
4763
- return { update, set, subscribe };
4764
- };
4765
-
4766
- function instance$6($$self, $$props, $$invalidate) {
4767
- let $formData;
4768
- let $formComponentData;
4769
- let { $$slots: slots = {}, $$scope } = $$props;
4770
- let { formId = 'form0' } = $$props;
4771
- const formComponentData = writable({ _data: {}, _isValidMap: {} });
4772
- component_subscribe($$self, formComponentData, value => $$invalidate(6, $formComponentData = value));
4773
-
4774
- setContext(FORM_CONTEXT_KEY, {
4775
- formComponentData,
4776
- submit: ({ stateId }) => {
4777
- if (checkIfDataAreValid($formComponentData)) {
4778
- formData.update(prev => ({ ...prev, ...$formComponentData._data }));
4779
- console.log('will send', $formData);
4780
- setState$1(stateId, true);
4781
- }
4782
- },
4783
- next: ({ stateId }) => {
4784
- if (checkIfDataAreValid($formComponentData)) {
4785
- formData.update(prev => ({ ...prev, ...$formComponentData._data }));
4786
- setState$1(stateId, true);
4787
- console.log('formData after next()', $formData);
4788
- }
4789
- },
4790
- prev: ({ stateId }) => {
4791
- formData.update(prev => {
4792
- Object.keys($formComponentData._data).forEach(name => {
4793
- delete prev[name];
4794
- });
4795
-
4796
- return { ...prev };
4797
- });
4798
-
4799
- setState$1(stateId, true);
4800
- console.log('formData after prev()', $formData);
4801
- }
4802
- });
4803
-
4804
- const formData = createFormDataAccessor(formId);
4805
- component_subscribe($$self, formData, value => $$invalidate(5, $formData = value));
4806
-
4807
- $$self.$$set = $$props => {
4808
- if ('formId' in $$props) $$invalidate(2, formId = $$props.formId);
4809
- if ('$$scope' in $$props) $$invalidate(3, $$scope = $$props.$$scope);
4810
- };
4811
-
4812
- return [formComponentData, formData, formId, $$scope, slots];
4711
+ const getValuesAreValidReader = statePath => ({
4712
+ subscribe(callback) {
4713
+ return formData.subscribe(formData => {
4714
+ const valuesAreValid = Object.entries(formData)
4715
+ .filter(([_, { statePath: s }]) => s === statePath)
4716
+ .every(([_, { isValid }]) => isValid);
4717
+ callback(valuesAreValid);
4718
+ });
4719
+ },
4720
+ });
4721
+ function formDataToEventValues(campaignId, formData) {
4722
+ const questions = [];
4723
+ const answersMap = {};
4724
+ Object.entries(formData).forEach(([name, dataItem]) => {
4725
+ questions.push(name);
4726
+ const value = dataItem.value;
4727
+ const answerKey = `question_${name}`;
4728
+ if (Array.isArray(value)) {
4729
+ answersMap[answerKey] = {
4730
+ choices: value,
4731
+ };
4732
+ }
4733
+ else if (typeof value === 'string') {
4734
+ answersMap[answerKey] = {
4735
+ free_answer: value,
4736
+ };
4737
+ }
4738
+ });
4739
+ return {
4740
+ [campaignId]: {
4741
+ questions,
4742
+ ...answersMap,
4743
+ },
4744
+ };
4813
4745
  }
4814
-
4815
- class Form extends SvelteComponent {
4816
- constructor(options) {
4817
- super();
4818
- init(this, options, instance$6, create_fragment$6, safe_not_equal, { formId: 2 }, add_css$5);
4819
- }
4746
+ function submit() {
4747
+ const systemConfig = getSystem();
4748
+ const campaignId = systemConfig.campaignId;
4749
+ if (campaignId) {
4750
+ const formData$1 = get(formData);
4751
+ const values = formDataToEventValues(campaignId, formData$1);
4752
+ send_event('_answer_question', values);
4753
+ }
4820
4754
  }
4821
4755
 
4822
4756
  /* src/components/FormTextarea.svelte generated by Svelte v3.53.1 */
4823
4757
 
4824
- function add_css$4(target) {
4758
+ function add_css$5(target) {
4825
4759
  append_styles(target, "svelte-kyay3k", ".textarea-wrapper.svelte-kyay3k{display:flex;align-items:center;width:100%;height:100%}.textarea.svelte-kyay3k{width:100%;resize:none}");
4826
4760
  }
4827
4761
 
4828
- function create_fragment$5(ctx) {
4762
+ function create_fragment$6(ctx) {
4829
4763
  let div;
4830
4764
  let textarea;
4831
4765
  let mounted;
@@ -4836,7 +4770,7 @@ function create_fragment$5(ctx) {
4836
4770
  div = element("div");
4837
4771
  textarea = element("textarea");
4838
4772
  attr(textarea, "class", "textarea svelte-kyay3k");
4839
- textarea.value = /*value*/ ctx[3];
4773
+ textarea.value = /*$value*/ ctx[3];
4840
4774
  textarea.required = /*required*/ ctx[0];
4841
4775
  attr(textarea, "rows", /*rows*/ ctx[1]);
4842
4776
  attr(textarea, "placeholder", /*placeholder*/ ctx[2]);
@@ -4852,8 +4786,8 @@ function create_fragment$5(ctx) {
4852
4786
  }
4853
4787
  },
4854
4788
  p(ctx, [dirty]) {
4855
- if (dirty & /*value*/ 8) {
4856
- textarea.value = /*value*/ ctx[3];
4789
+ if (dirty & /*$value*/ 8) {
4790
+ textarea.value = /*$value*/ ctx[3];
4857
4791
  }
4858
4792
 
4859
4793
  if (dirty & /*required*/ 1) {
@@ -4878,30 +4812,30 @@ function create_fragment$5(ctx) {
4878
4812
  };
4879
4813
  }
4880
4814
 
4881
- function instance$5($$self, $$props, $$invalidate) {
4882
- let value;
4883
- let $formComponentData;
4815
+ function instance$6($$self, $$props, $$invalidate) {
4816
+ let $value;
4884
4817
  let { name = '' } = $$props;
4885
4818
  let { required = true } = $$props;
4886
4819
  let { rows = 2 } = $$props;
4887
4820
  let { placeholder = '' } = $$props;
4888
- const { formComponentData } = getContext(FORM_CONTEXT_KEY);
4889
- component_subscribe($$self, formComponentData, value => $$invalidate(7, $formComponentData = value));
4890
-
4891
- function setValue(value) {
4892
- updateValue(formComponentData, name, () => ({
4893
- value,
4894
- isValid: required ? !!value : true
4895
- }));
4896
- }
4821
+ const { path: statePath } = getStateItemContext();
4822
+
4823
+ const value = registerInput({
4824
+ name,
4825
+ statePath,
4826
+ initialValue: '',
4827
+ validator(value) {
4828
+ return required ? !!value : true;
4829
+ }
4830
+ });
4831
+
4832
+ component_subscribe($$self, value, value => $$invalidate(3, $value = value));
4897
4833
 
4898
4834
  function handleInput(event) {
4899
- const value = event.target.value;
4900
- setValue(value);
4835
+ const updated = event.target.value;
4836
+ value.set(updated);
4901
4837
  }
4902
4838
 
4903
- setValue(value);
4904
-
4905
4839
  $$self.$$set = $$props => {
4906
4840
  if ('name' in $$props) $$invalidate(6, name = $$props.name);
4907
4841
  if ('required' in $$props) $$invalidate(0, required = $$props.required);
@@ -4909,22 +4843,7 @@ function instance$5($$self, $$props, $$invalidate) {
4909
4843
  if ('placeholder' in $$props) $$invalidate(2, placeholder = $$props.placeholder);
4910
4844
  };
4911
4845
 
4912
- $$self.$$.update = () => {
4913
- if ($$self.$$.dirty & /*$formComponentData, name*/ 192) {
4914
- $$invalidate(3, value = getValue($formComponentData, name) ?? '');
4915
- }
4916
- };
4917
-
4918
- return [
4919
- required,
4920
- rows,
4921
- placeholder,
4922
- value,
4923
- formComponentData,
4924
- handleInput,
4925
- name,
4926
- $formComponentData
4927
- ];
4846
+ return [required, rows, placeholder, $value, value, handleInput, name];
4928
4847
  }
4929
4848
 
4930
4849
  class FormTextarea extends SvelteComponent {
@@ -4934,8 +4853,8 @@ class FormTextarea extends SvelteComponent {
4934
4853
  init(
4935
4854
  this,
4936
4855
  options,
4937
- instance$5,
4938
- create_fragment$5,
4856
+ instance$6,
4857
+ create_fragment$6,
4939
4858
  safe_not_equal,
4940
4859
  {
4941
4860
  name: 6,
@@ -4943,14 +4862,14 @@ class FormTextarea extends SvelteComponent {
4943
4862
  rows: 1,
4944
4863
  placeholder: 2
4945
4864
  },
4946
- add_css$4
4865
+ add_css$5
4947
4866
  );
4948
4867
  }
4949
4868
  }
4950
4869
 
4951
4870
  /* src/components/FormButton.svelte generated by Svelte v3.53.1 */
4952
4871
 
4953
- function create_fragment$4(ctx) {
4872
+ function create_fragment$5(ctx) {
4954
4873
  let input;
4955
4874
  let mounted;
4956
4875
  let dispose;
@@ -4968,7 +4887,7 @@ function create_fragment$4(ctx) {
4968
4887
  insert(target, input, anchor);
4969
4888
 
4970
4889
  if (!mounted) {
4971
- dispose = listen(input, "click", /*handleClick*/ ctx[3]);
4890
+ dispose = listen(input, "click", /*handleClick*/ ctx[2]);
4972
4891
  mounted = true;
4973
4892
  }
4974
4893
  },
@@ -4991,89 +4910,90 @@ function create_fragment$4(ctx) {
4991
4910
  };
4992
4911
  }
4993
4912
 
4994
- function instance$4($$self, $$props, $$invalidate) {
4913
+ function instance$5($$self, $$props, $$invalidate) {
4995
4914
  let disabled;
4996
- let $formComponentData;
4915
+ let $valuesAreValid;
4997
4916
  let { text = '' } = $$props;
4998
4917
  let { type = { type: 'submit' } } = $$props;
4999
- const { formComponentData, submit, next, prev } = getContext(FORM_CONTEXT_KEY);
5000
- component_subscribe($$self, formComponentData, value => $$invalidate(5, $formComponentData = value));
4918
+ const { path: statePath } = getStateItemContext();
5001
4919
 
5002
4920
  function handleClick() {
5003
4921
  switch (type.type) {
5004
4922
  case 'submit':
5005
4923
  {
5006
- const stateId = type.stateId;
5007
- submit({ stateId });
4924
+ if ($valuesAreValid) {
4925
+ submit();
4926
+ const stateId = type.stateId;
4927
+ setState$1(stateId, true);
4928
+ }
4929
+
5008
4930
  break;
5009
4931
  }
5010
4932
  case 'next':
5011
4933
  {
5012
- const stateId = type.stateId;
5013
- next({ stateId });
4934
+ if ($valuesAreValid) {
4935
+ const stateId = type.stateId;
4936
+ setState$1(stateId, true);
4937
+ }
4938
+
5014
4939
  break;
5015
4940
  }
5016
4941
  case 'prev':
5017
4942
  {
4943
+ deleteValues(statePath);
5018
4944
  const stateId = type.stateId;
5019
- prev({ stateId });
4945
+ setState$1(stateId, true);
5020
4946
  break;
5021
4947
  }
5022
4948
  }
5023
4949
  }
5024
4950
 
4951
+ const valuesAreValid = getValuesAreValidReader(statePath);
4952
+ component_subscribe($$self, valuesAreValid, value => $$invalidate(5, $valuesAreValid = value));
4953
+
5025
4954
  $$self.$$set = $$props => {
5026
4955
  if ('text' in $$props) $$invalidate(0, text = $$props.text);
5027
4956
  if ('type' in $$props) $$invalidate(4, type = $$props.type);
5028
4957
  };
5029
4958
 
5030
4959
  $$self.$$.update = () => {
5031
- if ($$self.$$.dirty & /*type, $formComponentData*/ 48) {
4960
+ if ($$self.$$.dirty & /*type, $valuesAreValid*/ 48) {
5032
4961
  $$invalidate(1, disabled = (() => {
5033
- if (type.type === 'prev') return false;
5034
-
5035
- const dataAreValid = Object.entries($formComponentData._data).reduce(
5036
- (dataAreValid, [name]) => {
5037
- return dataAreValid && ($formComponentData._isValidMap[name] ?? true);
5038
- },
5039
- true
5040
- );
5041
-
5042
- return !dataAreValid;
4962
+ const enabled = type.type === 'prev' || $valuesAreValid;
4963
+ return !enabled;
5043
4964
  })());
5044
4965
  }
5045
4966
  };
5046
4967
 
5047
- return [text, disabled, formComponentData, handleClick, type, $formComponentData];
4968
+ return [text, disabled, handleClick, valuesAreValid, type, $valuesAreValid];
5048
4969
  }
5049
4970
 
5050
4971
  class FormButton extends SvelteComponent {
5051
4972
  constructor(options) {
5052
4973
  super();
5053
- init(this, options, instance$4, create_fragment$4, safe_not_equal, { text: 0, type: 4 });
4974
+ init(this, options, instance$5, create_fragment$5, safe_not_equal, { text: 0, type: 4 });
5054
4975
  }
5055
4976
  }
5056
4977
 
5057
4978
  /* src/components/FormRadioButtons.svelte generated by Svelte v3.53.1 */
5058
4979
 
5059
- function add_css$3(target) {
4980
+ function add_css$4(target) {
5060
4981
  append_styles(target, "svelte-1ajmbw1", ".radio-buttons.svelte-1ajmbw1{display:flex;justify-content:center;flex-direction:column;width:100%;height:100%}");
5061
4982
  }
5062
4983
 
5063
- function get_each_context(ctx, list, i) {
4984
+ function get_each_context$1(ctx, list, i) {
5064
4985
  const child_ctx = ctx.slice();
5065
- child_ctx[5] = list[i];
5066
- child_ctx[7] = i;
4986
+ child_ctx[7] = list[i];
4987
+ child_ctx[9] = i;
5067
4988
  return child_ctx;
5068
4989
  }
5069
4990
 
5070
- // (16:2) {#each _options as option, i}
5071
- function create_each_block(ctx) {
4991
+ // (23:2) {#each _options as option, i}
4992
+ function create_each_block$1(ctx) {
5072
4993
  let label;
5073
4994
  let input;
5074
- let input_value_value;
5075
4995
  let t0;
5076
- let t1_value = /*option*/ ctx[5] + "";
4996
+ let t1_value = /*option*/ ctx[7] + "";
5077
4997
  let t1;
5078
4998
  let t2;
5079
4999
  let mounted;
@@ -5088,7 +5008,7 @@ function create_each_block(ctx) {
5088
5008
  t2 = space();
5089
5009
  attr(input, "type", "radio");
5090
5010
  attr(input, "name", /*name*/ ctx[0]);
5091
- input.value = input_value_value = /*option*/ ctx[5];
5011
+ input.value = /*$value*/ ctx[2];
5092
5012
  },
5093
5013
  m(target, anchor) {
5094
5014
  insert(target, label, anchor);
@@ -5098,7 +5018,7 @@ function create_each_block(ctx) {
5098
5018
  append(label, t2);
5099
5019
 
5100
5020
  if (!mounted) {
5101
- dispose = listen(input, "change", /*handleChange*/ ctx[2](/*i*/ ctx[7]));
5021
+ dispose = listen(input, "change", /*handleChange*/ ctx[4](/*i*/ ctx[9]));
5102
5022
  mounted = true;
5103
5023
  }
5104
5024
  },
@@ -5109,11 +5029,11 @@ function create_each_block(ctx) {
5109
5029
  attr(input, "name", /*name*/ ctx[0]);
5110
5030
  }
5111
5031
 
5112
- if (dirty & /*_options*/ 2 && input_value_value !== (input_value_value = /*option*/ ctx[5])) {
5113
- input.value = input_value_value;
5032
+ if (dirty & /*$value*/ 4) {
5033
+ input.value = /*$value*/ ctx[2];
5114
5034
  }
5115
5035
 
5116
- if (dirty & /*_options*/ 2 && t1_value !== (t1_value = /*option*/ ctx[5] + "")) set_data(t1, t1_value);
5036
+ if (dirty & /*_options*/ 2 && t1_value !== (t1_value = /*option*/ ctx[7] + "")) set_data(t1, t1_value);
5117
5037
  },
5118
5038
  d(detaching) {
5119
5039
  if (detaching) detach(label);
@@ -5123,13 +5043,13 @@ function create_each_block(ctx) {
5123
5043
  };
5124
5044
  }
5125
5045
 
5126
- function create_fragment$3(ctx) {
5046
+ function create_fragment$4(ctx) {
5127
5047
  let div;
5128
5048
  let each_value = /*_options*/ ctx[1];
5129
5049
  let each_blocks = [];
5130
5050
 
5131
5051
  for (let i = 0; i < each_value.length; i += 1) {
5132
- each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
5052
+ each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i));
5133
5053
  }
5134
5054
 
5135
5055
  return {
@@ -5150,17 +5070,17 @@ function create_fragment$3(ctx) {
5150
5070
  }
5151
5071
  },
5152
5072
  p(ctx, [dirty]) {
5153
- if (dirty & /*_options, name, handleChange*/ 7) {
5073
+ if (dirty & /*_options, name, $value, handleChange*/ 23) {
5154
5074
  each_value = /*_options*/ ctx[1];
5155
5075
  let i;
5156
5076
 
5157
5077
  for (i = 0; i < each_value.length; i += 1) {
5158
- const child_ctx = get_each_context(ctx, each_value, i);
5078
+ const child_ctx = get_each_context$1(ctx, each_value, i);
5159
5079
 
5160
5080
  if (each_blocks[i]) {
5161
5081
  each_blocks[i].p(child_ctx, dirty);
5162
5082
  } else {
5163
- each_blocks[i] = create_each_block(child_ctx);
5083
+ each_blocks[i] = create_each_block$1(child_ctx);
5164
5084
  each_blocks[i].c();
5165
5085
  each_blocks[i].m(div, null);
5166
5086
  }
@@ -5182,38 +5102,264 @@ function create_fragment$3(ctx) {
5182
5102
  };
5183
5103
  }
5184
5104
 
5185
- function instance$3($$self, $$props, $$invalidate) {
5105
+ function instance$4($$self, $$props, $$invalidate) {
5186
5106
  let _options;
5107
+ let $value;
5187
5108
  let { name = '' } = $$props;
5188
5109
  let { options = '人参,レタス,キャベツ' } = $$props;
5189
- const { formComponentData } = getContext(FORM_CONTEXT_KEY);
5110
+ const { path: statePath } = getStateItemContext();
5111
+
5112
+ const value = registerInput({
5113
+ name,
5114
+ statePath,
5115
+ initialValue: [],
5116
+ validator(value) {
5117
+ return value.length > 0;
5118
+ }
5119
+ });
5120
+
5121
+ component_subscribe($$self, value, value => $$invalidate(2, $value = value));
5190
5122
 
5191
5123
  const handleChange = index => event => {
5192
5124
  if (event.target.checked) {
5193
- updateValue(formComponentData, name, () => ({ value: _options[index], isValid: true }));
5125
+ value.set([_options[index]]);
5194
5126
  }
5195
5127
  };
5196
5128
 
5197
- updateValue(formComponentData, name, () => ({ value: '', isValid: false }));
5198
-
5199
5129
  $$self.$$set = $$props => {
5200
5130
  if ('name' in $$props) $$invalidate(0, name = $$props.name);
5201
- if ('options' in $$props) $$invalidate(3, options = $$props.options);
5131
+ if ('options' in $$props) $$invalidate(5, options = $$props.options);
5202
5132
  };
5203
5133
 
5204
5134
  $$self.$$.update = () => {
5205
- if ($$self.$$.dirty & /*options*/ 8) {
5135
+ if ($$self.$$.dirty & /*options*/ 32) {
5206
5136
  $$invalidate(1, _options = options.split(','));
5207
5137
  }
5208
5138
  };
5209
5139
 
5210
- return [name, _options, handleChange, options];
5140
+ return [name, _options, $value, value, handleChange, options];
5211
5141
  }
5212
5142
 
5213
5143
  class FormRadioButtons extends SvelteComponent {
5214
5144
  constructor(options) {
5215
5145
  super();
5216
- init(this, options, instance$3, create_fragment$3, safe_not_equal, { name: 0, options: 3 }, add_css$3);
5146
+ init(this, options, instance$4, create_fragment$4, safe_not_equal, { name: 0, options: 5 }, add_css$4);
5147
+ }
5148
+ }
5149
+
5150
+ /* src/components/FormSelect.svelte generated by Svelte v3.53.1 */
5151
+
5152
+ function add_css$3(target) {
5153
+ append_styles(target, "svelte-1ajmbw1", ".radio-buttons.svelte-1ajmbw1{display:flex;justify-content:center;flex-direction:column;width:100%;height:100%}");
5154
+ }
5155
+
5156
+ function get_each_context(ctx, list, i) {
5157
+ const child_ctx = ctx.slice();
5158
+ child_ctx[6] = list[i];
5159
+ child_ctx[8] = i;
5160
+ return child_ctx;
5161
+ }
5162
+
5163
+ // (28:8) {:else}
5164
+ function create_else_block(ctx) {
5165
+ let t;
5166
+
5167
+ return {
5168
+ c() {
5169
+ t = text("回答を選択して下さい");
5170
+ },
5171
+ m(target, anchor) {
5172
+ insert(target, t, anchor);
5173
+ },
5174
+ p: noop,
5175
+ d(detaching) {
5176
+ if (detaching) detach(t);
5177
+ }
5178
+ };
5179
+ }
5180
+
5181
+ // (26:8) {#if option}
5182
+ function create_if_block(ctx) {
5183
+ let t_value = /*option*/ ctx[6] + "";
5184
+ let t;
5185
+
5186
+ return {
5187
+ c() {
5188
+ t = text(t_value);
5189
+ },
5190
+ m(target, anchor) {
5191
+ insert(target, t, anchor);
5192
+ },
5193
+ p(ctx, dirty) {
5194
+ if (dirty & /*_options*/ 1 && t_value !== (t_value = /*option*/ ctx[6] + "")) set_data(t, t_value);
5195
+ },
5196
+ d(detaching) {
5197
+ if (detaching) detach(t);
5198
+ }
5199
+ };
5200
+ }
5201
+
5202
+ // (24:4) {#each _options as option, i}
5203
+ function create_each_block(ctx) {
5204
+ let option;
5205
+ let t;
5206
+ let option_value_value;
5207
+
5208
+ function select_block_type(ctx, dirty) {
5209
+ if (/*option*/ ctx[6]) return create_if_block;
5210
+ return create_else_block;
5211
+ }
5212
+
5213
+ let current_block_type = select_block_type(ctx);
5214
+ let if_block = current_block_type(ctx);
5215
+
5216
+ return {
5217
+ c() {
5218
+ option = element("option");
5219
+ if_block.c();
5220
+ t = space();
5221
+ option.__value = option_value_value = /*option*/ ctx[6];
5222
+ option.value = option.__value;
5223
+ },
5224
+ m(target, anchor) {
5225
+ insert(target, option, anchor);
5226
+ if_block.m(option, null);
5227
+ append(option, t);
5228
+ },
5229
+ p(ctx, dirty) {
5230
+ if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block) {
5231
+ if_block.p(ctx, dirty);
5232
+ } else {
5233
+ if_block.d(1);
5234
+ if_block = current_block_type(ctx);
5235
+
5236
+ if (if_block) {
5237
+ if_block.c();
5238
+ if_block.m(option, t);
5239
+ }
5240
+ }
5241
+
5242
+ if (dirty & /*_options*/ 1 && option_value_value !== (option_value_value = /*option*/ ctx[6])) {
5243
+ option.__value = option_value_value;
5244
+ option.value = option.__value;
5245
+ }
5246
+ },
5247
+ d(detaching) {
5248
+ if (detaching) detach(option);
5249
+ if_block.d();
5250
+ }
5251
+ };
5252
+ }
5253
+
5254
+ function create_fragment$3(ctx) {
5255
+ let div;
5256
+ let select;
5257
+ let mounted;
5258
+ let dispose;
5259
+ let each_value = /*_options*/ ctx[0];
5260
+ let each_blocks = [];
5261
+
5262
+ for (let i = 0; i < each_value.length; i += 1) {
5263
+ each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
5264
+ }
5265
+
5266
+ return {
5267
+ c() {
5268
+ div = element("div");
5269
+ select = element("select");
5270
+
5271
+ for (let i = 0; i < each_blocks.length; i += 1) {
5272
+ each_blocks[i].c();
5273
+ }
5274
+
5275
+ attr(div, "class", "radio-buttons svelte-1ajmbw1");
5276
+ },
5277
+ m(target, anchor) {
5278
+ insert(target, div, anchor);
5279
+ append(div, select);
5280
+
5281
+ for (let i = 0; i < each_blocks.length; i += 1) {
5282
+ each_blocks[i].m(select, null);
5283
+ }
5284
+
5285
+ if (!mounted) {
5286
+ dispose = listen(select, "change", /*handleChange*/ ctx[1]);
5287
+ mounted = true;
5288
+ }
5289
+ },
5290
+ p(ctx, [dirty]) {
5291
+ if (dirty & /*_options*/ 1) {
5292
+ each_value = /*_options*/ ctx[0];
5293
+ let i;
5294
+
5295
+ for (i = 0; i < each_value.length; i += 1) {
5296
+ const child_ctx = get_each_context(ctx, each_value, i);
5297
+
5298
+ if (each_blocks[i]) {
5299
+ each_blocks[i].p(child_ctx, dirty);
5300
+ } else {
5301
+ each_blocks[i] = create_each_block(child_ctx);
5302
+ each_blocks[i].c();
5303
+ each_blocks[i].m(select, null);
5304
+ }
5305
+ }
5306
+
5307
+ for (; i < each_blocks.length; i += 1) {
5308
+ each_blocks[i].d(1);
5309
+ }
5310
+
5311
+ each_blocks.length = each_value.length;
5312
+ }
5313
+ },
5314
+ i: noop,
5315
+ o: noop,
5316
+ d(detaching) {
5317
+ if (detaching) detach(div);
5318
+ destroy_each(each_blocks, detaching);
5319
+ mounted = false;
5320
+ dispose();
5321
+ }
5322
+ };
5323
+ }
5324
+
5325
+ function instance$3($$self, $$props, $$invalidate) {
5326
+ let _options;
5327
+ let { name = '' } = $$props;
5328
+ let { options = 'プルダウン1,プルダウン2,プルダウン3' } = $$props;
5329
+ const { path: statePath } = getStateItemContext();
5330
+
5331
+ const value = registerInput({
5332
+ name,
5333
+ statePath,
5334
+ initialValue: [],
5335
+ validator(value) {
5336
+ return value.length > 0;
5337
+ }
5338
+ });
5339
+
5340
+ function handleChange(event) {
5341
+ const updated = event.target.value ? [event.target.value] : [];
5342
+ value.set(updated);
5343
+ }
5344
+
5345
+ $$self.$$set = $$props => {
5346
+ if ('name' in $$props) $$invalidate(2, name = $$props.name);
5347
+ if ('options' in $$props) $$invalidate(3, options = $$props.options);
5348
+ };
5349
+
5350
+ $$self.$$.update = () => {
5351
+ if ($$self.$$.dirty & /*options*/ 8) {
5352
+ $$invalidate(0, _options = ['', ...options.split(',')]);
5353
+ }
5354
+ };
5355
+
5356
+ return [_options, handleChange, name, options];
5357
+ }
5358
+
5359
+ class FormSelect extends SvelteComponent {
5360
+ constructor(options) {
5361
+ super();
5362
+ init(this, options, instance$3, create_fragment$3, safe_not_equal, { name: 2, options: 3 }, add_css$3);
5217
5363
  }
5218
5364
  }
5219
5365
 
@@ -5558,4 +5704,4 @@ class ImageBlock extends SvelteComponent {
5558
5704
  }
5559
5705
  }
5560
5706
 
5561
- export { ACTION_CHANGE_STATE_EVENT, ACTION_CLOSE_EVENT, ACTION_DESTROY_EVENT, ACTION_SHOW_EVENT, ALL_ACTION_ID, ALL_ACTION_SHORTEN_ID, Alignments, AnimationStyles, BackgroundSizes, ClipPaths, Cursors, DefaultListBackground, DefaultListBackgroundNone, DefaultListBackgroundStripe, DefaultListSeparator, DefaultListSeparatorBorder, DefaultListSeparatorGap, DefaultListSeparatorNone, DefaultModalPlacement, Directions, Elasticities, ElasticityStyle, EmbedElement, Flex, FlexItem, Form, FormButton, FormRadioButtons, FormTextarea, Grid, GridItem, GridModalState, ImageBlock, ImageElement, Justifies, KARTE_ACTION_RID, KARTE_ACTION_ROOT, KARTE_ACTION_SHORTEN_ID, KARTE_MODAL_ROOT, LengthUnits, List, ListBackgroundTypes, ListDirections, ListItem, ListSeparatorTypes, MediaQueries, Modal, ModalPositions, MovieVimeoElement, MovieYouTubeElement, NOOP, ObjectFits, OnClickOperationOptions, Overflows, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, TextButtonElement, TextDirections, TextElement, WritingModes, actionId, actionSetting, addState, applyCss, applyGlobalCss, close, closeAction, closeApp, closed, collection$1 as collection, create, createApp, createFog, customAnimation, customHandlers, customVariables, destroy, destroyed, dispatchDestroyEvent, embed, ensureActionRoot, ensureModalRoot, execOnClickOperation, finalize, getActionSetting, getActionShadowRoot, getCustomHandlers, getCustomVariables, getInternalHandlers, getMarginStyle, getPositionStyle, getState$1 as getState, getStates, getStoreState, getSystem, getTransform, h, handleFocus, handleKeydown, handleState, hasSuffix, hashCode, haveFunction, hideOnScroll, hideOnTime, initialize, internalHandlers, isClosed, isDestroyed, isOpened, isPreview, isStopped, linkTo, loadGlobalScript, loadGlobalStyle, loadStyle, maximumZindex, moveTo, none, onChangeState, onClose, onCreate, onDestroy, onScroll, onShow, onTime, opened, randStr, resetActionSetting, runScript, send_event, setActionSetting, setAutoStart, setClosed, setCustomHandlers, setCustomVariables, setDestroyed, setInternalHandlers, setMaximumZindex, setOpened, setPreviousFocus, setState$1 as setState, setStopped, setSystem, show, showAction, showModal, showOnScroll, showOnTime, state, states, stopped, system, toBr, updateCustomHandlers, updateCustomVariables, updateInternalHandlers, widget };
5707
+ export { ACTION_CHANGE_STATE_EVENT, ACTION_CLOSE_EVENT, ACTION_DESTROY_EVENT, ACTION_SHOW_EVENT, ALL_ACTION_ID, ALL_ACTION_SHORTEN_ID, Alignments, AnimationStyles, BackgroundSizes, ClipPaths, Cursors, DefaultListBackground, DefaultListBackgroundNone, DefaultListBackgroundStripe, DefaultListSeparator, DefaultListSeparatorBorder, DefaultListSeparatorGap, DefaultListSeparatorNone, DefaultModalPlacement, Directions, Elasticities, ElasticityStyle, EmbedElement, Flex, FlexItem, FormButton, FormRadioButtons, FormSelect, FormTextarea, Grid, GridItem, GridModalState, ImageBlock, ImageElement, Justifies, KARTE_ACTION_RID, KARTE_ACTION_ROOT, KARTE_ACTION_SHORTEN_ID, KARTE_MODAL_ROOT, LengthUnits, List, ListBackgroundTypes, ListDirections, ListItem, ListSeparatorTypes, MediaQueries, Modal, ModalPositions, MovieVimeoElement, MovieYouTubeElement, NOOP, ObjectFits, OnClickOperationOptions, Overflows, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, TextButtonElement, TextDirections, TextElement, WritingModes, actionId, actionSetting, addState, applyCss, applyGlobalCss, close, closeAction, closeApp, closed, collection$1 as collection, create, createApp, createFog, customAnimation, customHandlers, customVariables, destroy, destroyed, dispatchDestroyEvent, embed, ensureActionRoot, ensureModalRoot, execOnClickOperation, finalize, formData, getActionSetting, getActionShadowRoot, getCustomHandlers, getCustomVariables, getInternalHandlers, getMarginStyle, getPositionStyle, getState$1 as getState, getStates, getStoreState, getSystem, getTransform, h, handleFocus, handleKeydown, handleState, hasSuffix, hashCode, haveFunction, hideOnScroll, hideOnTime, initialize, internalHandlers, isClosed, isDestroyed, isOpened, isPreview, isStopped, linkTo, loadGlobalScript, loadGlobalStyle, loadStyle, maximumZindex, moveTo, none, onChangeState, onClose, onCreate, onDestroy, onScroll, onShow, onTime, opened, randStr, resetActionSetting, runScript, send_event, setActionSetting, setAutoStart, setClosed, setCustomHandlers, setCustomVariables, setDestroyed, setInternalHandlers, setMaximumZindex, setOpened, setPreviousFocus, setState$1 as setState, setStopped, setSystem, show, showAction, showModal, showOnScroll, showOnTime, state, states, stopped, system, toBr, updateCustomHandlers, updateCustomVariables, updateInternalHandlers, widget };