@plaidev/karte-action-sdk 1.1.176 → 1.1.177-28039844.a230804c
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/hydrate/index.es.d.ts +1245 -2266
- package/dist/hydrate/index.es.js +893 -762
- package/dist/index.es.d.ts +1245 -2266
- package/dist/index.es.js +920 -802
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
@@ -1,8 +1,33 @@
|
|
1
|
-
import { linear, elasticOut, cubicOut } from 'svelte/easing';
|
2
1
|
import { writable, get } from 'svelte/store';
|
3
2
|
import { onMount as onMount$1, onDestroy as onDestroy$1, beforeUpdate as beforeUpdate$1, afterUpdate as afterUpdate$1, tick as tick$1, setContext, getContext, createEventDispatcher } from 'svelte';
|
4
3
|
import { SvelteComponent, init, safe_not_equal, create_slot, update_slot_base, get_all_dirty_from_scope, get_slot_changes, transition_in, transition_out, append_styles, empty, insert, group_outros, check_outros, detach, component_subscribe, element, space, attr, noop, listen, null_to_empty, is_function, create_component, mount_component, destroy_component, add_render_callback, create_in_transition, binding_callbacks, set_style, svg_element, append, destroy_each, text, set_data, src_url_equal, HtmlTag, construct_svelte_component, subscribe } from 'svelte/internal';
|
4
|
+
import { linear, elasticOut, cubicOut } from 'svelte/easing';
|
5
|
+
|
6
|
+
/** @internal */
|
7
|
+
const ACTION_HOOK_LABEL = '__ACTION_HOOK__';
|
8
|
+
/** @internal */
|
9
|
+
const KARTE_ACTION_ROOT = 'karte-action-root';
|
10
|
+
/** @internal */
|
11
|
+
const KARTE_ACTION_RID = 'karte-action-rid';
|
12
|
+
/** @internal */
|
13
|
+
const KARTE_ACTION_SHORTEN_ID = 'karte-action-id';
|
14
|
+
/** @internal */
|
15
|
+
const ALL_ACTION_ID = 'KARTE_ALL_ACTION_ID';
|
16
|
+
/** @internal */
|
17
|
+
const ALL_ACTION_SHORTEN_ID = 'KARTE_ALL_ACTION_SHORTEN_ID';
|
18
|
+
// -------- The following codes are deprecated --------
|
19
|
+
/**
|
20
|
+
* 非推奨
|
21
|
+
*
|
22
|
+
* @deprecated 非推奨
|
23
|
+
*
|
24
|
+
* @internal
|
25
|
+
*/
|
26
|
+
const KARTE_MODAL_ROOT = 'karte-modal-root';
|
5
27
|
|
28
|
+
/**
|
29
|
+
* 静的変数に関連するコードを管理する
|
30
|
+
*/
|
6
31
|
/** @internal */
|
7
32
|
const PropTypes = [
|
8
33
|
'BooleanKeyword',
|
@@ -247,6 +272,13 @@ const NOOP = (_args) => { }; // eslint-disable-line @typescript-eslint/no-unused
|
|
247
272
|
const isPreview = () => {
|
248
273
|
return false;
|
249
274
|
};
|
275
|
+
// prettier-ignore
|
276
|
+
/** @internal */
|
277
|
+
const actionId = typeof __FIX_ACTION_CHANGE_STATE_EVENT__ === 'string'
|
278
|
+
? __FIX_ACTION_CHANGE_STATE_EVENT__
|
279
|
+
: typeof __FLYER_GEN_ACTION_ID_ON_BUILD__ === 'string'
|
280
|
+
? __FLYER_GEN_ACTION_ID_ON_BUILD__
|
281
|
+
: randStr();
|
250
282
|
/** @internal */
|
251
283
|
const handleFocus = (node) => (e) => {
|
252
284
|
if (node) {
|
@@ -449,6 +481,23 @@ function randStr(digit = 8) {
|
|
449
481
|
function getGoogleFontsParam() {
|
450
482
|
return 'family=' + Fonts.map(font => font.replace(/ /g, '+')).join('&family=');
|
451
483
|
}
|
484
|
+
/** @internal */
|
485
|
+
const h = (type, props, ...children) => {
|
486
|
+
const el = document.createElement(type);
|
487
|
+
for (const key of Object.keys(props)) {
|
488
|
+
const v = props[key];
|
489
|
+
if (key === 'style') {
|
490
|
+
Object.assign(el.style, v);
|
491
|
+
}
|
492
|
+
else {
|
493
|
+
el.setAttribute(key, v);
|
494
|
+
}
|
495
|
+
}
|
496
|
+
for (const child of children) {
|
497
|
+
el.appendChild(child);
|
498
|
+
}
|
499
|
+
return el;
|
500
|
+
};
|
452
501
|
|
453
502
|
/**
|
454
503
|
* Store to handle action setting
|
@@ -809,446 +858,123 @@ function resetVariables() {
|
|
809
858
|
*/
|
810
859
|
const formData = writable({});
|
811
860
|
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
861
|
+
/**
|
862
|
+
* アクションのログの記録の管理
|
863
|
+
*/
|
864
|
+
const MESSAGES_LIMIT = 1000;
|
865
|
+
const EVENTS_LIMIT = 1000;
|
866
|
+
// 実行ログ
|
867
|
+
let logs = [];
|
868
|
+
// KARTEイベント
|
869
|
+
let events = [];
|
820
870
|
/** @internal */
|
821
|
-
function
|
822
|
-
|
823
|
-
subscribe(run) {
|
824
|
-
return formData.subscribe(formData => {
|
825
|
-
run(formData[name]?.value);
|
826
|
-
});
|
827
|
-
},
|
828
|
-
set(value) {
|
829
|
-
formData.update(prev => ({
|
830
|
-
...prev,
|
831
|
-
[name]: {
|
832
|
-
statePath,
|
833
|
-
value,
|
834
|
-
isValid: validator(value),
|
835
|
-
},
|
836
|
-
}));
|
837
|
-
},
|
838
|
-
update(updater) {
|
839
|
-
formData.update(prev => {
|
840
|
-
const prevValue = prev[name]?.value;
|
841
|
-
return {
|
842
|
-
...prev,
|
843
|
-
[name]: {
|
844
|
-
statePath,
|
845
|
-
value: updater(prevValue),
|
846
|
-
isValid: validator(prevValue),
|
847
|
-
},
|
848
|
-
};
|
849
|
-
});
|
850
|
-
},
|
851
|
-
};
|
852
|
-
if (isEmpty(get(writableValue))) {
|
853
|
-
writableValue.set(initialValue);
|
854
|
-
}
|
855
|
-
return writableValue;
|
871
|
+
function getLogs() {
|
872
|
+
return logs;
|
856
873
|
}
|
857
874
|
/** @internal */
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
875
|
+
function getEvents() {
|
876
|
+
return events;
|
877
|
+
}
|
878
|
+
// iframe内の場合は親windowを参照する
|
879
|
+
function w(w) {
|
880
|
+
return w.parent === w ? w : w.parent;
|
881
|
+
}
|
882
|
+
/**
|
883
|
+
* ログを送信する関数群
|
884
|
+
*
|
885
|
+
* @internal
|
886
|
+
*/
|
887
|
+
const logger = {
|
888
|
+
info: (...messages) => {
|
889
|
+
const log = cloneToJson({ level: 'info', messages, date: new Date() });
|
890
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
866
891
|
},
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
892
|
+
log: (...messages) => {
|
893
|
+
const log = cloneToJson({ level: 'info', messages, date: new Date() });
|
894
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
895
|
+
},
|
896
|
+
error: (...messages) => {
|
897
|
+
const log = cloneToJson({ level: 'error', messages, date: new Date() });
|
898
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
899
|
+
},
|
900
|
+
warn: (...messages) => {
|
901
|
+
const log = cloneToJson({ level: 'warn', messages, date: new Date() });
|
902
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
903
|
+
},
|
904
|
+
system: (...messages) => {
|
905
|
+
const log = cloneToJson({ level: 'system', messages, date: new Date() });
|
906
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
907
|
+
},
|
908
|
+
event: (name, values) => {
|
909
|
+
const event = values ? { name, values, date: new Date() } : { name, date: new Date() };
|
910
|
+
w(window).postMessage({
|
911
|
+
type: 'KARTE-ACTION-LOGGER',
|
912
|
+
detail: { method: 'event', event, values: values },
|
913
|
+
}, '*');
|
914
|
+
},
|
915
|
+
clear: () => {
|
916
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clear' } }, '*');
|
917
|
+
},
|
918
|
+
clearEvents: () => {
|
919
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clearEvents' } }, '*');
|
920
|
+
},
|
921
|
+
};
|
922
|
+
/**
|
923
|
+
* メッセージを実行ログに表示する
|
924
|
+
*
|
925
|
+
* @internal
|
926
|
+
*/
|
927
|
+
function listenLogger() {
|
928
|
+
const handler = (event) => {
|
929
|
+
const { type, detail } = event.data;
|
930
|
+
if (event.origin !== location.origin) {
|
931
|
+
return;
|
879
932
|
}
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
933
|
+
if (type !== 'KARTE-ACTION-LOGGER') {
|
934
|
+
return;
|
935
|
+
}
|
936
|
+
if (detail.method === 'clear') {
|
937
|
+
logs = [];
|
938
|
+
}
|
939
|
+
else if (detail.method === 'clearEvents') {
|
940
|
+
events = [];
|
941
|
+
}
|
942
|
+
else if (detail.method === 'log') {
|
943
|
+
if (MESSAGES_LIMIT <= logs.length) {
|
944
|
+
logs.shift();
|
945
|
+
}
|
946
|
+
const { level, messages } = detail.log;
|
947
|
+
const log = { level, messages, date: new Date() };
|
948
|
+
logs.push(log);
|
949
|
+
}
|
950
|
+
else if (detail.method === 'event') {
|
951
|
+
if (EVENTS_LIMIT <= events.length) {
|
952
|
+
events.shift();
|
953
|
+
}
|
954
|
+
const { name, values } = detail.event;
|
955
|
+
const karteEvent = values
|
956
|
+
? { name, values, date: new Date() }
|
957
|
+
: { name, date: new Date() };
|
958
|
+
events.push(karteEvent);
|
884
959
|
}
|
885
|
-
}
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
...answersMap,
|
890
|
-
},
|
960
|
+
};
|
961
|
+
window.addEventListener('message', handler, false);
|
962
|
+
return () => {
|
963
|
+
window.removeEventListener('message', handler, false);
|
891
964
|
};
|
892
965
|
}
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
const values = formDataToEventValues(campaignId, formData$1);
|
900
|
-
return values;
|
901
|
-
}
|
902
|
-
return {};
|
903
|
-
}
|
904
|
-
|
905
|
-
/** @internal */
|
906
|
-
const ALL_ACTION_ID = 'KARTE_ALL_ACTION_ID';
|
907
|
-
/** @internal */
|
908
|
-
const ALL_ACTION_SHORTEN_ID = 'KARTE_ALL_ACTION_SHORTEN_ID';
|
909
|
-
// prettier-ignore
|
910
|
-
/** @internal */
|
911
|
-
const actionId = typeof __FIX_ACTION_CHANGE_STATE_EVENT__ === 'string'
|
912
|
-
? __FIX_ACTION_CHANGE_STATE_EVENT__
|
913
|
-
: typeof __FLYER_GEN_ACTION_ID_ON_BUILD__ === 'string'
|
914
|
-
? __FLYER_GEN_ACTION_ID_ON_BUILD__
|
915
|
-
: randStr();
|
916
|
-
/** @internal */
|
917
|
-
const ACTION_SHOW_EVENT = `KARTE-ACTION-SHOW-${actionId}`;
|
918
|
-
/** @internal */
|
919
|
-
const ACTION_CLOSE_EVENT = `KARTE-ACTION-CLOSE-${actionId}`;
|
920
|
-
/** @internal */
|
921
|
-
const ACTION_DESTROY_EVENT = `KARTE-ACTION-DESTROY-${actionId}`;
|
922
|
-
/** @internal */
|
923
|
-
const ACTION_CHANGE_STATE_EVENT = `KARTE-ACTION-CHANGE-STATE-${actionId}`;
|
924
|
-
/** @internal */
|
925
|
-
const handleState = (event) => {
|
926
|
-
if (event.detail.actionId === actionId || event.detail.actionId === ALL_ACTION_ID) {
|
927
|
-
send_event('_message_state_changed', { state: event.detail.to });
|
928
|
-
setState$1(event.detail.to, { disableInPreview: event.detail.disableInPreview });
|
929
|
-
}
|
930
|
-
};
|
931
|
-
/** @internal */
|
932
|
-
const initialize = (setting) => {
|
933
|
-
const newSetting = setSetting(setting);
|
934
|
-
if (newSetting.initialState) {
|
935
|
-
setState$1(newSetting.initialState);
|
936
|
-
}
|
937
|
-
setOpened(true);
|
938
|
-
setClosed(false); // deprecated
|
939
|
-
return () => finalize();
|
940
|
-
};
|
941
|
-
/** @internal */
|
942
|
-
const finalize = () => {
|
943
|
-
resetSetting();
|
944
|
-
};
|
945
|
-
/** @internal */
|
946
|
-
const send_event = (event_name, values) => {
|
947
|
-
const setting = getSetting();
|
948
|
-
setting?.send?.(event_name, values);
|
949
|
-
};
|
950
|
-
function _moveTo(to) {
|
951
|
-
window.dispatchEvent(new CustomEvent(ACTION_CHANGE_STATE_EVENT, { detail: { to, actionId } }));
|
952
|
-
}
|
953
|
-
/** @internal */
|
954
|
-
const moveTo = (to) => () => {
|
955
|
-
_moveTo(to);
|
956
|
-
};
|
957
|
-
/** @internal */
|
958
|
-
const linkTo = (to, targetBlank = true) => () => {
|
959
|
-
send_event('message_click', { url: to, state: getState$1() });
|
960
|
-
if (targetBlank) {
|
961
|
-
window.open(to);
|
962
|
-
}
|
963
|
-
else {
|
964
|
-
location.href = to;
|
965
|
-
}
|
966
|
-
};
|
967
|
-
/** @internal */
|
968
|
-
const closeApp = (trigger) => () => {
|
969
|
-
window.dispatchEvent(new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger } }));
|
970
|
-
};
|
971
|
-
/** @internal */
|
972
|
-
const runScript = (handlerName) => () => {
|
973
|
-
const handlers = getEventHandlers();
|
974
|
-
const handler = handlers[handlerName];
|
975
|
-
if (!handler)
|
976
|
-
return;
|
977
|
-
try {
|
978
|
-
handler();
|
979
|
-
}
|
980
|
-
catch (e) {
|
981
|
-
console.warn('Failed to run custom handler', handlerName, e);
|
982
|
-
}
|
983
|
-
};
|
984
|
-
/** @internal */
|
985
|
-
const submitForm = (to) => () => {
|
986
|
-
const values = submit();
|
987
|
-
send_event('_answer_question', values);
|
988
|
-
_moveTo(to);
|
989
|
-
};
|
990
|
-
/** @internal */
|
991
|
-
const execOnClickOperation = (onClickOperation) => {
|
992
|
-
if (onClickOperation.operation === 'linkTo') {
|
993
|
-
linkTo(...onClickOperation.args)();
|
994
|
-
}
|
995
|
-
else if (onClickOperation.operation === 'moveTo') {
|
996
|
-
moveTo(...onClickOperation.args)();
|
997
|
-
}
|
998
|
-
else if (onClickOperation.operation === 'closeApp') {
|
999
|
-
closeApp(onClickOperation.args[0] || 'button')();
|
1000
|
-
}
|
1001
|
-
else if (onClickOperation.operation === 'runScript') {
|
1002
|
-
runScript(onClickOperation.args[0])();
|
1003
|
-
}
|
1004
|
-
else if (onClickOperation.operation === 'submitForm') {
|
1005
|
-
submitForm(onClickOperation.args[0])();
|
1006
|
-
}
|
1007
|
-
};
|
1008
|
-
/** @internal */
|
1009
|
-
const haveFunction = (onClickOperation) => {
|
1010
|
-
return onClickOperation.operation !== 'none';
|
1011
|
-
};
|
1012
|
-
function getAnimation(animation) {
|
1013
|
-
switch (animation.type) {
|
1014
|
-
case 'fade':
|
1015
|
-
return `opacity: ${animation.progress}`;
|
1016
|
-
case 'bounce': {
|
1017
|
-
const translateX = animation.x;
|
1018
|
-
const translateY = animation.y;
|
1019
|
-
return `transform: translate3d(${translateX}%, ${translateY}%, 0) scale(${animation.progress});`;
|
1020
|
-
}
|
1021
|
-
case 'slide-down': {
|
1022
|
-
const translateX = animation.x;
|
1023
|
-
const translateY = animation.y - 100 * (1 - animation.progress);
|
1024
|
-
return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
|
1025
|
-
}
|
1026
|
-
case 'slide-up': {
|
1027
|
-
const translateX = animation.x;
|
1028
|
-
const translateY = animation.y + 100 * (1 - animation.progress);
|
1029
|
-
return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
|
1030
|
-
}
|
1031
|
-
case 'slide-left': {
|
1032
|
-
const translateX = animation.x + 100 * (1 - animation.progress);
|
1033
|
-
const translateY = animation.y;
|
1034
|
-
return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
|
1035
|
-
}
|
1036
|
-
case 'slide-right': {
|
1037
|
-
const translateX = animation.x - 100 * (1 - animation.progress);
|
1038
|
-
const translateY = animation.y;
|
1039
|
-
return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
|
1040
|
-
}
|
1041
|
-
case 'none': {
|
1042
|
-
const translateX = animation.x;
|
1043
|
-
const translateY = animation.y;
|
1044
|
-
return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
|
1045
|
-
}
|
1046
|
-
default:
|
1047
|
-
console.warn(`[action-sdk] invalid '${animation}', so we use 'transform: none' instead`);
|
1048
|
-
return 'transform: none';
|
1049
|
-
}
|
1050
|
-
}
|
1051
|
-
const EASING = {
|
1052
|
-
fade: linear,
|
1053
|
-
bounce: elasticOut,
|
1054
|
-
'slide-down': cubicOut,
|
1055
|
-
'slide-up': cubicOut,
|
1056
|
-
'slide-left': cubicOut,
|
1057
|
-
'slide-right': cubicOut,
|
1058
|
-
none: linear,
|
1059
|
-
};
|
1060
|
-
/**
|
1061
|
-
* The function to activate svelte animation.
|
1062
|
-
*
|
1063
|
-
* @param node - A target node of animation. This argument is passed by svelte, by default.
|
1064
|
-
* @param customAnimationOptions - A custom animation option object
|
1065
|
-
*
|
1066
|
-
* @see {@link https://svelte.dev/docs#template-syntax-element-directives-transition-fn-custom-transition-functions| Custom transition functions} for detail documentation
|
1067
|
-
*
|
1068
|
-
* @internal
|
1069
|
-
*/
|
1070
|
-
function customAnimation(node, { transform, animationStyle, delay = 0, duration = 1000 }) {
|
1071
|
-
const [x, y] = transform;
|
1072
|
-
return {
|
1073
|
-
delay,
|
1074
|
-
duration,
|
1075
|
-
easing: EASING[animationStyle],
|
1076
|
-
css: (progress) => getAnimation({ type: animationStyle, x, y, progress }),
|
1077
|
-
};
|
1078
|
-
}
|
1079
|
-
/**
|
1080
|
-
* ES Modules に対応していない JavaScript をページに読み込む
|
1081
|
-
*
|
1082
|
-
* @param src - JavaScript ファイルのリンク URL
|
1083
|
-
*
|
1084
|
-
* @public
|
1085
|
-
*/
|
1086
|
-
async function loadGlobalScript(src) {
|
1087
|
-
return new Promise((resolve, reject) => {
|
1088
|
-
const script = document.createElement('script');
|
1089
|
-
script.src = src;
|
1090
|
-
document.body.appendChild(script);
|
1091
|
-
script.addEventListener('load', () => resolve(script));
|
1092
|
-
script.addEventListener('error', () => reject(script));
|
1093
|
-
});
|
1094
|
-
}
|
1095
|
-
/**
|
1096
|
-
* グローバル CSS をページに適用する
|
1097
|
-
*
|
1098
|
-
* @param css - CSS
|
1099
|
-
*
|
1100
|
-
* @public
|
1101
|
-
*/
|
1102
|
-
async function applyGlobalCss(css) {
|
1103
|
-
return new Promise((resolve, reject) => {
|
1104
|
-
const style = document.createElement('style');
|
1105
|
-
style.textContent = css;
|
1106
|
-
document.body.appendChild(style);
|
1107
|
-
style.addEventListener('load', () => resolve(style));
|
1108
|
-
style.addEventListener('error', () => reject(style));
|
1109
|
-
});
|
1110
|
-
}
|
1111
|
-
/**
|
1112
|
-
* style ファイルをページに読み込む
|
1113
|
-
*
|
1114
|
-
* @param href - style ファイルのリンク URL
|
1115
|
-
*
|
1116
|
-
* @public
|
1117
|
-
*/
|
1118
|
-
async function loadGlobalStyle(href) {
|
1119
|
-
return new Promise((resolve, reject) => {
|
1120
|
-
const link = document.createElement('link');
|
1121
|
-
link.rel = 'stylesheet';
|
1122
|
-
link.href = href;
|
1123
|
-
document.body.appendChild(link);
|
1124
|
-
link.addEventListener('load', () => resolve(link));
|
1125
|
-
link.addEventListener('error', () => reject(link));
|
1126
|
-
});
|
1127
|
-
}
|
1128
|
-
// @internal
|
1129
|
-
function getCssVariables(data) {
|
1130
|
-
return Object.entries(data)
|
1131
|
-
.filter(([key, value]) => {
|
1132
|
-
return ['string', 'number'].includes(typeof value) && key.startsWith('--');
|
1133
|
-
})
|
1134
|
-
.map(([key, value]) => `${key}:${value}`)
|
1135
|
-
.join(';');
|
1136
|
-
}
|
1137
|
-
|
1138
|
-
/**
|
1139
|
-
* アクションのログの記録の管理
|
1140
|
-
*/
|
1141
|
-
const MESSAGES_LIMIT = 1000;
|
1142
|
-
const EVENTS_LIMIT = 1000;
|
1143
|
-
// 実行ログ
|
1144
|
-
let logs = [];
|
1145
|
-
// KARTEイベント
|
1146
|
-
let events = [];
|
1147
|
-
/** @internal */
|
1148
|
-
function getLogs() {
|
1149
|
-
return logs;
|
1150
|
-
}
|
1151
|
-
/** @internal */
|
1152
|
-
function getEvents() {
|
1153
|
-
return events;
|
1154
|
-
}
|
1155
|
-
// iframe内の場合は親windowを参照する
|
1156
|
-
function w(w) {
|
1157
|
-
return w.parent === w ? w : w.parent;
|
1158
|
-
}
|
1159
|
-
/**
|
1160
|
-
* ログを送信する関数群
|
1161
|
-
*
|
1162
|
-
* @internal
|
1163
|
-
*/
|
1164
|
-
const logger = {
|
1165
|
-
info: (...messages) => {
|
1166
|
-
const log = cloneToJson({ level: 'info', messages, date: new Date() });
|
1167
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
1168
|
-
},
|
1169
|
-
log: (...messages) => {
|
1170
|
-
const log = cloneToJson({ level: 'info', messages, date: new Date() });
|
1171
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
1172
|
-
},
|
1173
|
-
error: (...messages) => {
|
1174
|
-
const log = cloneToJson({ level: 'error', messages, date: new Date() });
|
1175
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
1176
|
-
},
|
1177
|
-
warn: (...messages) => {
|
1178
|
-
const log = cloneToJson({ level: 'warn', messages, date: new Date() });
|
1179
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
1180
|
-
},
|
1181
|
-
system: (...messages) => {
|
1182
|
-
const log = cloneToJson({ level: 'system', messages, date: new Date() });
|
1183
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
1184
|
-
},
|
1185
|
-
event: (name, values) => {
|
1186
|
-
const event = values ? { name, values, date: new Date() } : { name, date: new Date() };
|
1187
|
-
w(window).postMessage({
|
1188
|
-
type: 'KARTE-ACTION-LOGGER',
|
1189
|
-
detail: { method: 'event', event, values: values },
|
1190
|
-
}, '*');
|
1191
|
-
},
|
1192
|
-
clear: () => {
|
1193
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clear' } }, '*');
|
1194
|
-
},
|
1195
|
-
clearEvents: () => {
|
1196
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clearEvents' } }, '*');
|
1197
|
-
},
|
1198
|
-
};
|
1199
|
-
/**
|
1200
|
-
* メッセージを実行ログに表示する
|
1201
|
-
*
|
1202
|
-
* @internal
|
1203
|
-
*/
|
1204
|
-
function listenLogger() {
|
1205
|
-
const handler = (event) => {
|
1206
|
-
const { type, detail } = event.data;
|
1207
|
-
if (event.origin !== location.origin) {
|
1208
|
-
return;
|
1209
|
-
}
|
1210
|
-
if (type !== 'KARTE-ACTION-LOGGER') {
|
1211
|
-
return;
|
1212
|
-
}
|
1213
|
-
if (detail.method === 'clear') {
|
1214
|
-
logs = [];
|
1215
|
-
}
|
1216
|
-
else if (detail.method === 'clearEvents') {
|
1217
|
-
events = [];
|
1218
|
-
}
|
1219
|
-
else if (detail.method === 'log') {
|
1220
|
-
if (MESSAGES_LIMIT <= logs.length) {
|
1221
|
-
logs.shift();
|
1222
|
-
}
|
1223
|
-
const { level, messages } = detail.log;
|
1224
|
-
const log = { level, messages, date: new Date() };
|
1225
|
-
logs.push(log);
|
1226
|
-
}
|
1227
|
-
else if (detail.method === 'event') {
|
1228
|
-
if (EVENTS_LIMIT <= events.length) {
|
1229
|
-
events.shift();
|
1230
|
-
}
|
1231
|
-
const { name, values } = detail.event;
|
1232
|
-
const karteEvent = values
|
1233
|
-
? { name, values, date: new Date() }
|
1234
|
-
: { name, date: new Date() };
|
1235
|
-
events.push(karteEvent);
|
1236
|
-
}
|
1237
|
-
};
|
1238
|
-
window.addEventListener('message', handler, false);
|
1239
|
-
return () => {
|
1240
|
-
window.removeEventListener('message', handler, false);
|
1241
|
-
};
|
1242
|
-
}
|
1243
|
-
function cloneToJson(data) {
|
1244
|
-
try {
|
1245
|
-
return JSON.parse(JSON.stringify(data));
|
1246
|
-
}
|
1247
|
-
catch (e) {
|
1248
|
-
return data;
|
966
|
+
function cloneToJson(data) {
|
967
|
+
try {
|
968
|
+
return JSON.parse(JSON.stringify(data));
|
969
|
+
}
|
970
|
+
catch (e) {
|
971
|
+
return data;
|
1249
972
|
}
|
1250
973
|
}
|
1251
974
|
|
975
|
+
/**
|
976
|
+
* モーダル(ポップアップ)のロジックを管理する
|
977
|
+
*/
|
1252
978
|
function doPresent({ direction, deltaRate }, downFn, upFn, condition = false) {
|
1253
979
|
if (direction === 'down' && deltaRate > 0) {
|
1254
980
|
downFn();
|
@@ -1393,6 +1119,23 @@ function checkAndDo(checkFn, fn, ...conditionFns) {
|
|
1393
1119
|
return haveCondition ? cleanupAll : null;
|
1394
1120
|
}
|
1395
1121
|
|
1122
|
+
/** @internal */
|
1123
|
+
const ACTION_DESTROY_EVENT = `KARTE-ACTION-DESTROY-${actionId}`;
|
1124
|
+
/** @internal */
|
1125
|
+
const ACTION_SHOW_EVENT = `KARTE-ACTION-SHOW-${actionId}`;
|
1126
|
+
/** @internal */
|
1127
|
+
const ACTION_CLOSE_EVENT = `KARTE-ACTION-CLOSE-${actionId}`;
|
1128
|
+
/** @internal */
|
1129
|
+
const ACTION_CHANGE_STATE_EVENT = `KARTE-ACTION-CHANGE-STATE-${actionId}`;
|
1130
|
+
/** @internal */
|
1131
|
+
const send_event = (event_name, values) => {
|
1132
|
+
const setting = getSetting();
|
1133
|
+
setting?.send?.(event_name, values);
|
1134
|
+
};
|
1135
|
+
|
1136
|
+
/**
|
1137
|
+
* アクションテーブルに関連するコードの管理
|
1138
|
+
*/
|
1396
1139
|
const DEFAULT_COLLECTION_ENDPOINT = typeof __FLYER_GEN_COLLECTION_API_ENDPOINT__ === 'string'
|
1397
1140
|
? __FLYER_GEN_COLLECTION_API_ENDPOINT__
|
1398
1141
|
: 'https://t.karte.io/collection';
|
@@ -1498,83 +1241,34 @@ const loadActionTable = async (config, api_key, endpoint) => {
|
|
1498
1241
|
}, {});
|
1499
1242
|
};
|
1500
1243
|
|
1501
|
-
/** @internal */
|
1502
|
-
const ACTION_HOOK_LABEL = '__ACTION_HOOK__';
|
1503
|
-
/**
|
1504
|
-
* アクションが作成 (create) される前にフックする関数
|
1505
|
-
*
|
1506
|
-
* @param fn - 呼び出されるフック関数
|
1507
|
-
*
|
1508
|
-
* @public
|
1509
|
-
*/
|
1510
|
-
function onCreate(fn) {
|
1511
|
-
let { onCreateHandlers } = getInternalHandlers();
|
1512
|
-
if (!onCreateHandlers) {
|
1513
|
-
onCreateHandlers = [];
|
1514
|
-
}
|
1515
|
-
onCreateHandlers.push(fn);
|
1516
|
-
setInternalHandlers({ onCreateHandlers });
|
1517
|
-
}
|
1518
|
-
/**
|
1519
|
-
* アクションが表示 (show) された後にフックする関数
|
1520
|
-
*
|
1521
|
-
* @param fn - 呼び出されるフック関数
|
1522
|
-
*
|
1523
|
-
* @public
|
1524
|
-
*/
|
1525
|
-
function onShow(fn) {
|
1526
|
-
let { onShowHandlers } = getInternalHandlers();
|
1527
|
-
if (!onShowHandlers) {
|
1528
|
-
onShowHandlers = [];
|
1529
|
-
}
|
1530
|
-
onShowHandlers.push(fn);
|
1531
|
-
setInternalHandlers({ onShowHandlers });
|
1532
|
-
}
|
1533
|
-
/**
|
1534
|
-
* アクションがクローズ (close) される前にフックする関数
|
1535
|
-
*
|
1536
|
-
* @param fn - 呼び出されるフック関数
|
1537
|
-
*
|
1538
|
-
* @public
|
1539
|
-
*/
|
1540
|
-
function onClose(fn) {
|
1541
|
-
let { onCloseHandlers } = getInternalHandlers();
|
1542
|
-
if (!onCloseHandlers) {
|
1543
|
-
onCloseHandlers = [];
|
1544
|
-
}
|
1545
|
-
onCloseHandlers.push(fn);
|
1546
|
-
setInternalHandlers({ onCloseHandlers });
|
1547
|
-
}
|
1548
1244
|
/**
|
1549
|
-
*
|
1245
|
+
* Edgeが起動するアクションに関連するコードを管理する
|
1550
1246
|
*
|
1551
|
-
*
|
1247
|
+
* アクションのCreate, Destroyの状態はここで管理する。
|
1552
1248
|
*
|
1553
|
-
*
|
1249
|
+
* FIXME: モーダルなどの機能ごとのコードを分離したい
|
1554
1250
|
*/
|
1555
|
-
|
1556
|
-
|
1557
|
-
if (
|
1558
|
-
|
1251
|
+
/** @internal */
|
1252
|
+
const handleState = (event) => {
|
1253
|
+
if (event.detail.actionId === actionId || event.detail.actionId === ALL_ACTION_ID) {
|
1254
|
+
send_event('_message_state_changed', { state: event.detail.to });
|
1255
|
+
setState$1(event.detail.to, { disableInPreview: event.detail.disableInPreview });
|
1559
1256
|
}
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
* @param fn - 呼び出されるフック関数
|
1567
|
-
*
|
1568
|
-
* @public
|
1569
|
-
*/
|
1570
|
-
function onChangeState(fn) {
|
1571
|
-
let { onChangeStateHandlers } = getInternalHandlers();
|
1572
|
-
if (!onChangeStateHandlers) {
|
1573
|
-
onChangeStateHandlers = [];
|
1257
|
+
};
|
1258
|
+
/** @internal */
|
1259
|
+
const initialize = (setting) => {
|
1260
|
+
const newSetting = setSetting(setting);
|
1261
|
+
if (newSetting.initialState) {
|
1262
|
+
setState$1(newSetting.initialState);
|
1574
1263
|
}
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1264
|
+
setOpened(true);
|
1265
|
+
setClosed(false); // deprecated
|
1266
|
+
return () => finalize();
|
1267
|
+
};
|
1268
|
+
/** @internal */
|
1269
|
+
const finalize = () => {
|
1270
|
+
resetSetting();
|
1271
|
+
};
|
1578
1272
|
/**
|
1579
1273
|
* アクションを作成する
|
1580
1274
|
*
|
@@ -1789,92 +1483,154 @@ function create(App, options = {
|
|
1789
1483
|
window.removeEventListener(ACTION_DESTROY_EVENT, handleDestroy);
|
1790
1484
|
window.removeEventListener('beforeunload', dispatchDestroyEvent, false);
|
1791
1485
|
};
|
1792
|
-
return appCleanup;
|
1486
|
+
return appCleanup;
|
1487
|
+
}
|
1488
|
+
/** @internal */
|
1489
|
+
function ensureActionRoot(useShadow = true) {
|
1490
|
+
const systemConfig = getSystem();
|
1491
|
+
const rootAttrs = {
|
1492
|
+
class: `${KARTE_ACTION_ROOT} ${KARTE_MODAL_ROOT}`,
|
1493
|
+
[`data-${KARTE_ACTION_RID}`]: actionId,
|
1494
|
+
[`data-${KARTE_ACTION_SHORTEN_ID}`]: systemConfig.shortenId
|
1495
|
+
? systemConfig.shortenId
|
1496
|
+
: ALL_ACTION_SHORTEN_ID,
|
1497
|
+
};
|
1498
|
+
let el = document.querySelector(`.${KARTE_MODAL_ROOT}[data-${KARTE_ACTION_RID}='${actionId}']`);
|
1499
|
+
if (el == null) {
|
1500
|
+
el = h('div', rootAttrs);
|
1501
|
+
document.body.appendChild(el);
|
1502
|
+
}
|
1503
|
+
const isShadow = !!document.body.attachShadow && useShadow;
|
1504
|
+
if (isShadow) {
|
1505
|
+
return el.shadowRoot ?? el.attachShadow({ mode: 'open' });
|
1506
|
+
}
|
1507
|
+
else {
|
1508
|
+
return el;
|
1509
|
+
}
|
1510
|
+
}
|
1511
|
+
/**
|
1512
|
+
* Dispatch the event to destroy KARTE action
|
1513
|
+
*
|
1514
|
+
* @internal
|
1515
|
+
*/
|
1516
|
+
function dispatchDestroyEvent() {
|
1517
|
+
const event = new CustomEvent(ACTION_DESTROY_EVENT);
|
1518
|
+
window.dispatchEvent(event);
|
1519
|
+
}
|
1520
|
+
/**
|
1521
|
+
* アクションの破棄する
|
1522
|
+
*
|
1523
|
+
* @public
|
1524
|
+
*/
|
1525
|
+
function destroyAction() {
|
1526
|
+
setDestroyed(true);
|
1527
|
+
dispatchDestroyEvent();
|
1528
|
+
}
|
1529
|
+
/**
|
1530
|
+
* アクションが作成 (create) される前にフックする関数
|
1531
|
+
*
|
1532
|
+
* @param fn - 呼び出されるフック関数
|
1533
|
+
*
|
1534
|
+
* @public
|
1535
|
+
*/
|
1536
|
+
function onCreate(fn) {
|
1537
|
+
let { onCreateHandlers } = getInternalHandlers();
|
1538
|
+
if (!onCreateHandlers) {
|
1539
|
+
onCreateHandlers = [];
|
1540
|
+
}
|
1541
|
+
onCreateHandlers.push(fn);
|
1542
|
+
setInternalHandlers({ onCreateHandlers });
|
1543
|
+
}
|
1544
|
+
/**
|
1545
|
+
* アクションが破棄 (destroy) される前にフックする関数
|
1546
|
+
*
|
1547
|
+
* @param fn - 呼び出されるフック関数
|
1548
|
+
*
|
1549
|
+
* @public
|
1550
|
+
*/
|
1551
|
+
function onDestroy(fn) {
|
1552
|
+
let { onDestroyHandlers } = getInternalHandlers();
|
1553
|
+
if (!onDestroyHandlers) {
|
1554
|
+
onDestroyHandlers = [];
|
1555
|
+
}
|
1556
|
+
onDestroyHandlers.push(fn);
|
1557
|
+
setInternalHandlers({ onDestroyHandlers });
|
1558
|
+
}
|
1559
|
+
/**
|
1560
|
+
* 非推奨
|
1561
|
+
*
|
1562
|
+
* @deprecated 非推奨
|
1563
|
+
*
|
1564
|
+
* @internal
|
1565
|
+
*/
|
1566
|
+
const showModal = create;
|
1567
|
+
/**
|
1568
|
+
* 非推奨
|
1569
|
+
*
|
1570
|
+
* @deprecated 非推奨
|
1571
|
+
*
|
1572
|
+
* @internal
|
1573
|
+
*/
|
1574
|
+
const ensureModalRoot = ensureActionRoot;
|
1575
|
+
/**
|
1576
|
+
* 非推奨
|
1577
|
+
*
|
1578
|
+
* @deprecated 非推奨
|
1579
|
+
*
|
1580
|
+
* @internal
|
1581
|
+
*/
|
1582
|
+
function createApp(App, options = {
|
1583
|
+
send: () => { },
|
1584
|
+
publish: () => { },
|
1585
|
+
props: {},
|
1586
|
+
variables: {},
|
1587
|
+
localVariablesQuery: undefined,
|
1588
|
+
}) {
|
1589
|
+
let app = null;
|
1590
|
+
const close = () => {
|
1591
|
+
if (app) {
|
1592
|
+
app.$destroy();
|
1593
|
+
app = null;
|
1594
|
+
}
|
1595
|
+
};
|
1596
|
+
const appArgs = {
|
1597
|
+
target: null,
|
1598
|
+
props: {
|
1599
|
+
send: options.send,
|
1600
|
+
publish: options.publish,
|
1601
|
+
close,
|
1602
|
+
data: {
|
1603
|
+
...options.props,
|
1604
|
+
...options.variables,
|
1605
|
+
},
|
1606
|
+
},
|
1607
|
+
};
|
1608
|
+
{
|
1609
|
+
const win = ensureModalRoot(true);
|
1610
|
+
appArgs.target = win;
|
1611
|
+
}
|
1612
|
+
return {
|
1613
|
+
close,
|
1614
|
+
show: () => {
|
1615
|
+
if (app) {
|
1616
|
+
return;
|
1617
|
+
}
|
1618
|
+
options.send('message_open');
|
1619
|
+
app = new App(appArgs);
|
1620
|
+
},
|
1621
|
+
};
|
1793
1622
|
}
|
1794
1623
|
/**
|
1795
|
-
*
|
1624
|
+
* 非推奨
|
1796
1625
|
*
|
1797
|
-
* @
|
1798
|
-
*/
|
1799
|
-
function dispatchDestroyEvent() {
|
1800
|
-
const event = new CustomEvent(ACTION_DESTROY_EVENT);
|
1801
|
-
window.dispatchEvent(event);
|
1802
|
-
}
|
1803
|
-
/**
|
1804
|
-
* アクションの破棄する
|
1626
|
+
* @deprecated 非推奨
|
1805
1627
|
*
|
1806
|
-
* @
|
1628
|
+
* @internal
|
1807
1629
|
*/
|
1808
|
-
function
|
1630
|
+
function destroy() {
|
1809
1631
|
setDestroyed(true);
|
1810
1632
|
dispatchDestroyEvent();
|
1811
1633
|
}
|
1812
|
-
/**
|
1813
|
-
* アクションを表示する
|
1814
|
-
*
|
1815
|
-
* @public
|
1816
|
-
*/
|
1817
|
-
function showAction() {
|
1818
|
-
const event = new CustomEvent(ACTION_SHOW_EVENT, { detail: { trigger: 'custom' } });
|
1819
|
-
window.dispatchEvent(event);
|
1820
|
-
}
|
1821
|
-
/**
|
1822
|
-
* アクションを閉じる
|
1823
|
-
*
|
1824
|
-
* @param trigger - 閉じた時のトリガー。デフォルト `'none'`
|
1825
|
-
*
|
1826
|
-
* @public
|
1827
|
-
*/
|
1828
|
-
function closeAction(trigger = 'none') {
|
1829
|
-
const event = new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger } });
|
1830
|
-
window.dispatchEvent(event);
|
1831
|
-
}
|
1832
|
-
/** @internal */
|
1833
|
-
const KARTE_ACTION_ROOT = 'karte-action-root';
|
1834
|
-
/** @internal */
|
1835
|
-
const KARTE_ACTION_RID = 'karte-action-rid';
|
1836
|
-
/** @internal */
|
1837
|
-
const KARTE_ACTION_SHORTEN_ID = 'karte-action-id';
|
1838
|
-
/** @internal */
|
1839
|
-
function ensureActionRoot(useShadow = true) {
|
1840
|
-
const systemConfig = getSystem();
|
1841
|
-
const rootAttrs = {
|
1842
|
-
class: `${KARTE_ACTION_ROOT} ${KARTE_MODAL_ROOT}`,
|
1843
|
-
[`data-${KARTE_ACTION_RID}`]: actionId,
|
1844
|
-
[`data-${KARTE_ACTION_SHORTEN_ID}`]: systemConfig.shortenId
|
1845
|
-
? systemConfig.shortenId
|
1846
|
-
: ALL_ACTION_SHORTEN_ID,
|
1847
|
-
};
|
1848
|
-
let el = document.querySelector(`.${KARTE_MODAL_ROOT}[data-${KARTE_ACTION_RID}='${actionId}']`);
|
1849
|
-
if (el == null) {
|
1850
|
-
el = h('div', rootAttrs);
|
1851
|
-
document.body.appendChild(el);
|
1852
|
-
}
|
1853
|
-
const isShadow = !!document.body.attachShadow && useShadow;
|
1854
|
-
if (isShadow) {
|
1855
|
-
return el.shadowRoot ?? el.attachShadow({ mode: 'open' });
|
1856
|
-
}
|
1857
|
-
else {
|
1858
|
-
return el;
|
1859
|
-
}
|
1860
|
-
}
|
1861
|
-
/** @internal */
|
1862
|
-
const h = (type, props, ...children) => {
|
1863
|
-
const el = document.createElement(type);
|
1864
|
-
for (const key of Object.keys(props)) {
|
1865
|
-
const v = props[key];
|
1866
|
-
if (key === 'style') {
|
1867
|
-
Object.assign(el.style, v);
|
1868
|
-
}
|
1869
|
-
else {
|
1870
|
-
el.setAttribute(key, v);
|
1871
|
-
}
|
1872
|
-
}
|
1873
|
-
for (const child of children) {
|
1874
|
-
el.appendChild(child);
|
1875
|
-
}
|
1876
|
-
return el;
|
1877
|
-
};
|
1878
1634
|
/**
|
1879
1635
|
* 非推奨
|
1880
1636
|
*
|
@@ -1907,19 +1663,129 @@ function createFog({ color = '#000', opacity = '50%', zIndex = 999, onclick, })
|
|
1907
1663
|
root.appendChild(fog);
|
1908
1664
|
return { fog, close };
|
1909
1665
|
}
|
1666
|
+
|
1910
1667
|
/**
|
1911
|
-
*
|
1668
|
+
* スクリプト接客が利用するコードの管理
|
1669
|
+
*/
|
1670
|
+
/**
|
1671
|
+
* ES Modules に対応していない JavaScript をページに読み込む
|
1912
1672
|
*
|
1913
|
-
* @
|
1673
|
+
* @param src - JavaScript ファイルのリンク URL
|
1914
1674
|
*
|
1915
1675
|
* @public
|
1916
1676
|
*/
|
1917
|
-
function
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1677
|
+
async function loadGlobalScript(src) {
|
1678
|
+
return new Promise((resolve, reject) => {
|
1679
|
+
const script = document.createElement('script');
|
1680
|
+
script.src = src;
|
1681
|
+
document.body.appendChild(script);
|
1682
|
+
script.addEventListener('load', () => resolve(script));
|
1683
|
+
script.addEventListener('error', () => reject(script));
|
1684
|
+
});
|
1685
|
+
}
|
1686
|
+
/**
|
1687
|
+
* グローバル CSS をページに適用する
|
1688
|
+
*
|
1689
|
+
* @param css - CSS
|
1690
|
+
*
|
1691
|
+
* @public
|
1692
|
+
*/
|
1693
|
+
async function applyGlobalCss(css) {
|
1694
|
+
return new Promise((resolve, reject) => {
|
1695
|
+
const style = document.createElement('style');
|
1696
|
+
style.textContent = css;
|
1697
|
+
document.body.appendChild(style);
|
1698
|
+
style.addEventListener('load', () => resolve(style));
|
1699
|
+
style.addEventListener('error', () => reject(style));
|
1700
|
+
});
|
1701
|
+
}
|
1702
|
+
/**
|
1703
|
+
* style ファイルをページに読み込む
|
1704
|
+
*
|
1705
|
+
* @param href - style ファイルのリンク URL
|
1706
|
+
*
|
1707
|
+
* @public
|
1708
|
+
*/
|
1709
|
+
async function loadGlobalStyle(href) {
|
1710
|
+
return new Promise((resolve, reject) => {
|
1711
|
+
const link = document.createElement('link');
|
1712
|
+
link.rel = 'stylesheet';
|
1713
|
+
link.href = href;
|
1714
|
+
document.body.appendChild(link);
|
1715
|
+
link.addEventListener('load', () => resolve(link));
|
1716
|
+
link.addEventListener('error', () => reject(link));
|
1717
|
+
});
|
1718
|
+
}
|
1719
|
+
|
1720
|
+
/**
|
1721
|
+
* モーダル(ポップアップ)に関連するコードの管理
|
1722
|
+
*
|
1723
|
+
* アクションのShow, Close, ChangeStateの状態はここで管理する。
|
1724
|
+
*/
|
1725
|
+
/**
|
1726
|
+
* アクションが表示 (show) された後にフックする関数
|
1727
|
+
*
|
1728
|
+
* @param fn - 呼び出されるフック関数
|
1729
|
+
*
|
1730
|
+
* @public
|
1731
|
+
*/
|
1732
|
+
function onShow(fn) {
|
1733
|
+
let { onShowHandlers } = getInternalHandlers();
|
1734
|
+
if (!onShowHandlers) {
|
1735
|
+
onShowHandlers = [];
|
1921
1736
|
}
|
1922
|
-
|
1737
|
+
onShowHandlers.push(fn);
|
1738
|
+
setInternalHandlers({ onShowHandlers });
|
1739
|
+
}
|
1740
|
+
/**
|
1741
|
+
* アクションがクローズ (close) される前にフックする関数
|
1742
|
+
*
|
1743
|
+
* @param fn - 呼び出されるフック関数
|
1744
|
+
*
|
1745
|
+
* @public
|
1746
|
+
*/
|
1747
|
+
function onClose(fn) {
|
1748
|
+
let { onCloseHandlers } = getInternalHandlers();
|
1749
|
+
if (!onCloseHandlers) {
|
1750
|
+
onCloseHandlers = [];
|
1751
|
+
}
|
1752
|
+
onCloseHandlers.push(fn);
|
1753
|
+
setInternalHandlers({ onCloseHandlers });
|
1754
|
+
}
|
1755
|
+
/**
|
1756
|
+
* アクションのステートが変更された (changeState) 後にフックする関数
|
1757
|
+
*
|
1758
|
+
* @param fn - 呼び出されるフック関数
|
1759
|
+
*
|
1760
|
+
* @public
|
1761
|
+
*/
|
1762
|
+
function onChangeState(fn) {
|
1763
|
+
let { onChangeStateHandlers } = getInternalHandlers();
|
1764
|
+
if (!onChangeStateHandlers) {
|
1765
|
+
onChangeStateHandlers = [];
|
1766
|
+
}
|
1767
|
+
onChangeStateHandlers.push(fn);
|
1768
|
+
setInternalHandlers({ onChangeStateHandlers });
|
1769
|
+
}
|
1770
|
+
/**
|
1771
|
+
* アクションを表示する
|
1772
|
+
*
|
1773
|
+
* @public
|
1774
|
+
*/
|
1775
|
+
function showAction() {
|
1776
|
+
const event = new CustomEvent(ACTION_SHOW_EVENT, { detail: { trigger: 'custom' } });
|
1777
|
+
window.dispatchEvent(event);
|
1778
|
+
}
|
1779
|
+
/**
|
1780
|
+
* アクションを閉じる
|
1781
|
+
*
|
1782
|
+
* @param trigger - 閉じた時のトリガー。デフォルト `'none'`
|
1783
|
+
*
|
1784
|
+
* @public
|
1785
|
+
*/
|
1786
|
+
function closeAction(trigger = 'none') {
|
1787
|
+
const event = new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger } });
|
1788
|
+
window.dispatchEvent(event);
|
1923
1789
|
}
|
1924
1790
|
/**
|
1925
1791
|
* アクションに CSS を適用する
|
@@ -1934,7 +1800,7 @@ async function applyCss(css) {
|
|
1934
1800
|
return new Promise((resolve, reject) => {
|
1935
1801
|
const style = document.createElement('style');
|
1936
1802
|
style.textContent = css;
|
1937
|
-
const shadowRoot =
|
1803
|
+
const shadowRoot = getActionRoot();
|
1938
1804
|
if (!shadowRoot)
|
1939
1805
|
return;
|
1940
1806
|
shadowRoot.append(style);
|
@@ -1973,7 +1839,7 @@ async function fixFontFaceIssue(href, cssRules) {
|
|
1973
1839
|
* @public
|
1974
1840
|
*/
|
1975
1841
|
async function loadStyle(href) {
|
1976
|
-
const sr =
|
1842
|
+
const sr = getActionRoot();
|
1977
1843
|
if (!sr)
|
1978
1844
|
return;
|
1979
1845
|
let cssRules = '';
|
@@ -2002,95 +1868,30 @@ async function loadStyle(href) {
|
|
2002
1868
|
// @ts-ignore
|
2003
1869
|
document.adoptedStyleSheets = [...document.adoptedStyleSheets, css, fontFaceCss];
|
2004
1870
|
}
|
2005
|
-
//
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
/**
|
2015
|
-
* 非推奨
|
2016
|
-
*
|
2017
|
-
* @deprecated 非推奨
|
2018
|
-
*
|
2019
|
-
* @internal
|
2020
|
-
*/
|
2021
|
-
const KARTE_MODAL_ROOT = 'karte-modal-root';
|
2022
|
-
/**
|
2023
|
-
* 非推奨
|
2024
|
-
*
|
2025
|
-
* @deprecated 非推奨
|
2026
|
-
*
|
2027
|
-
* @internal
|
2028
|
-
*/
|
2029
|
-
const ensureModalRoot = ensureActionRoot;
|
2030
|
-
/**
|
2031
|
-
* 非推奨
|
2032
|
-
*
|
2033
|
-
* @deprecated 非推奨
|
2034
|
-
*
|
2035
|
-
* @internal
|
2036
|
-
*/
|
2037
|
-
const show = showAction;
|
2038
|
-
/**
|
2039
|
-
* 非推奨
|
2040
|
-
*
|
2041
|
-
* @deprecated 非推奨
|
2042
|
-
*
|
2043
|
-
* @internal
|
2044
|
-
*/
|
2045
|
-
const close = closeAction;
|
1871
|
+
// @internal
|
1872
|
+
function getCssVariables(data) {
|
1873
|
+
return Object.entries(data)
|
1874
|
+
.filter(([key, value]) => {
|
1875
|
+
return ['string', 'number'].includes(typeof value) && key.startsWith('--');
|
1876
|
+
})
|
1877
|
+
.map(([key, value]) => `${key}:${value}`)
|
1878
|
+
.join(';');
|
1879
|
+
}
|
2046
1880
|
/**
|
2047
|
-
*
|
1881
|
+
* アクションのルートの DOM 要素を取得する
|
2048
1882
|
*
|
2049
|
-
* @
|
1883
|
+
* @returns アクションがルートの DOM 要素 を持つ場合は DOM 要素を返します。ない場合は `null` を返します
|
2050
1884
|
*
|
2051
|
-
* @
|
1885
|
+
* @public
|
2052
1886
|
*/
|
2053
|
-
function
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
variables: {},
|
2058
|
-
localVariablesQuery: undefined,
|
2059
|
-
}) {
|
2060
|
-
let app = null;
|
2061
|
-
const close = () => {
|
2062
|
-
if (app) {
|
2063
|
-
app.$destroy();
|
2064
|
-
app = null;
|
2065
|
-
}
|
2066
|
-
};
|
2067
|
-
const appArgs = {
|
2068
|
-
target: null,
|
2069
|
-
props: {
|
2070
|
-
send: options.send,
|
2071
|
-
publish: options.publish,
|
2072
|
-
close,
|
2073
|
-
data: {
|
2074
|
-
...options.props,
|
2075
|
-
...options.variables,
|
2076
|
-
},
|
2077
|
-
},
|
2078
|
-
};
|
2079
|
-
{
|
2080
|
-
const win = ensureModalRoot(true);
|
2081
|
-
appArgs.target = win;
|
1887
|
+
function getActionRoot() {
|
1888
|
+
const root = document.querySelector(`.${KARTE_ACTION_ROOT}[data-${KARTE_ACTION_RID}='${actionId}']`);
|
1889
|
+
if (!root?.shadowRoot) {
|
1890
|
+
return null;
|
2082
1891
|
}
|
2083
|
-
return
|
2084
|
-
close,
|
2085
|
-
show: () => {
|
2086
|
-
if (app) {
|
2087
|
-
return;
|
2088
|
-
}
|
2089
|
-
options.send('message_open');
|
2090
|
-
app = new App(appArgs);
|
2091
|
-
},
|
2092
|
-
};
|
1892
|
+
return root.shadowRoot;
|
2093
1893
|
}
|
1894
|
+
// -------- The following codes are deprecated --------
|
2094
1895
|
/**
|
2095
1896
|
* 非推奨
|
2096
1897
|
*
|
@@ -2098,13 +1899,7 @@ function createApp(App, options = {
|
|
2098
1899
|
*
|
2099
1900
|
* @internal
|
2100
1901
|
*/
|
2101
|
-
|
2102
|
-
const root = document.querySelector(`.${KARTE_ACTION_ROOT}[data-${KARTE_ACTION_RID}='${actionId}']`);
|
2103
|
-
if (!root?.shadowRoot) {
|
2104
|
-
return null;
|
2105
|
-
}
|
2106
|
-
return root.shadowRoot;
|
2107
|
-
}
|
1902
|
+
const show = showAction;
|
2108
1903
|
/**
|
2109
1904
|
* 非推奨
|
2110
1905
|
*
|
@@ -2112,13 +1907,10 @@ function getActionShadowRoot() {
|
|
2112
1907
|
*
|
2113
1908
|
* @internal
|
2114
1909
|
*/
|
2115
|
-
|
2116
|
-
setDestroyed(true);
|
2117
|
-
dispatchDestroyEvent();
|
2118
|
-
}
|
1910
|
+
const close = closeAction;
|
2119
1911
|
|
2120
1912
|
/**
|
2121
|
-
* Widget API 互換のインターフェース
|
1913
|
+
* エディタv1のWidget API 互換のインターフェース
|
2122
1914
|
*/
|
2123
1915
|
const STORE_LS_KEY_PREFIX = 'krt___';
|
2124
1916
|
const valCallbacks = {};
|
@@ -2627,12 +2419,238 @@ function instance$w($$self, $$props, $$invalidate) {
|
|
2627
2419
|
|
2628
2420
|
return [path, $state, $$scope, slots];
|
2629
2421
|
}
|
2630
|
-
|
2631
|
-
class StateItem extends SvelteComponent {
|
2632
|
-
constructor(options) {
|
2633
|
-
super();
|
2634
|
-
init(this, options, instance$w, create_fragment$w, safe_not_equal, { path: 0 }, add_css$t);
|
2635
|
-
}
|
2422
|
+
|
2423
|
+
class StateItem extends SvelteComponent {
|
2424
|
+
constructor(options) {
|
2425
|
+
super();
|
2426
|
+
init(this, options, instance$w, create_fragment$w, safe_not_equal, { path: 0 }, add_css$t);
|
2427
|
+
}
|
2428
|
+
}
|
2429
|
+
|
2430
|
+
function isEmpty(value) {
|
2431
|
+
if (Array.isArray(value)) {
|
2432
|
+
return value.length === 0;
|
2433
|
+
}
|
2434
|
+
else {
|
2435
|
+
return !value;
|
2436
|
+
}
|
2437
|
+
}
|
2438
|
+
/** @internal */
|
2439
|
+
function registerInput({ name, statePath, validator = () => true, initialValue, }) {
|
2440
|
+
const writableValue = {
|
2441
|
+
subscribe(run) {
|
2442
|
+
return formData.subscribe(formData => {
|
2443
|
+
run(formData[name]?.value);
|
2444
|
+
});
|
2445
|
+
},
|
2446
|
+
set(value) {
|
2447
|
+
formData.update(prev => ({
|
2448
|
+
...prev,
|
2449
|
+
[name]: {
|
2450
|
+
statePath,
|
2451
|
+
value,
|
2452
|
+
isValid: validator(value),
|
2453
|
+
},
|
2454
|
+
}));
|
2455
|
+
},
|
2456
|
+
update(updater) {
|
2457
|
+
formData.update(prev => {
|
2458
|
+
const prevValue = prev[name]?.value;
|
2459
|
+
return {
|
2460
|
+
...prev,
|
2461
|
+
[name]: {
|
2462
|
+
statePath,
|
2463
|
+
value: updater(prevValue),
|
2464
|
+
isValid: validator(prevValue),
|
2465
|
+
},
|
2466
|
+
};
|
2467
|
+
});
|
2468
|
+
},
|
2469
|
+
};
|
2470
|
+
if (isEmpty(get(writableValue))) {
|
2471
|
+
writableValue.set(initialValue);
|
2472
|
+
}
|
2473
|
+
return writableValue;
|
2474
|
+
}
|
2475
|
+
/** @internal */
|
2476
|
+
const getValuesAreValidReader = statePath => ({
|
2477
|
+
subscribe(callback) {
|
2478
|
+
return formData.subscribe(formData => {
|
2479
|
+
const valuesAreValid = Object.entries(formData)
|
2480
|
+
.filter(([_, { statePath: s }]) => s === statePath) // eslint-disable-line @typescript-eslint/no-unused-vars
|
2481
|
+
.every(([_, { isValid }]) => isValid); // eslint-disable-line @typescript-eslint/no-unused-vars
|
2482
|
+
callback(valuesAreValid);
|
2483
|
+
});
|
2484
|
+
},
|
2485
|
+
});
|
2486
|
+
function formDataToEventValues(campaignId, formData) {
|
2487
|
+
const questions = [];
|
2488
|
+
const answersMap = {};
|
2489
|
+
Object.entries(formData).forEach(([name, dataItem]) => {
|
2490
|
+
questions.push(name);
|
2491
|
+
const value = dataItem.value;
|
2492
|
+
const answerKey = `question_${name}`;
|
2493
|
+
if (Array.isArray(value)) {
|
2494
|
+
answersMap[answerKey] = {
|
2495
|
+
choices: value,
|
2496
|
+
};
|
2497
|
+
}
|
2498
|
+
else if (typeof value === 'string') {
|
2499
|
+
answersMap[answerKey] = {
|
2500
|
+
free_answer: value,
|
2501
|
+
};
|
2502
|
+
}
|
2503
|
+
});
|
2504
|
+
return {
|
2505
|
+
[campaignId]: {
|
2506
|
+
questions,
|
2507
|
+
...answersMap,
|
2508
|
+
},
|
2509
|
+
};
|
2510
|
+
}
|
2511
|
+
/** @internal */
|
2512
|
+
function submit() {
|
2513
|
+
const systemConfig = getSystem();
|
2514
|
+
const campaignId = systemConfig.campaignId;
|
2515
|
+
if (campaignId) {
|
2516
|
+
const formData$1 = get(formData);
|
2517
|
+
const values = formDataToEventValues(campaignId, formData$1);
|
2518
|
+
return values;
|
2519
|
+
}
|
2520
|
+
return {};
|
2521
|
+
}
|
2522
|
+
|
2523
|
+
/**
|
2524
|
+
* モーダル(ポップアップ)のコンポーネントが利用するコードの管理
|
2525
|
+
*/
|
2526
|
+
function _moveTo(to) {
|
2527
|
+
window.dispatchEvent(new CustomEvent(ACTION_CHANGE_STATE_EVENT, { detail: { to, actionId } }));
|
2528
|
+
}
|
2529
|
+
/** @internal */
|
2530
|
+
const moveTo = (to) => () => {
|
2531
|
+
_moveTo(to);
|
2532
|
+
};
|
2533
|
+
/** @internal */
|
2534
|
+
const linkTo = (to, targetBlank = true) => () => {
|
2535
|
+
send_event('message_click', { url: to, state: getState$1() });
|
2536
|
+
if (targetBlank) {
|
2537
|
+
window.open(to);
|
2538
|
+
}
|
2539
|
+
else {
|
2540
|
+
location.href = to;
|
2541
|
+
}
|
2542
|
+
};
|
2543
|
+
/** @internal */
|
2544
|
+
const closeApp = (trigger) => () => {
|
2545
|
+
window.dispatchEvent(new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger } }));
|
2546
|
+
};
|
2547
|
+
/** @internal */
|
2548
|
+
const runScript = (handlerName) => () => {
|
2549
|
+
const handlers = getEventHandlers();
|
2550
|
+
const handler = handlers[handlerName];
|
2551
|
+
if (!handler)
|
2552
|
+
return;
|
2553
|
+
try {
|
2554
|
+
handler();
|
2555
|
+
}
|
2556
|
+
catch (e) {
|
2557
|
+
console.warn('Failed to run custom handler', handlerName, e);
|
2558
|
+
}
|
2559
|
+
};
|
2560
|
+
/** @internal */
|
2561
|
+
const submitForm = (to) => () => {
|
2562
|
+
const values = submit();
|
2563
|
+
send_event('_answer_question', values);
|
2564
|
+
_moveTo(to);
|
2565
|
+
};
|
2566
|
+
/** @internal */
|
2567
|
+
const execOnClickOperation = (onClickOperation) => {
|
2568
|
+
if (onClickOperation.operation === 'linkTo') {
|
2569
|
+
linkTo(...onClickOperation.args)();
|
2570
|
+
}
|
2571
|
+
else if (onClickOperation.operation === 'moveTo') {
|
2572
|
+
moveTo(...onClickOperation.args)();
|
2573
|
+
}
|
2574
|
+
else if (onClickOperation.operation === 'closeApp') {
|
2575
|
+
closeApp(onClickOperation.args[0] || 'button')();
|
2576
|
+
}
|
2577
|
+
else if (onClickOperation.operation === 'runScript') {
|
2578
|
+
runScript(onClickOperation.args[0])();
|
2579
|
+
}
|
2580
|
+
else if (onClickOperation.operation === 'submitForm') {
|
2581
|
+
submitForm(onClickOperation.args[0])();
|
2582
|
+
}
|
2583
|
+
};
|
2584
|
+
/** @internal */
|
2585
|
+
const haveFunction = (onClickOperation) => {
|
2586
|
+
return onClickOperation.operation !== 'none';
|
2587
|
+
};
|
2588
|
+
function getAnimation(animation) {
|
2589
|
+
switch (animation.type) {
|
2590
|
+
case 'fade':
|
2591
|
+
return `opacity: ${animation.progress}`;
|
2592
|
+
case 'bounce': {
|
2593
|
+
const translateX = animation.x;
|
2594
|
+
const translateY = animation.y;
|
2595
|
+
return `transform: translate3d(${translateX}%, ${translateY}%, 0) scale(${animation.progress});`;
|
2596
|
+
}
|
2597
|
+
case 'slide-down': {
|
2598
|
+
const translateX = animation.x;
|
2599
|
+
const translateY = animation.y - 100 * (1 - animation.progress);
|
2600
|
+
return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
|
2601
|
+
}
|
2602
|
+
case 'slide-up': {
|
2603
|
+
const translateX = animation.x;
|
2604
|
+
const translateY = animation.y + 100 * (1 - animation.progress);
|
2605
|
+
return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
|
2606
|
+
}
|
2607
|
+
case 'slide-left': {
|
2608
|
+
const translateX = animation.x + 100 * (1 - animation.progress);
|
2609
|
+
const translateY = animation.y;
|
2610
|
+
return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
|
2611
|
+
}
|
2612
|
+
case 'slide-right': {
|
2613
|
+
const translateX = animation.x - 100 * (1 - animation.progress);
|
2614
|
+
const translateY = animation.y;
|
2615
|
+
return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
|
2616
|
+
}
|
2617
|
+
case 'none': {
|
2618
|
+
const translateX = animation.x;
|
2619
|
+
const translateY = animation.y;
|
2620
|
+
return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
|
2621
|
+
}
|
2622
|
+
default:
|
2623
|
+
console.warn(`[action-sdk] invalid '${animation}', so we use 'transform: none' instead`);
|
2624
|
+
return 'transform: none';
|
2625
|
+
}
|
2626
|
+
}
|
2627
|
+
const EASING = {
|
2628
|
+
fade: linear,
|
2629
|
+
bounce: elasticOut,
|
2630
|
+
'slide-down': cubicOut,
|
2631
|
+
'slide-up': cubicOut,
|
2632
|
+
'slide-left': cubicOut,
|
2633
|
+
'slide-right': cubicOut,
|
2634
|
+
none: linear,
|
2635
|
+
};
|
2636
|
+
/**
|
2637
|
+
* The function to activate svelte animation.
|
2638
|
+
*
|
2639
|
+
* @param node - A target node of animation. This argument is passed by svelte, by default.
|
2640
|
+
* @param customAnimationOptions - A custom animation option object
|
2641
|
+
*
|
2642
|
+
* @see {@link https://svelte.dev/docs#template-syntax-element-directives-transition-fn-custom-transition-functions| Custom transition functions} for detail documentation
|
2643
|
+
*
|
2644
|
+
* @internal
|
2645
|
+
*/
|
2646
|
+
function customAnimation(node, { transform, animationStyle, delay = 0, duration = 1000 }) {
|
2647
|
+
const [x, y] = transform;
|
2648
|
+
return {
|
2649
|
+
delay,
|
2650
|
+
duration,
|
2651
|
+
easing: EASING[animationStyle],
|
2652
|
+
css: (progress) => getAnimation({ type: animationStyle, x, y, progress }),
|
2653
|
+
};
|
2636
2654
|
}
|
2637
2655
|
|
2638
2656
|
/* src/components/BackgroundOverray.svelte generated by Svelte v3.53.1 */
|
@@ -2730,8 +2748,8 @@ function add_css$r(target) {
|
|
2730
2748
|
append_styles(target, "svelte-1tg0tf", ".button.svelte-1tg0tf{display:block;text-decoration:none;color:inherit;border:none;background:none;margin:0;padding:0}.button.svelte-1tg0tf:link,.button.svelte-1tg0tf:visited,.button.svelte-1tg0tf:active,.button.svelte-1tg0tf:hover{color:inherit}");
|
2731
2749
|
}
|
2732
2750
|
|
2733
|
-
// (
|
2734
|
-
function create_else_block$
|
2751
|
+
// (49:0) {:else}
|
2752
|
+
function create_else_block$3(ctx) {
|
2735
2753
|
let button;
|
2736
2754
|
let current;
|
2737
2755
|
let mounted;
|
@@ -2798,7 +2816,7 @@ function create_else_block$2(ctx) {
|
|
2798
2816
|
};
|
2799
2817
|
}
|
2800
2818
|
|
2801
|
-
// (
|
2819
|
+
// (45:39)
|
2802
2820
|
function create_if_block_2(ctx) {
|
2803
2821
|
let div;
|
2804
2822
|
let current;
|
@@ -2857,7 +2875,7 @@ function create_if_block_2(ctx) {
|
|
2857
2875
|
};
|
2858
2876
|
}
|
2859
2877
|
|
2860
|
-
// (
|
2878
|
+
// (41:41)
|
2861
2879
|
function create_if_block_1$2(ctx) {
|
2862
2880
|
let a;
|
2863
2881
|
let a_href_value;
|
@@ -2937,7 +2955,7 @@ function create_if_block_1$2(ctx) {
|
|
2937
2955
|
};
|
2938
2956
|
}
|
2939
2957
|
|
2940
|
-
// (
|
2958
|
+
// (37:0) {#if disabled}
|
2941
2959
|
function create_if_block$6(ctx) {
|
2942
2960
|
let div;
|
2943
2961
|
let current;
|
@@ -3001,7 +3019,7 @@ function create_fragment$u(ctx) {
|
|
3001
3019
|
let if_block;
|
3002
3020
|
let if_block_anchor;
|
3003
3021
|
let current;
|
3004
|
-
const if_block_creators = [create_if_block$6, create_if_block_1$2, create_if_block_2, create_else_block$
|
3022
|
+
const if_block_creators = [create_if_block$6, create_if_block_1$2, create_if_block_2, create_else_block$3];
|
3005
3023
|
const if_blocks = [];
|
3006
3024
|
|
3007
3025
|
function select_block_type(ctx, dirty) {
|
@@ -3166,7 +3184,7 @@ function add_css$q(target) {
|
|
3166
3184
|
append_styles(target, "svelte-yyiwdt", ".modal.svelte-yyiwdt{position:fixed;box-sizing:border-box;z-index:2147483647;display:flex}.modal.svelte-yyiwdt > .button{flex:auto;display:flex}.close.svelte-yyiwdt{position:absolute;top:0;right:0}.close.svelte-yyiwdt > .button{position:absolute;display:flex;justify-content:center;align-items:center;background-color:transparent;border:none;cursor:pointer;padding:0;transition:all 0.25s}.close.svelte-yyiwdt > .button:hover{transform:rotate(90deg)}.modal-content.svelte-yyiwdt{flex:auto;display:flex;justify-content:center;align-items:center}");
|
3167
3185
|
}
|
3168
3186
|
|
3169
|
-
// (
|
3187
|
+
// (146:0) {#if visible}
|
3170
3188
|
function create_if_block$5(ctx) {
|
3171
3189
|
let div;
|
3172
3190
|
let button;
|
@@ -3245,7 +3263,7 @@ function create_if_block$5(ctx) {
|
|
3245
3263
|
};
|
3246
3264
|
}
|
3247
3265
|
|
3248
|
-
// (
|
3266
|
+
// (163:6) {#if closable}
|
3249
3267
|
function create_if_block_1$1(ctx) {
|
3250
3268
|
let div;
|
3251
3269
|
let button;
|
@@ -3307,7 +3325,7 @@ function create_if_block_1$1(ctx) {
|
|
3307
3325
|
};
|
3308
3326
|
}
|
3309
3327
|
|
3310
|
-
// (
|
3328
|
+
// (165:10) <Button onClick={onClose} style={_closeStyle} eventName={closeEventName} eventValue={closeEventValue}>
|
3311
3329
|
function create_default_slot_1$1(ctx) {
|
3312
3330
|
let svg;
|
3313
3331
|
let path;
|
@@ -3340,7 +3358,7 @@ function create_default_slot_1$1(ctx) {
|
|
3340
3358
|
};
|
3341
3359
|
}
|
3342
3360
|
|
3343
|
-
// (
|
3361
|
+
// (162:4) <Button {onClick} eventName={clickEventName} eventValue={clickEventValue}>
|
3344
3362
|
function create_default_slot$6(ctx) {
|
3345
3363
|
let t;
|
3346
3364
|
let div;
|
@@ -3998,7 +4016,7 @@ function get_each_context$6(ctx, list, i) {
|
|
3998
4016
|
}
|
3999
4017
|
|
4000
4018
|
// (13:2) {:else}
|
4001
|
-
function create_else_block$
|
4019
|
+
function create_else_block$2(ctx) {
|
4002
4020
|
let t_value = /*item*/ ctx[2] + "";
|
4003
4021
|
let t;
|
4004
4022
|
|
@@ -4045,7 +4063,7 @@ function create_each_block$6(ctx) {
|
|
4045
4063
|
if (dirty & /*items*/ 1) show_if = null;
|
4046
4064
|
if (show_if == null) show_if = !!/*item*/ ctx[2].match(regexp);
|
4047
4065
|
if (show_if) return create_if_block$4;
|
4048
|
-
return create_else_block$
|
4066
|
+
return create_else_block$2;
|
4049
4067
|
}
|
4050
4068
|
|
4051
4069
|
let current_block_type = select_block_type(ctx, -1);
|
@@ -4167,120 +4185,123 @@ class RenderText extends SvelteComponent {
|
|
4167
4185
|
/* src/components/TextElement.svelte generated by Svelte v3.53.1 */
|
4168
4186
|
|
4169
4187
|
function add_css$o(target) {
|
4170
|
-
append_styles(target, "svelte-
|
4188
|
+
append_styles(target, "svelte-600oh0", ".text-element-wrapper.svelte-600oh0.svelte-600oh0{position:relative;height:100%}.text-element.svelte-600oh0.svelte-600oh0{display:flex;position:relative;width:100%;height:100%;box-sizing:border-box;white-space:pre-wrap;overflow:auto;margin:0px;padding:0px}.text-link-element.svelte-600oh0.svelte-600oh0{text-decoration:none;color:inherit}.text-element-inner.svelte-600oh0.svelte-600oh0{width:100%;height:auto}.text-direction-vertical.svelte-600oh0.svelte-600oh0{writing-mode:vertical-rl}.text-direction-vertical.svelte-600oh0 .text-element-inner.svelte-600oh0{width:auto;height:100%}.tooltip.svelte-600oh0.svelte-600oh0{display:none;position:absolute;bottom:-40px;left:50%;transform:translateX(-50%);color:#fff;background-color:#3d4948;white-space:nowrap;padding:4px 8px 4px 8px;border-radius:4px;font-size:12px;z-index:2147483647}.tooltip.svelte-600oh0.svelte-600oh0:before{content:'';position:absolute;top:-13px;left:50%;margin-left:-7px;border:7px solid transparent;border-bottom:7px solid #3d4948}.tooltip.show.svelte-600oh0.svelte-600oh0{display:block}.tooltip-error.svelte-600oh0.svelte-600oh0{background-color:#c00}.tooltip-error.svelte-600oh0.svelte-600oh0:before{border-bottom:7px solid #c00}");
|
4171
4189
|
}
|
4172
4190
|
|
4173
|
-
// (
|
4174
|
-
function
|
4175
|
-
let div0;
|
4176
|
-
let t1;
|
4191
|
+
// (78:2) {:else}
|
4192
|
+
function create_else_block$1(ctx) {
|
4177
4193
|
let div1;
|
4194
|
+
let div0;
|
4195
|
+
let rendertext;
|
4196
|
+
let div1_class_value;
|
4197
|
+
let current;
|
4198
|
+
rendertext = new RenderText({ props: { text: /*text*/ ctx[0] } });
|
4178
4199
|
|
4179
4200
|
return {
|
4180
4201
|
c() {
|
4181
|
-
div0 = element("div");
|
4182
|
-
div0.textContent = "コピーしました";
|
4183
|
-
t1 = space();
|
4184
4202
|
div1 = element("div");
|
4185
|
-
|
4186
|
-
|
4187
|
-
attr(
|
4203
|
+
div0 = element("div");
|
4204
|
+
create_component(rendertext.$$.fragment);
|
4205
|
+
attr(div0, "class", "text-element-inner svelte-600oh0");
|
4206
|
+
attr(div1, "class", div1_class_value = "" + (null_to_empty(`text-element text-direction-${/*textDirection*/ ctx[1]}`) + " svelte-600oh0"));
|
4207
|
+
attr(div1, "style", /*style*/ ctx[5]);
|
4188
4208
|
},
|
4189
4209
|
m(target, anchor) {
|
4190
|
-
insert(target, div0, anchor);
|
4191
|
-
/*div0_binding*/ ctx[9](div0);
|
4192
|
-
insert(target, t1, anchor);
|
4193
4210
|
insert(target, div1, anchor);
|
4194
|
-
|
4211
|
+
append(div1, div0);
|
4212
|
+
mount_component(rendertext, div0, null);
|
4213
|
+
current = true;
|
4214
|
+
},
|
4215
|
+
p(ctx, dirty) {
|
4216
|
+
const rendertext_changes = {};
|
4217
|
+
if (dirty & /*text*/ 1) rendertext_changes.text = /*text*/ ctx[0];
|
4218
|
+
rendertext.$set(rendertext_changes);
|
4219
|
+
|
4220
|
+
if (!current || dirty & /*textDirection*/ 2 && div1_class_value !== (div1_class_value = "" + (null_to_empty(`text-element text-direction-${/*textDirection*/ ctx[1]}`) + " svelte-600oh0"))) {
|
4221
|
+
attr(div1, "class", div1_class_value);
|
4222
|
+
}
|
4223
|
+
|
4224
|
+
if (!current || dirty & /*style*/ 32) {
|
4225
|
+
attr(div1, "style", /*style*/ ctx[5]);
|
4226
|
+
}
|
4227
|
+
},
|
4228
|
+
i(local) {
|
4229
|
+
if (current) return;
|
4230
|
+
transition_in(rendertext.$$.fragment, local);
|
4231
|
+
current = true;
|
4232
|
+
},
|
4233
|
+
o(local) {
|
4234
|
+
transition_out(rendertext.$$.fragment, local);
|
4235
|
+
current = false;
|
4195
4236
|
},
|
4196
|
-
p: noop,
|
4197
4237
|
d(detaching) {
|
4198
|
-
if (detaching) detach(div0);
|
4199
|
-
/*div0_binding*/ ctx[9](null);
|
4200
|
-
if (detaching) detach(t1);
|
4201
4238
|
if (detaching) detach(div1);
|
4202
|
-
|
4239
|
+
destroy_component(rendertext);
|
4203
4240
|
}
|
4204
4241
|
};
|
4205
4242
|
}
|
4206
4243
|
|
4207
|
-
|
4208
|
-
|
4209
|
-
let
|
4210
|
-
let link_href_value;
|
4211
|
-
let t0;
|
4212
|
-
let div1;
|
4244
|
+
// (69:2) {#if enableCopy}
|
4245
|
+
function create_if_block$3(ctx) {
|
4246
|
+
let a;
|
4213
4247
|
let div0;
|
4214
4248
|
let rendertext;
|
4215
|
-
let
|
4216
|
-
let
|
4249
|
+
let a_class_value;
|
4250
|
+
let t0;
|
4251
|
+
let div1;
|
4252
|
+
let t2;
|
4253
|
+
let div2;
|
4217
4254
|
let current;
|
4218
4255
|
let mounted;
|
4219
4256
|
let dispose;
|
4220
4257
|
rendertext = new RenderText({ props: { text: /*text*/ ctx[0] } });
|
4221
|
-
let if_block = /*enableCopy*/ ctx[1] && create_if_block$3(ctx);
|
4222
4258
|
|
4223
4259
|
return {
|
4224
4260
|
c() {
|
4225
|
-
|
4226
|
-
link = element("link");
|
4227
|
-
t0 = space();
|
4228
|
-
div1 = element("div");
|
4261
|
+
a = element("a");
|
4229
4262
|
div0 = element("div");
|
4230
4263
|
create_component(rendertext.$$.fragment);
|
4231
|
-
|
4232
|
-
|
4233
|
-
|
4234
|
-
|
4235
|
-
|
4236
|
-
|
4237
|
-
attr(
|
4238
|
-
attr(
|
4264
|
+
t0 = space();
|
4265
|
+
div1 = element("div");
|
4266
|
+
div1.textContent = "コピーしました";
|
4267
|
+
t2 = space();
|
4268
|
+
div2 = element("div");
|
4269
|
+
div2.textContent = "コピーできませんでした";
|
4270
|
+
attr(div0, "class", "text-element-inner svelte-600oh0");
|
4271
|
+
attr(a, "href", '');
|
4272
|
+
attr(a, "class", a_class_value = "" + (null_to_empty(`text-element text-link-element text-direction-${/*textDirection*/ ctx[1]}`) + " svelte-600oh0"));
|
4273
|
+
attr(a, "style", /*style*/ ctx[5]);
|
4274
|
+
attr(div1, "class", "tooltip svelte-600oh0");
|
4275
|
+
attr(div2, "class", "tooltip tooltip-error svelte-600oh0");
|
4239
4276
|
},
|
4240
4277
|
m(target, anchor) {
|
4241
|
-
insert(target,
|
4242
|
-
append(
|
4243
|
-
append(div2, t0);
|
4244
|
-
append(div2, div1);
|
4245
|
-
append(div1, div0);
|
4278
|
+
insert(target, a, anchor);
|
4279
|
+
append(a, div0);
|
4246
4280
|
mount_component(rendertext, div0, null);
|
4247
|
-
|
4248
|
-
|
4281
|
+
insert(target, t0, anchor);
|
4282
|
+
insert(target, div1, anchor);
|
4283
|
+
/*div1_binding*/ ctx[10](div1);
|
4284
|
+
insert(target, t2, anchor);
|
4285
|
+
insert(target, div2, anchor);
|
4286
|
+
/*div2_binding*/ ctx[11](div2);
|
4249
4287
|
current = true;
|
4250
4288
|
|
4251
4289
|
if (!mounted) {
|
4252
|
-
dispose = listen(
|
4290
|
+
dispose = listen(a, "click", /*onCopy*/ ctx[6]);
|
4253
4291
|
mounted = true;
|
4254
4292
|
}
|
4255
4293
|
},
|
4256
|
-
p(ctx,
|
4257
|
-
if (!current || dirty & /*text*/ 1 && link_href_value !== (link_href_value = `https://fonts.googleapis.com/css2?${getGoogleFontsParam()}&display=swap&text=${/*text*/ ctx[0]}`)) {
|
4258
|
-
attr(link, "href", link_href_value);
|
4259
|
-
}
|
4260
|
-
|
4294
|
+
p(ctx, dirty) {
|
4261
4295
|
const rendertext_changes = {};
|
4262
4296
|
if (dirty & /*text*/ 1) rendertext_changes.text = /*text*/ ctx[0];
|
4263
4297
|
rendertext.$set(rendertext_changes);
|
4264
4298
|
|
4265
|
-
if (!current || dirty & /*textDirection*/
|
4266
|
-
attr(
|
4299
|
+
if (!current || dirty & /*textDirection*/ 2 && a_class_value !== (a_class_value = "" + (null_to_empty(`text-element text-link-element text-direction-${/*textDirection*/ ctx[1]}`) + " svelte-600oh0"))) {
|
4300
|
+
attr(a, "class", a_class_value);
|
4267
4301
|
}
|
4268
4302
|
|
4269
4303
|
if (!current || dirty & /*style*/ 32) {
|
4270
|
-
attr(
|
4271
|
-
}
|
4272
|
-
|
4273
|
-
if (/*enableCopy*/ ctx[1]) {
|
4274
|
-
if (if_block) {
|
4275
|
-
if_block.p(ctx, dirty);
|
4276
|
-
} else {
|
4277
|
-
if_block = create_if_block$3(ctx);
|
4278
|
-
if_block.c();
|
4279
|
-
if_block.m(div2, null);
|
4280
|
-
}
|
4281
|
-
} else if (if_block) {
|
4282
|
-
if_block.d(1);
|
4283
|
-
if_block = null;
|
4304
|
+
attr(a, "style", /*style*/ ctx[5]);
|
4284
4305
|
}
|
4285
4306
|
},
|
4286
4307
|
i(local) {
|
@@ -4293,53 +4314,147 @@ function create_fragment$p(ctx) {
|
|
4293
4314
|
current = false;
|
4294
4315
|
},
|
4295
4316
|
d(detaching) {
|
4296
|
-
if (detaching) detach(
|
4317
|
+
if (detaching) detach(a);
|
4297
4318
|
destroy_component(rendertext);
|
4298
|
-
if (
|
4319
|
+
if (detaching) detach(t0);
|
4320
|
+
if (detaching) detach(div1);
|
4321
|
+
/*div1_binding*/ ctx[10](null);
|
4322
|
+
if (detaching) detach(t2);
|
4323
|
+
if (detaching) detach(div2);
|
4324
|
+
/*div2_binding*/ ctx[11](null);
|
4299
4325
|
mounted = false;
|
4300
4326
|
dispose();
|
4301
4327
|
}
|
4302
4328
|
};
|
4303
4329
|
}
|
4304
4330
|
|
4331
|
+
function create_fragment$p(ctx) {
|
4332
|
+
let div;
|
4333
|
+
let link;
|
4334
|
+
let link_href_value;
|
4335
|
+
let t;
|
4336
|
+
let current_block_type_index;
|
4337
|
+
let if_block;
|
4338
|
+
let current;
|
4339
|
+
const if_block_creators = [create_if_block$3, create_else_block$1];
|
4340
|
+
const if_blocks = [];
|
4341
|
+
|
4342
|
+
function select_block_type(ctx, dirty) {
|
4343
|
+
if (/*enableCopy*/ ctx[2]) return 0;
|
4344
|
+
return 1;
|
4345
|
+
}
|
4346
|
+
|
4347
|
+
current_block_type_index = select_block_type(ctx);
|
4348
|
+
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
|
4349
|
+
|
4350
|
+
return {
|
4351
|
+
c() {
|
4352
|
+
div = element("div");
|
4353
|
+
link = element("link");
|
4354
|
+
t = space();
|
4355
|
+
if_block.c();
|
4356
|
+
attr(link, "href", link_href_value = `https://fonts.googleapis.com/css2?${getGoogleFontsParam()}&display=swap&text=${/*text*/ ctx[0]}`);
|
4357
|
+
attr(link, "rel", "stylesheet");
|
4358
|
+
attr(div, "class", "text-element-wrapper svelte-600oh0");
|
4359
|
+
},
|
4360
|
+
m(target, anchor) {
|
4361
|
+
insert(target, div, anchor);
|
4362
|
+
append(div, link);
|
4363
|
+
append(div, t);
|
4364
|
+
if_blocks[current_block_type_index].m(div, null);
|
4365
|
+
current = true;
|
4366
|
+
},
|
4367
|
+
p(ctx, [dirty]) {
|
4368
|
+
if (!current || dirty & /*text*/ 1 && link_href_value !== (link_href_value = `https://fonts.googleapis.com/css2?${getGoogleFontsParam()}&display=swap&text=${/*text*/ ctx[0]}`)) {
|
4369
|
+
attr(link, "href", link_href_value);
|
4370
|
+
}
|
4371
|
+
|
4372
|
+
let previous_block_index = current_block_type_index;
|
4373
|
+
current_block_type_index = select_block_type(ctx);
|
4374
|
+
|
4375
|
+
if (current_block_type_index === previous_block_index) {
|
4376
|
+
if_blocks[current_block_type_index].p(ctx, dirty);
|
4377
|
+
} else {
|
4378
|
+
group_outros();
|
4379
|
+
|
4380
|
+
transition_out(if_blocks[previous_block_index], 1, 1, () => {
|
4381
|
+
if_blocks[previous_block_index] = null;
|
4382
|
+
});
|
4383
|
+
|
4384
|
+
check_outros();
|
4385
|
+
if_block = if_blocks[current_block_type_index];
|
4386
|
+
|
4387
|
+
if (!if_block) {
|
4388
|
+
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
|
4389
|
+
if_block.c();
|
4390
|
+
} else {
|
4391
|
+
if_block.p(ctx, dirty);
|
4392
|
+
}
|
4393
|
+
|
4394
|
+
transition_in(if_block, 1);
|
4395
|
+
if_block.m(div, null);
|
4396
|
+
}
|
4397
|
+
},
|
4398
|
+
i(local) {
|
4399
|
+
if (current) return;
|
4400
|
+
transition_in(if_block);
|
4401
|
+
current = true;
|
4402
|
+
},
|
4403
|
+
o(local) {
|
4404
|
+
transition_out(if_block);
|
4405
|
+
current = false;
|
4406
|
+
},
|
4407
|
+
d(detaching) {
|
4408
|
+
if (detaching) detach(div);
|
4409
|
+
if_blocks[current_block_type_index].d();
|
4410
|
+
}
|
4411
|
+
};
|
4412
|
+
}
|
4413
|
+
|
4305
4414
|
function instance$p($$self, $$props, $$invalidate) {
|
4306
4415
|
let style;
|
4307
4416
|
let { text = 'サンプルSample' } = $$props;
|
4417
|
+
let { _textStyle = 'font-size:12px; line-height: 1.5;' } = $$props;
|
4418
|
+
let { textDirection = 'horizontal' } = $$props;
|
4419
|
+
let { _style = '' } = $$props;
|
4308
4420
|
let { enableCopy = false } = $$props;
|
4421
|
+
let { eventName = '' } = $$props;
|
4422
|
+
let eventValue = undefined;
|
4309
4423
|
let tooltipEl;
|
4310
4424
|
let tooltipErrorEl;
|
4311
4425
|
|
4312
|
-
const
|
4313
|
-
|
4314
|
-
|
4315
|
-
|
4316
|
-
|
4317
|
-
|
4318
|
-
|
4426
|
+
const onCopy = async e => {
|
4427
|
+
e.preventDefault();
|
4428
|
+
|
4429
|
+
try {
|
4430
|
+
await navigator.clipboard.writeText(text);
|
4431
|
+
|
4432
|
+
if (eventName) {
|
4433
|
+
send_event(eventName, eventValue);
|
4319
4434
|
}
|
4320
4435
|
|
4321
|
-
|
4322
|
-
|
4323
|
-
|
4324
|
-
tooltipErrorEl.classList.remove('show');
|
4325
|
-
},
|
4326
|
-
1000
|
4327
|
-
);
|
4436
|
+
tooltipEl.classList.add('show');
|
4437
|
+
} catch(err) {
|
4438
|
+
tooltipErrorEl.classList.add('show');
|
4328
4439
|
}
|
4329
|
-
};
|
4330
4440
|
|
4331
|
-
|
4332
|
-
|
4333
|
-
|
4441
|
+
setTimeout(
|
4442
|
+
() => {
|
4443
|
+
tooltipEl.classList.remove('show');
|
4444
|
+
tooltipErrorEl.classList.remove('show');
|
4445
|
+
},
|
4446
|
+
1000
|
4447
|
+
);
|
4448
|
+
};
|
4334
4449
|
|
4335
|
-
function
|
4450
|
+
function div1_binding($$value) {
|
4336
4451
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
4337
4452
|
tooltipEl = $$value;
|
4338
4453
|
$$invalidate(3, tooltipEl);
|
4339
4454
|
});
|
4340
4455
|
}
|
4341
4456
|
|
4342
|
-
function
|
4457
|
+
function div2_binding($$value) {
|
4343
4458
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
4344
4459
|
tooltipErrorEl = $$value;
|
4345
4460
|
$$invalidate(4, tooltipErrorEl);
|
@@ -4348,10 +4463,11 @@ function instance$p($$self, $$props, $$invalidate) {
|
|
4348
4463
|
|
4349
4464
|
$$self.$$set = $$props => {
|
4350
4465
|
if ('text' in $$props) $$invalidate(0, text = $$props.text);
|
4351
|
-
if ('enableCopy' in $$props) $$invalidate(1, enableCopy = $$props.enableCopy);
|
4352
4466
|
if ('_textStyle' in $$props) $$invalidate(7, _textStyle = $$props._textStyle);
|
4353
|
-
if ('textDirection' in $$props) $$invalidate(
|
4467
|
+
if ('textDirection' in $$props) $$invalidate(1, textDirection = $$props.textDirection);
|
4354
4468
|
if ('_style' in $$props) $$invalidate(8, _style = $$props._style);
|
4469
|
+
if ('enableCopy' in $$props) $$invalidate(2, enableCopy = $$props.enableCopy);
|
4470
|
+
if ('eventName' in $$props) $$invalidate(9, eventName = $$props.eventName);
|
4355
4471
|
};
|
4356
4472
|
|
4357
4473
|
$$self.$$.update = () => {
|
@@ -4362,16 +4478,17 @@ function instance$p($$self, $$props, $$invalidate) {
|
|
4362
4478
|
|
4363
4479
|
return [
|
4364
4480
|
text,
|
4365
|
-
enableCopy,
|
4366
4481
|
textDirection,
|
4482
|
+
enableCopy,
|
4367
4483
|
tooltipEl,
|
4368
4484
|
tooltipErrorEl,
|
4369
4485
|
style,
|
4370
|
-
|
4486
|
+
onCopy,
|
4371
4487
|
_textStyle,
|
4372
4488
|
_style,
|
4373
|
-
|
4374
|
-
div1_binding
|
4489
|
+
eventName,
|
4490
|
+
div1_binding,
|
4491
|
+
div2_binding
|
4375
4492
|
];
|
4376
4493
|
}
|
4377
4494
|
|
@@ -4387,10 +4504,11 @@ class TextElement extends SvelteComponent {
|
|
4387
4504
|
safe_not_equal,
|
4388
4505
|
{
|
4389
4506
|
text: 0,
|
4390
|
-
enableCopy: 1,
|
4391
4507
|
_textStyle: 7,
|
4392
|
-
textDirection:
|
4393
|
-
_style: 8
|
4508
|
+
textDirection: 1,
|
4509
|
+
_style: 8,
|
4510
|
+
enableCopy: 2,
|
4511
|
+
eventName: 9
|
4394
4512
|
},
|
4395
4513
|
add_css$o
|
4396
4514
|
);
|