@plaidev/karte-action-sdk 1.1.176 → 1.1.177-28039844.a230804c
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/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/hydrate/index.es.js
CHANGED
@@ -1,8 +1,33 @@
|
|
1
|
-
import '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_hydration, group_outros, check_outros, detach, component_subscribe, element, space, claim_element, children, claim_space, attr, noop, listen, null_to_empty, is_function, create_component, claim_component, mount_component, destroy_component, add_render_callback, create_in_transition, binding_callbacks, set_style, svg_element, claim_svg_element, append_hydration, destroy_each, text, claim_text, set_data, src_url_equal, HtmlTagHydration, claim_html_tag, construct_svelte_component, subscribe } from 'svelte/internal';
|
4
|
+
import '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,10 @@ const NOOP = (_args) => { }; // eslint-disable-line @typescript-eslint/no-unused
|
|
247
272
|
const isPreview = () => {
|
248
273
|
return true;
|
249
274
|
};
|
275
|
+
// prettier-ignore
|
276
|
+
/** @internal */
|
277
|
+
const actionId = ALL_ACTION_ID
|
278
|
+
;
|
250
279
|
/** @internal */
|
251
280
|
const handleFocus = (node) => (e) => {
|
252
281
|
if (node) {
|
@@ -445,6 +474,23 @@ function hasSuffix(value, suffix) {
|
|
445
474
|
function getGoogleFontsParam() {
|
446
475
|
return 'family=' + Fonts.map(font => font.replace(/ /g, '+')).join('&family=');
|
447
476
|
}
|
477
|
+
/** @internal */
|
478
|
+
const h = (type, props, ...children) => {
|
479
|
+
const el = document.createElement(type);
|
480
|
+
for (const key of Object.keys(props)) {
|
481
|
+
const v = props[key];
|
482
|
+
if (key === 'style') {
|
483
|
+
Object.assign(el.style, v);
|
484
|
+
}
|
485
|
+
else {
|
486
|
+
el.setAttribute(key, v);
|
487
|
+
}
|
488
|
+
}
|
489
|
+
for (const child of children) {
|
490
|
+
el.appendChild(child);
|
491
|
+
}
|
492
|
+
return el;
|
493
|
+
};
|
448
494
|
|
449
495
|
/**
|
450
496
|
* Store to handle action setting
|
@@ -807,385 +853,109 @@ function resetVariables() {
|
|
807
853
|
*/
|
808
854
|
const formData = writable({});
|
809
855
|
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
856
|
+
/**
|
857
|
+
* アクションのログの記録の管理
|
858
|
+
*/
|
859
|
+
const MESSAGES_LIMIT = 1000;
|
860
|
+
const EVENTS_LIMIT = 1000;
|
861
|
+
// 実行ログ
|
862
|
+
let logs = [];
|
863
|
+
// KARTEイベント
|
864
|
+
let events = [];
|
818
865
|
/** @internal */
|
819
|
-
function
|
820
|
-
|
821
|
-
subscribe(run) {
|
822
|
-
return formData.subscribe(formData => {
|
823
|
-
run(formData[name]?.value);
|
824
|
-
});
|
825
|
-
},
|
826
|
-
set(value) {
|
827
|
-
formData.update(prev => ({
|
828
|
-
...prev,
|
829
|
-
[name]: {
|
830
|
-
statePath,
|
831
|
-
value,
|
832
|
-
isValid: validator(value),
|
833
|
-
},
|
834
|
-
}));
|
835
|
-
},
|
836
|
-
update(updater) {
|
837
|
-
formData.update(prev => {
|
838
|
-
const prevValue = prev[name]?.value;
|
839
|
-
return {
|
840
|
-
...prev,
|
841
|
-
[name]: {
|
842
|
-
statePath,
|
843
|
-
value: updater(prevValue),
|
844
|
-
isValid: validator(prevValue),
|
845
|
-
},
|
846
|
-
};
|
847
|
-
});
|
848
|
-
},
|
849
|
-
};
|
850
|
-
if (isEmpty(get(writableValue))) {
|
851
|
-
writableValue.set(initialValue);
|
852
|
-
}
|
853
|
-
return writableValue;
|
866
|
+
function getLogs() {
|
867
|
+
return logs;
|
854
868
|
}
|
855
869
|
/** @internal */
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
870
|
+
function getEvents() {
|
871
|
+
return events;
|
872
|
+
}
|
873
|
+
// iframe内の場合は親windowを参照する
|
874
|
+
function w(w) {
|
875
|
+
return w.parent === w ? w : w.parent;
|
876
|
+
}
|
877
|
+
/**
|
878
|
+
* ログを送信する関数群
|
879
|
+
*
|
880
|
+
* @internal
|
881
|
+
*/
|
882
|
+
const logger = {
|
883
|
+
info: (...messages) => {
|
884
|
+
const log = cloneToJson({ level: 'info', messages, date: new Date() });
|
885
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
864
886
|
},
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
887
|
+
log: (...messages) => {
|
888
|
+
const log = cloneToJson({ level: 'info', messages, date: new Date() });
|
889
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
890
|
+
},
|
891
|
+
error: (...messages) => {
|
892
|
+
const log = cloneToJson({ level: 'error', messages, date: new Date() });
|
893
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
894
|
+
},
|
895
|
+
warn: (...messages) => {
|
896
|
+
const log = cloneToJson({ level: 'warn', messages, date: new Date() });
|
897
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
898
|
+
},
|
899
|
+
system: (...messages) => {
|
900
|
+
const log = cloneToJson({ level: 'system', messages, date: new Date() });
|
901
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
902
|
+
},
|
903
|
+
event: (name, values) => {
|
904
|
+
const event = values ? { name, values, date: new Date() } : { name, date: new Date() };
|
905
|
+
w(window).postMessage({
|
906
|
+
type: 'KARTE-ACTION-LOGGER',
|
907
|
+
detail: { method: 'event', event, values: values },
|
908
|
+
}, '*');
|
909
|
+
},
|
910
|
+
clear: () => {
|
911
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clear' } }, '*');
|
912
|
+
},
|
913
|
+
clearEvents: () => {
|
914
|
+
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clearEvents' } }, '*');
|
915
|
+
},
|
916
|
+
};
|
917
|
+
/**
|
918
|
+
* メッセージを実行ログに表示する
|
919
|
+
*
|
920
|
+
* @internal
|
921
|
+
*/
|
922
|
+
function listenLogger() {
|
923
|
+
const handler = (event) => {
|
924
|
+
const { type, detail } = event.data;
|
925
|
+
if (event.origin !== location.origin) {
|
926
|
+
return;
|
877
927
|
}
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
928
|
+
if (type !== 'KARTE-ACTION-LOGGER') {
|
929
|
+
return;
|
930
|
+
}
|
931
|
+
if (detail.method === 'clear') {
|
932
|
+
logs = [];
|
933
|
+
}
|
934
|
+
else if (detail.method === 'clearEvents') {
|
935
|
+
events = [];
|
936
|
+
}
|
937
|
+
else if (detail.method === 'log') {
|
938
|
+
if (MESSAGES_LIMIT <= logs.length) {
|
939
|
+
logs.shift();
|
940
|
+
}
|
941
|
+
const { level, messages } = detail.log;
|
942
|
+
const log = { level, messages, date: new Date() };
|
943
|
+
logs.push(log);
|
944
|
+
}
|
945
|
+
else if (detail.method === 'event') {
|
946
|
+
if (EVENTS_LIMIT <= events.length) {
|
947
|
+
events.shift();
|
948
|
+
}
|
949
|
+
const { name, values } = detail.event;
|
950
|
+
const karteEvent = values
|
951
|
+
? { name, values, date: new Date() }
|
952
|
+
: { name, date: new Date() };
|
953
|
+
events.push(karteEvent);
|
882
954
|
}
|
883
|
-
}
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
...answersMap,
|
888
|
-
},
|
889
|
-
};
|
890
|
-
}
|
891
|
-
/** @internal */
|
892
|
-
function submit() {
|
893
|
-
const systemConfig = getSystem();
|
894
|
-
const campaignId = systemConfig.campaignId;
|
895
|
-
if (campaignId) {
|
896
|
-
const formData$1 = get(formData);
|
897
|
-
const values = formDataToEventValues(campaignId, formData$1);
|
898
|
-
return values;
|
899
|
-
}
|
900
|
-
{
|
901
|
-
const formData$1 = get(formData);
|
902
|
-
const values = formDataToEventValues('mock', formData$1);
|
903
|
-
console.log('values: ', values);
|
904
|
-
return values;
|
905
|
-
}
|
906
|
-
}
|
907
|
-
|
908
|
-
/** @internal */
|
909
|
-
const ALL_ACTION_ID = 'KARTE_ALL_ACTION_ID';
|
910
|
-
/** @internal */
|
911
|
-
const ALL_ACTION_SHORTEN_ID = 'KARTE_ALL_ACTION_SHORTEN_ID';
|
912
|
-
// prettier-ignore
|
913
|
-
/** @internal */
|
914
|
-
const actionId = ALL_ACTION_ID
|
915
|
-
;
|
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
|
-
/**
|
1013
|
-
* The function to activate svelte animation.
|
1014
|
-
*
|
1015
|
-
* @param node - A target node of animation. This argument is passed by svelte, by default.
|
1016
|
-
* @param customAnimationOptions - A custom animation option object
|
1017
|
-
*
|
1018
|
-
* @see {@link https://svelte.dev/docs#template-syntax-element-directives-transition-fn-custom-transition-functions| Custom transition functions} for detail documentation
|
1019
|
-
*
|
1020
|
-
* @internal
|
1021
|
-
*/
|
1022
|
-
function customAnimation(node, { transform, animationStyle, delay = 0, duration = 1000 }) {
|
1023
|
-
{
|
1024
|
-
return {};
|
1025
|
-
}
|
1026
|
-
}
|
1027
|
-
/**
|
1028
|
-
* ES Modules に対応していない JavaScript をページに読み込む
|
1029
|
-
*
|
1030
|
-
* @param src - JavaScript ファイルのリンク URL
|
1031
|
-
*
|
1032
|
-
* @public
|
1033
|
-
*/
|
1034
|
-
async function loadGlobalScript(src) {
|
1035
|
-
return new Promise((resolve, reject) => {
|
1036
|
-
const script = document.createElement('script');
|
1037
|
-
script.src = src;
|
1038
|
-
document.body.appendChild(script);
|
1039
|
-
script.addEventListener('load', () => resolve(script));
|
1040
|
-
script.addEventListener('error', () => reject(script));
|
1041
|
-
});
|
1042
|
-
}
|
1043
|
-
/**
|
1044
|
-
* グローバル CSS をページに適用する
|
1045
|
-
*
|
1046
|
-
* @param css - CSS
|
1047
|
-
*
|
1048
|
-
* @public
|
1049
|
-
*/
|
1050
|
-
async function applyGlobalCss(css) {
|
1051
|
-
return new Promise((resolve, reject) => {
|
1052
|
-
const style = document.createElement('style');
|
1053
|
-
style.textContent = css;
|
1054
|
-
document.body.appendChild(style);
|
1055
|
-
style.addEventListener('load', () => resolve(style));
|
1056
|
-
style.addEventListener('error', () => reject(style));
|
1057
|
-
});
|
1058
|
-
}
|
1059
|
-
/**
|
1060
|
-
* style ファイルをページに読み込む
|
1061
|
-
*
|
1062
|
-
* @param href - style ファイルのリンク URL
|
1063
|
-
*
|
1064
|
-
* @public
|
1065
|
-
*/
|
1066
|
-
async function loadGlobalStyle(href) {
|
1067
|
-
return new Promise((resolve, reject) => {
|
1068
|
-
const link = document.createElement('link');
|
1069
|
-
link.rel = 'stylesheet';
|
1070
|
-
link.href = href;
|
1071
|
-
document.body.appendChild(link);
|
1072
|
-
link.addEventListener('load', () => resolve(link));
|
1073
|
-
link.addEventListener('error', () => reject(link));
|
1074
|
-
});
|
1075
|
-
}
|
1076
|
-
// @internal
|
1077
|
-
function getCssVariables(data) {
|
1078
|
-
return Object.entries(data)
|
1079
|
-
.filter(([key, value]) => {
|
1080
|
-
return ['string', 'number'].includes(typeof value) && key.startsWith('--');
|
1081
|
-
})
|
1082
|
-
.map(([key, value]) => `${key}:${value}`)
|
1083
|
-
.join(';');
|
1084
|
-
}
|
1085
|
-
|
1086
|
-
/**
|
1087
|
-
* アクションのログの記録の管理
|
1088
|
-
*/
|
1089
|
-
const MESSAGES_LIMIT = 1000;
|
1090
|
-
const EVENTS_LIMIT = 1000;
|
1091
|
-
// 実行ログ
|
1092
|
-
let logs = [];
|
1093
|
-
// KARTEイベント
|
1094
|
-
let events = [];
|
1095
|
-
/** @internal */
|
1096
|
-
function getLogs() {
|
1097
|
-
return logs;
|
1098
|
-
}
|
1099
|
-
/** @internal */
|
1100
|
-
function getEvents() {
|
1101
|
-
return events;
|
1102
|
-
}
|
1103
|
-
// iframe内の場合は親windowを参照する
|
1104
|
-
function w(w) {
|
1105
|
-
return w.parent === w ? w : w.parent;
|
1106
|
-
}
|
1107
|
-
/**
|
1108
|
-
* ログを送信する関数群
|
1109
|
-
*
|
1110
|
-
* @internal
|
1111
|
-
*/
|
1112
|
-
const logger = {
|
1113
|
-
info: (...messages) => {
|
1114
|
-
const log = cloneToJson({ level: 'info', messages, date: new Date() });
|
1115
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
1116
|
-
},
|
1117
|
-
log: (...messages) => {
|
1118
|
-
const log = cloneToJson({ level: 'info', messages, date: new Date() });
|
1119
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
1120
|
-
},
|
1121
|
-
error: (...messages) => {
|
1122
|
-
const log = cloneToJson({ level: 'error', messages, date: new Date() });
|
1123
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
1124
|
-
},
|
1125
|
-
warn: (...messages) => {
|
1126
|
-
const log = cloneToJson({ level: 'warn', messages, date: new Date() });
|
1127
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
1128
|
-
},
|
1129
|
-
system: (...messages) => {
|
1130
|
-
const log = cloneToJson({ level: 'system', messages, date: new Date() });
|
1131
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
1132
|
-
},
|
1133
|
-
event: (name, values) => {
|
1134
|
-
const event = values ? { name, values, date: new Date() } : { name, date: new Date() };
|
1135
|
-
w(window).postMessage({
|
1136
|
-
type: 'KARTE-ACTION-LOGGER',
|
1137
|
-
detail: { method: 'event', event, values: values },
|
1138
|
-
}, '*');
|
1139
|
-
},
|
1140
|
-
clear: () => {
|
1141
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clear' } }, '*');
|
1142
|
-
},
|
1143
|
-
clearEvents: () => {
|
1144
|
-
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clearEvents' } }, '*');
|
1145
|
-
},
|
1146
|
-
};
|
1147
|
-
/**
|
1148
|
-
* メッセージを実行ログに表示する
|
1149
|
-
*
|
1150
|
-
* @internal
|
1151
|
-
*/
|
1152
|
-
function listenLogger() {
|
1153
|
-
const handler = (event) => {
|
1154
|
-
const { type, detail } = event.data;
|
1155
|
-
if (event.origin !== location.origin) {
|
1156
|
-
return;
|
1157
|
-
}
|
1158
|
-
if (type !== 'KARTE-ACTION-LOGGER') {
|
1159
|
-
return;
|
1160
|
-
}
|
1161
|
-
if (detail.method === 'clear') {
|
1162
|
-
logs = [];
|
1163
|
-
}
|
1164
|
-
else if (detail.method === 'clearEvents') {
|
1165
|
-
events = [];
|
1166
|
-
}
|
1167
|
-
else if (detail.method === 'log') {
|
1168
|
-
if (MESSAGES_LIMIT <= logs.length) {
|
1169
|
-
logs.shift();
|
1170
|
-
}
|
1171
|
-
const { level, messages } = detail.log;
|
1172
|
-
const log = { level, messages, date: new Date() };
|
1173
|
-
logs.push(log);
|
1174
|
-
}
|
1175
|
-
else if (detail.method === 'event') {
|
1176
|
-
if (EVENTS_LIMIT <= events.length) {
|
1177
|
-
events.shift();
|
1178
|
-
}
|
1179
|
-
const { name, values } = detail.event;
|
1180
|
-
const karteEvent = values
|
1181
|
-
? { name, values, date: new Date() }
|
1182
|
-
: { name, date: new Date() };
|
1183
|
-
events.push(karteEvent);
|
1184
|
-
}
|
1185
|
-
};
|
1186
|
-
window.addEventListener('message', handler, false);
|
1187
|
-
return () => {
|
1188
|
-
window.removeEventListener('message', handler, false);
|
955
|
+
};
|
956
|
+
window.addEventListener('message', handler, false);
|
957
|
+
return () => {
|
958
|
+
window.removeEventListener('message', handler, false);
|
1189
959
|
};
|
1190
960
|
}
|
1191
961
|
const { info, log, error, warn } = console;
|
@@ -1229,6 +999,9 @@ function cloneToJson(data) {
|
|
1229
999
|
}
|
1230
1000
|
}
|
1231
1001
|
|
1002
|
+
/**
|
1003
|
+
* モーダル(ポップアップ)のロジックを管理する
|
1004
|
+
*/
|
1232
1005
|
function doPresent({ direction, deltaRate }, downFn, upFn, condition = false) {
|
1233
1006
|
if (direction === 'down' && deltaRate > 0) {
|
1234
1007
|
downFn();
|
@@ -1321,6 +1094,23 @@ function showOnTime(props, show = NOOP) {
|
|
1321
1094
|
: null;
|
1322
1095
|
}
|
1323
1096
|
|
1097
|
+
/** @internal */
|
1098
|
+
const ACTION_DESTROY_EVENT = `KARTE-ACTION-DESTROY-${actionId}`;
|
1099
|
+
/** @internal */
|
1100
|
+
const ACTION_SHOW_EVENT = `KARTE-ACTION-SHOW-${actionId}`;
|
1101
|
+
/** @internal */
|
1102
|
+
const ACTION_CLOSE_EVENT = `KARTE-ACTION-CLOSE-${actionId}`;
|
1103
|
+
/** @internal */
|
1104
|
+
const ACTION_CHANGE_STATE_EVENT = `KARTE-ACTION-CHANGE-STATE-${actionId}`;
|
1105
|
+
/** @internal */
|
1106
|
+
const send_event = (event_name, values) => {
|
1107
|
+
const setting = getSetting();
|
1108
|
+
setting?.send?.(event_name, values);
|
1109
|
+
};
|
1110
|
+
|
1111
|
+
/**
|
1112
|
+
* アクションテーブルに関連するコードの管理
|
1113
|
+
*/
|
1324
1114
|
const DEFAULT_COLLECTION_ENDPOINT = typeof __FLYER_GEN_COLLECTION_API_ENDPOINT__ === 'string'
|
1325
1115
|
? __FLYER_GEN_COLLECTION_API_ENDPOINT__
|
1326
1116
|
: 'https://t.karte.io/collection';
|
@@ -1413,83 +1203,34 @@ const loadActionTable = async (config, api_key, endpoint) => {
|
|
1413
1203
|
}, {});
|
1414
1204
|
};
|
1415
1205
|
|
1416
|
-
/** @internal */
|
1417
|
-
const ACTION_HOOK_LABEL = '__ACTION_HOOK__';
|
1418
|
-
/**
|
1419
|
-
* アクションが作成 (create) される前にフックする関数
|
1420
|
-
*
|
1421
|
-
* @param fn - 呼び出されるフック関数
|
1422
|
-
*
|
1423
|
-
* @public
|
1424
|
-
*/
|
1425
|
-
function onCreate(fn) {
|
1426
|
-
let { onCreateHandlers } = getInternalHandlers();
|
1427
|
-
if (!onCreateHandlers) {
|
1428
|
-
onCreateHandlers = [];
|
1429
|
-
}
|
1430
|
-
onCreateHandlers.push(fn);
|
1431
|
-
setInternalHandlers({ onCreateHandlers });
|
1432
|
-
}
|
1433
1206
|
/**
|
1434
|
-
*
|
1435
|
-
*
|
1436
|
-
* @param fn - 呼び出されるフック関数
|
1437
|
-
*
|
1438
|
-
* @public
|
1439
|
-
*/
|
1440
|
-
function onShow(fn) {
|
1441
|
-
let { onShowHandlers } = getInternalHandlers();
|
1442
|
-
if (!onShowHandlers) {
|
1443
|
-
onShowHandlers = [];
|
1444
|
-
}
|
1445
|
-
onShowHandlers.push(fn);
|
1446
|
-
setInternalHandlers({ onShowHandlers });
|
1447
|
-
}
|
1448
|
-
/**
|
1449
|
-
* アクションがクローズ (close) される前にフックする関数
|
1207
|
+
* Edgeが起動するアクションに関連するコードを管理する
|
1450
1208
|
*
|
1451
|
-
*
|
1209
|
+
* アクションのCreate, Destroyの状態はここで管理する。
|
1452
1210
|
*
|
1453
|
-
*
|
1211
|
+
* FIXME: モーダルなどの機能ごとのコードを分離したい
|
1454
1212
|
*/
|
1455
|
-
|
1456
|
-
|
1457
|
-
if (
|
1458
|
-
|
1459
|
-
|
1460
|
-
onCloseHandlers.push(fn);
|
1461
|
-
setInternalHandlers({ onCloseHandlers });
|
1462
|
-
}
|
1463
|
-
/**
|
1464
|
-
* アクションが破棄 (destroy) される前にフックする関数
|
1465
|
-
*
|
1466
|
-
* @param fn - 呼び出されるフック関数
|
1467
|
-
*
|
1468
|
-
* @public
|
1469
|
-
*/
|
1470
|
-
function onDestroy(fn) {
|
1471
|
-
let { onDestroyHandlers } = getInternalHandlers();
|
1472
|
-
if (!onDestroyHandlers) {
|
1473
|
-
onDestroyHandlers = [];
|
1213
|
+
/** @internal */
|
1214
|
+
const handleState = (event) => {
|
1215
|
+
if (event.detail.actionId === actionId || event.detail.actionId === ALL_ACTION_ID) {
|
1216
|
+
send_event('_message_state_changed', { state: event.detail.to });
|
1217
|
+
setState$1(event.detail.to, { disableInPreview: event.detail.disableInPreview });
|
1474
1218
|
}
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
* @param fn - 呼び出されるフック関数
|
1482
|
-
*
|
1483
|
-
* @public
|
1484
|
-
*/
|
1485
|
-
function onChangeState(fn) {
|
1486
|
-
let { onChangeStateHandlers } = getInternalHandlers();
|
1487
|
-
if (!onChangeStateHandlers) {
|
1488
|
-
onChangeStateHandlers = [];
|
1219
|
+
};
|
1220
|
+
/** @internal */
|
1221
|
+
const initialize = (setting) => {
|
1222
|
+
const newSetting = setSetting(setting);
|
1223
|
+
if (newSetting.initialState) {
|
1224
|
+
setState$1(newSetting.initialState);
|
1489
1225
|
}
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1226
|
+
setOpened(true);
|
1227
|
+
setClosed(false); // deprecated
|
1228
|
+
return () => finalize();
|
1229
|
+
};
|
1230
|
+
/** @internal */
|
1231
|
+
const finalize = () => {
|
1232
|
+
resetSetting();
|
1233
|
+
};
|
1493
1234
|
/**
|
1494
1235
|
* アクションを作成する
|
1495
1236
|
*
|
@@ -1681,6 +1422,29 @@ function create(App, options = {
|
|
1681
1422
|
};
|
1682
1423
|
return appCleanup;
|
1683
1424
|
}
|
1425
|
+
/** @internal */
|
1426
|
+
function ensureActionRoot(useShadow = true) {
|
1427
|
+
const systemConfig = getSystem();
|
1428
|
+
const rootAttrs = {
|
1429
|
+
class: `${KARTE_ACTION_ROOT} ${KARTE_MODAL_ROOT}`,
|
1430
|
+
[`data-${KARTE_ACTION_RID}`]: actionId,
|
1431
|
+
[`data-${KARTE_ACTION_SHORTEN_ID}`]: systemConfig.shortenId
|
1432
|
+
? systemConfig.shortenId
|
1433
|
+
: ALL_ACTION_SHORTEN_ID,
|
1434
|
+
};
|
1435
|
+
let el = document.querySelector(`.${KARTE_MODAL_ROOT}[data-${KARTE_ACTION_RID}='${actionId}']`);
|
1436
|
+
if (el == null) {
|
1437
|
+
el = h('div', rootAttrs);
|
1438
|
+
document.body.appendChild(el);
|
1439
|
+
}
|
1440
|
+
const isShadow = !!document.body.attachShadow && useShadow;
|
1441
|
+
if (isShadow) {
|
1442
|
+
return el.shadowRoot ?? el.attachShadow({ mode: 'open' });
|
1443
|
+
}
|
1444
|
+
else {
|
1445
|
+
return el;
|
1446
|
+
}
|
1447
|
+
}
|
1684
1448
|
/**
|
1685
1449
|
* Dispatch the event to destroy KARTE action
|
1686
1450
|
*
|
@@ -1700,71 +1464,111 @@ function destroyAction() {
|
|
1700
1464
|
dispatchDestroyEvent();
|
1701
1465
|
}
|
1702
1466
|
/**
|
1703
|
-
*
|
1467
|
+
* アクションが作成 (create) される前にフックする関数
|
1468
|
+
*
|
1469
|
+
* @param fn - 呼び出されるフック関数
|
1704
1470
|
*
|
1705
1471
|
* @public
|
1706
1472
|
*/
|
1707
|
-
function
|
1708
|
-
|
1709
|
-
|
1473
|
+
function onCreate(fn) {
|
1474
|
+
let { onCreateHandlers } = getInternalHandlers();
|
1475
|
+
if (!onCreateHandlers) {
|
1476
|
+
onCreateHandlers = [];
|
1477
|
+
}
|
1478
|
+
onCreateHandlers.push(fn);
|
1479
|
+
setInternalHandlers({ onCreateHandlers });
|
1480
|
+
}
|
1481
|
+
/**
|
1482
|
+
* アクションが破棄 (destroy) される前にフックする関数
|
1483
|
+
*
|
1484
|
+
* @param fn - 呼び出されるフック関数
|
1485
|
+
*
|
1486
|
+
* @public
|
1487
|
+
*/
|
1488
|
+
function onDestroy(fn) {
|
1489
|
+
let { onDestroyHandlers } = getInternalHandlers();
|
1490
|
+
if (!onDestroyHandlers) {
|
1491
|
+
onDestroyHandlers = [];
|
1492
|
+
}
|
1493
|
+
onDestroyHandlers.push(fn);
|
1494
|
+
setInternalHandlers({ onDestroyHandlers });
|
1495
|
+
}
|
1496
|
+
/**
|
1497
|
+
* 非推奨
|
1498
|
+
*
|
1499
|
+
* @deprecated 非推奨
|
1500
|
+
*
|
1501
|
+
* @internal
|
1502
|
+
*/
|
1503
|
+
const showModal = create;
|
1504
|
+
/**
|
1505
|
+
* 非推奨
|
1506
|
+
*
|
1507
|
+
* @deprecated 非推奨
|
1508
|
+
*
|
1509
|
+
* @internal
|
1510
|
+
*/
|
1511
|
+
const ensureModalRoot = ensureActionRoot;
|
1512
|
+
/**
|
1513
|
+
* 非推奨
|
1514
|
+
*
|
1515
|
+
* @deprecated 非推奨
|
1516
|
+
*
|
1517
|
+
* @internal
|
1518
|
+
*/
|
1519
|
+
function createApp(App, options = {
|
1520
|
+
send: () => { },
|
1521
|
+
publish: () => { },
|
1522
|
+
props: {},
|
1523
|
+
variables: {},
|
1524
|
+
localVariablesQuery: undefined,
|
1525
|
+
}) {
|
1526
|
+
let app = null;
|
1527
|
+
const close = () => {
|
1528
|
+
if (app) {
|
1529
|
+
app.$destroy();
|
1530
|
+
app = null;
|
1531
|
+
}
|
1532
|
+
};
|
1533
|
+
const appArgs = {
|
1534
|
+
target: null,
|
1535
|
+
props: {
|
1536
|
+
send: options.send,
|
1537
|
+
publish: options.publish,
|
1538
|
+
close,
|
1539
|
+
data: {
|
1540
|
+
...options.props,
|
1541
|
+
...options.variables,
|
1542
|
+
},
|
1543
|
+
},
|
1544
|
+
};
|
1545
|
+
{
|
1546
|
+
const win = ensureModalRoot(false);
|
1547
|
+
appArgs.target = win;
|
1548
|
+
appArgs.hydrate = true;
|
1549
|
+
}
|
1550
|
+
return {
|
1551
|
+
close,
|
1552
|
+
show: () => {
|
1553
|
+
if (app) {
|
1554
|
+
return;
|
1555
|
+
}
|
1556
|
+
options.send('message_open');
|
1557
|
+
app = new App(appArgs);
|
1558
|
+
},
|
1559
|
+
};
|
1710
1560
|
}
|
1711
1561
|
/**
|
1712
|
-
*
|
1562
|
+
* 非推奨
|
1713
1563
|
*
|
1714
|
-
* @
|
1564
|
+
* @deprecated 非推奨
|
1715
1565
|
*
|
1716
|
-
* @
|
1566
|
+
* @internal
|
1717
1567
|
*/
|
1718
|
-
function
|
1719
|
-
|
1720
|
-
|
1721
|
-
}
|
1722
|
-
/** @internal */
|
1723
|
-
const KARTE_ACTION_ROOT = 'karte-action-root';
|
1724
|
-
/** @internal */
|
1725
|
-
const KARTE_ACTION_RID = 'karte-action-rid';
|
1726
|
-
/** @internal */
|
1727
|
-
const KARTE_ACTION_SHORTEN_ID = 'karte-action-id';
|
1728
|
-
/** @internal */
|
1729
|
-
function ensureActionRoot(useShadow = true) {
|
1730
|
-
const systemConfig = getSystem();
|
1731
|
-
const rootAttrs = {
|
1732
|
-
class: `${KARTE_ACTION_ROOT} ${KARTE_MODAL_ROOT}`,
|
1733
|
-
[`data-${KARTE_ACTION_RID}`]: actionId,
|
1734
|
-
[`data-${KARTE_ACTION_SHORTEN_ID}`]: systemConfig.shortenId
|
1735
|
-
? systemConfig.shortenId
|
1736
|
-
: ALL_ACTION_SHORTEN_ID,
|
1737
|
-
};
|
1738
|
-
let el = document.querySelector(`.${KARTE_MODAL_ROOT}[data-${KARTE_ACTION_RID}='${actionId}']`);
|
1739
|
-
if (el == null) {
|
1740
|
-
el = h('div', rootAttrs);
|
1741
|
-
document.body.appendChild(el);
|
1742
|
-
}
|
1743
|
-
const isShadow = !!document.body.attachShadow && useShadow;
|
1744
|
-
if (isShadow) {
|
1745
|
-
return el.shadowRoot ?? el.attachShadow({ mode: 'open' });
|
1746
|
-
}
|
1747
|
-
else {
|
1748
|
-
return el;
|
1749
|
-
}
|
1568
|
+
function destroy() {
|
1569
|
+
setDestroyed(true);
|
1570
|
+
dispatchDestroyEvent();
|
1750
1571
|
}
|
1751
|
-
/** @internal */
|
1752
|
-
const h = (type, props, ...children) => {
|
1753
|
-
const el = document.createElement(type);
|
1754
|
-
for (const key of Object.keys(props)) {
|
1755
|
-
const v = props[key];
|
1756
|
-
if (key === 'style') {
|
1757
|
-
Object.assign(el.style, v);
|
1758
|
-
}
|
1759
|
-
else {
|
1760
|
-
el.setAttribute(key, v);
|
1761
|
-
}
|
1762
|
-
}
|
1763
|
-
for (const child of children) {
|
1764
|
-
el.appendChild(child);
|
1765
|
-
}
|
1766
|
-
return el;
|
1767
|
-
};
|
1768
1572
|
/**
|
1769
1573
|
* 非推奨
|
1770
1574
|
*
|
@@ -1797,19 +1601,129 @@ function createFog({ color = '#000', opacity = '50%', zIndex = 999, onclick, })
|
|
1797
1601
|
root.appendChild(fog);
|
1798
1602
|
return { fog, close };
|
1799
1603
|
}
|
1604
|
+
|
1800
1605
|
/**
|
1801
|
-
*
|
1606
|
+
* スクリプト接客が利用するコードの管理
|
1607
|
+
*/
|
1608
|
+
/**
|
1609
|
+
* ES Modules に対応していない JavaScript をページに読み込む
|
1802
1610
|
*
|
1803
|
-
* @
|
1611
|
+
* @param src - JavaScript ファイルのリンク URL
|
1804
1612
|
*
|
1805
1613
|
* @public
|
1806
1614
|
*/
|
1807
|
-
function
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1615
|
+
async function loadGlobalScript(src) {
|
1616
|
+
return new Promise((resolve, reject) => {
|
1617
|
+
const script = document.createElement('script');
|
1618
|
+
script.src = src;
|
1619
|
+
document.body.appendChild(script);
|
1620
|
+
script.addEventListener('load', () => resolve(script));
|
1621
|
+
script.addEventListener('error', () => reject(script));
|
1622
|
+
});
|
1623
|
+
}
|
1624
|
+
/**
|
1625
|
+
* グローバル CSS をページに適用する
|
1626
|
+
*
|
1627
|
+
* @param css - CSS
|
1628
|
+
*
|
1629
|
+
* @public
|
1630
|
+
*/
|
1631
|
+
async function applyGlobalCss(css) {
|
1632
|
+
return new Promise((resolve, reject) => {
|
1633
|
+
const style = document.createElement('style');
|
1634
|
+
style.textContent = css;
|
1635
|
+
document.body.appendChild(style);
|
1636
|
+
style.addEventListener('load', () => resolve(style));
|
1637
|
+
style.addEventListener('error', () => reject(style));
|
1638
|
+
});
|
1639
|
+
}
|
1640
|
+
/**
|
1641
|
+
* style ファイルをページに読み込む
|
1642
|
+
*
|
1643
|
+
* @param href - style ファイルのリンク URL
|
1644
|
+
*
|
1645
|
+
* @public
|
1646
|
+
*/
|
1647
|
+
async function loadGlobalStyle(href) {
|
1648
|
+
return new Promise((resolve, reject) => {
|
1649
|
+
const link = document.createElement('link');
|
1650
|
+
link.rel = 'stylesheet';
|
1651
|
+
link.href = href;
|
1652
|
+
document.body.appendChild(link);
|
1653
|
+
link.addEventListener('load', () => resolve(link));
|
1654
|
+
link.addEventListener('error', () => reject(link));
|
1655
|
+
});
|
1656
|
+
}
|
1657
|
+
|
1658
|
+
/**
|
1659
|
+
* モーダル(ポップアップ)に関連するコードの管理
|
1660
|
+
*
|
1661
|
+
* アクションのShow, Close, ChangeStateの状態はここで管理する。
|
1662
|
+
*/
|
1663
|
+
/**
|
1664
|
+
* アクションが表示 (show) された後にフックする関数
|
1665
|
+
*
|
1666
|
+
* @param fn - 呼び出されるフック関数
|
1667
|
+
*
|
1668
|
+
* @public
|
1669
|
+
*/
|
1670
|
+
function onShow(fn) {
|
1671
|
+
let { onShowHandlers } = getInternalHandlers();
|
1672
|
+
if (!onShowHandlers) {
|
1673
|
+
onShowHandlers = [];
|
1811
1674
|
}
|
1812
|
-
|
1675
|
+
onShowHandlers.push(fn);
|
1676
|
+
setInternalHandlers({ onShowHandlers });
|
1677
|
+
}
|
1678
|
+
/**
|
1679
|
+
* アクションがクローズ (close) される前にフックする関数
|
1680
|
+
*
|
1681
|
+
* @param fn - 呼び出されるフック関数
|
1682
|
+
*
|
1683
|
+
* @public
|
1684
|
+
*/
|
1685
|
+
function onClose(fn) {
|
1686
|
+
let { onCloseHandlers } = getInternalHandlers();
|
1687
|
+
if (!onCloseHandlers) {
|
1688
|
+
onCloseHandlers = [];
|
1689
|
+
}
|
1690
|
+
onCloseHandlers.push(fn);
|
1691
|
+
setInternalHandlers({ onCloseHandlers });
|
1692
|
+
}
|
1693
|
+
/**
|
1694
|
+
* アクションのステートが変更された (changeState) 後にフックする関数
|
1695
|
+
*
|
1696
|
+
* @param fn - 呼び出されるフック関数
|
1697
|
+
*
|
1698
|
+
* @public
|
1699
|
+
*/
|
1700
|
+
function onChangeState(fn) {
|
1701
|
+
let { onChangeStateHandlers } = getInternalHandlers();
|
1702
|
+
if (!onChangeStateHandlers) {
|
1703
|
+
onChangeStateHandlers = [];
|
1704
|
+
}
|
1705
|
+
onChangeStateHandlers.push(fn);
|
1706
|
+
setInternalHandlers({ onChangeStateHandlers });
|
1707
|
+
}
|
1708
|
+
/**
|
1709
|
+
* アクションを表示する
|
1710
|
+
*
|
1711
|
+
* @public
|
1712
|
+
*/
|
1713
|
+
function showAction() {
|
1714
|
+
const event = new CustomEvent(ACTION_SHOW_EVENT, { detail: { trigger: 'custom' } });
|
1715
|
+
window.dispatchEvent(event);
|
1716
|
+
}
|
1717
|
+
/**
|
1718
|
+
* アクションを閉じる
|
1719
|
+
*
|
1720
|
+
* @param trigger - 閉じた時のトリガー。デフォルト `'none'`
|
1721
|
+
*
|
1722
|
+
* @public
|
1723
|
+
*/
|
1724
|
+
function closeAction(trigger = 'none') {
|
1725
|
+
const event = new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger } });
|
1726
|
+
window.dispatchEvent(event);
|
1813
1727
|
}
|
1814
1728
|
/**
|
1815
1729
|
* アクションに CSS を適用する
|
@@ -1824,7 +1738,7 @@ async function applyCss(css) {
|
|
1824
1738
|
return new Promise((resolve, reject) => {
|
1825
1739
|
const style = document.createElement('style');
|
1826
1740
|
style.textContent = css;
|
1827
|
-
const shadowRoot =
|
1741
|
+
const shadowRoot = getActionRoot();
|
1828
1742
|
if (!shadowRoot)
|
1829
1743
|
return;
|
1830
1744
|
shadowRoot.append(style);
|
@@ -1863,125 +1777,59 @@ async function fixFontFaceIssue(href, cssRules) {
|
|
1863
1777
|
* @public
|
1864
1778
|
*/
|
1865
1779
|
async function loadStyle(href) {
|
1866
|
-
const sr =
|
1780
|
+
const sr = getActionRoot();
|
1867
1781
|
if (!sr)
|
1868
1782
|
return;
|
1869
1783
|
let cssRules = '';
|
1870
1784
|
try {
|
1871
1785
|
const res = await fetch(href);
|
1872
|
-
cssRules = await res.text();
|
1873
|
-
}
|
1874
|
-
catch (e) {
|
1875
|
-
// pass
|
1876
|
-
}
|
1877
|
-
if (!cssRules)
|
1878
|
-
return;
|
1879
|
-
// Chromeのバグで、Shadow Rootの@font-faceを絶対パスで指定する必要がある
|
1880
|
-
// @see https://stackoverflow.com/a/63717709
|
1881
|
-
const [rules, fontFaceRules] = await fixFontFaceIssue(href, cssRules);
|
1882
|
-
const css = new CSSStyleSheet();
|
1883
|
-
// @ts-ignore
|
1884
|
-
await css.replace(rules);
|
1885
|
-
const fontFaceCss = new CSSStyleSheet();
|
1886
|
-
// @ts-ignore
|
1887
|
-
await fontFaceCss.replace(fontFaceRules);
|
1888
|
-
// @ts-ignore
|
1889
|
-
sr.adoptedStyleSheets = [...sr.adoptedStyleSheets, css, fontFaceCss];
|
1890
|
-
// Chromeのバグで、ページとShadow Rootの両方に、@font-faceを設定する必要がある
|
1891
|
-
// @see https://stackoverflow.com/a/63717709
|
1892
|
-
// @ts-ignore
|
1893
|
-
document.adoptedStyleSheets = [...document.adoptedStyleSheets, css, fontFaceCss];
|
1894
|
-
}
|
1895
|
-
//
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
/**
|
1905
|
-
* 非推奨
|
1906
|
-
*
|
1907
|
-
* @deprecated 非推奨
|
1908
|
-
*
|
1909
|
-
* @internal
|
1910
|
-
*/
|
1911
|
-
const KARTE_MODAL_ROOT = 'karte-modal-root';
|
1912
|
-
/**
|
1913
|
-
* 非推奨
|
1914
|
-
*
|
1915
|
-
* @deprecated 非推奨
|
1916
|
-
*
|
1917
|
-
* @internal
|
1918
|
-
*/
|
1919
|
-
const ensureModalRoot = ensureActionRoot;
|
1920
|
-
/**
|
1921
|
-
* 非推奨
|
1922
|
-
*
|
1923
|
-
* @deprecated 非推奨
|
1924
|
-
*
|
1925
|
-
* @internal
|
1926
|
-
*/
|
1927
|
-
const show = showAction;
|
1928
|
-
/**
|
1929
|
-
* 非推奨
|
1930
|
-
*
|
1931
|
-
* @deprecated 非推奨
|
1932
|
-
*
|
1933
|
-
* @internal
|
1934
|
-
*/
|
1935
|
-
const close = closeAction;
|
1786
|
+
cssRules = await res.text();
|
1787
|
+
}
|
1788
|
+
catch (e) {
|
1789
|
+
// pass
|
1790
|
+
}
|
1791
|
+
if (!cssRules)
|
1792
|
+
return;
|
1793
|
+
// Chromeのバグで、Shadow Rootの@font-faceを絶対パスで指定する必要がある
|
1794
|
+
// @see https://stackoverflow.com/a/63717709
|
1795
|
+
const [rules, fontFaceRules] = await fixFontFaceIssue(href, cssRules);
|
1796
|
+
const css = new CSSStyleSheet();
|
1797
|
+
// @ts-ignore
|
1798
|
+
await css.replace(rules);
|
1799
|
+
const fontFaceCss = new CSSStyleSheet();
|
1800
|
+
// @ts-ignore
|
1801
|
+
await fontFaceCss.replace(fontFaceRules);
|
1802
|
+
// @ts-ignore
|
1803
|
+
sr.adoptedStyleSheets = [...sr.adoptedStyleSheets, css, fontFaceCss];
|
1804
|
+
// Chromeのバグで、ページとShadow Rootの両方に、@font-faceを設定する必要がある
|
1805
|
+
// @see https://stackoverflow.com/a/63717709
|
1806
|
+
// @ts-ignore
|
1807
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, css, fontFaceCss];
|
1808
|
+
}
|
1809
|
+
// @internal
|
1810
|
+
function getCssVariables(data) {
|
1811
|
+
return Object.entries(data)
|
1812
|
+
.filter(([key, value]) => {
|
1813
|
+
return ['string', 'number'].includes(typeof value) && key.startsWith('--');
|
1814
|
+
})
|
1815
|
+
.map(([key, value]) => `${key}:${value}`)
|
1816
|
+
.join(';');
|
1817
|
+
}
|
1936
1818
|
/**
|
1937
|
-
*
|
1819
|
+
* アクションのルートの DOM 要素を取得する
|
1938
1820
|
*
|
1939
|
-
* @
|
1821
|
+
* @returns アクションがルートの DOM 要素 を持つ場合は DOM 要素を返します。ない場合は `null` を返します
|
1940
1822
|
*
|
1941
|
-
* @
|
1823
|
+
* @public
|
1942
1824
|
*/
|
1943
|
-
function
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
variables: {},
|
1948
|
-
localVariablesQuery: undefined,
|
1949
|
-
}) {
|
1950
|
-
let app = null;
|
1951
|
-
const close = () => {
|
1952
|
-
if (app) {
|
1953
|
-
app.$destroy();
|
1954
|
-
app = null;
|
1955
|
-
}
|
1956
|
-
};
|
1957
|
-
const appArgs = {
|
1958
|
-
target: null,
|
1959
|
-
props: {
|
1960
|
-
send: options.send,
|
1961
|
-
publish: options.publish,
|
1962
|
-
close,
|
1963
|
-
data: {
|
1964
|
-
...options.props,
|
1965
|
-
...options.variables,
|
1966
|
-
},
|
1967
|
-
},
|
1968
|
-
};
|
1969
|
-
{
|
1970
|
-
const win = ensureModalRoot(false);
|
1971
|
-
appArgs.target = win;
|
1972
|
-
appArgs.hydrate = true;
|
1825
|
+
function getActionRoot() {
|
1826
|
+
const root = document.querySelector(`.${KARTE_ACTION_ROOT}[data-${KARTE_ACTION_RID}='${actionId}']`);
|
1827
|
+
if (!root?.shadowRoot) {
|
1828
|
+
return null;
|
1973
1829
|
}
|
1974
|
-
return
|
1975
|
-
close,
|
1976
|
-
show: () => {
|
1977
|
-
if (app) {
|
1978
|
-
return;
|
1979
|
-
}
|
1980
|
-
options.send('message_open');
|
1981
|
-
app = new App(appArgs);
|
1982
|
-
},
|
1983
|
-
};
|
1830
|
+
return root.shadowRoot;
|
1984
1831
|
}
|
1832
|
+
// -------- The following codes are deprecated --------
|
1985
1833
|
/**
|
1986
1834
|
* 非推奨
|
1987
1835
|
*
|
@@ -1989,13 +1837,7 @@ function createApp(App, options = {
|
|
1989
1837
|
*
|
1990
1838
|
* @internal
|
1991
1839
|
*/
|
1992
|
-
|
1993
|
-
const root = document.querySelector(`.${KARTE_ACTION_ROOT}[data-${KARTE_ACTION_RID}='${actionId}']`);
|
1994
|
-
if (!root?.shadowRoot) {
|
1995
|
-
return null;
|
1996
|
-
}
|
1997
|
-
return root.shadowRoot;
|
1998
|
-
}
|
1840
|
+
const show = showAction;
|
1999
1841
|
/**
|
2000
1842
|
* 非推奨
|
2001
1843
|
*
|
@@ -2003,13 +1845,10 @@ function getActionShadowRoot() {
|
|
2003
1845
|
*
|
2004
1846
|
* @internal
|
2005
1847
|
*/
|
2006
|
-
|
2007
|
-
setDestroyed(true);
|
2008
|
-
dispatchDestroyEvent();
|
2009
|
-
}
|
1848
|
+
const close = closeAction;
|
2010
1849
|
|
2011
1850
|
/**
|
2012
|
-
* Widget API 互換のインターフェース
|
1851
|
+
* エディタv1のWidget API 互換のインターフェース
|
2013
1852
|
*/
|
2014
1853
|
const STORE_LS_KEY_PREFIX = 'krt___';
|
2015
1854
|
const valCallbacks = {};
|
@@ -2543,6 +2382,185 @@ class StateItem extends SvelteComponent {
|
|
2543
2382
|
}
|
2544
2383
|
}
|
2545
2384
|
|
2385
|
+
function isEmpty(value) {
|
2386
|
+
if (Array.isArray(value)) {
|
2387
|
+
return value.length === 0;
|
2388
|
+
}
|
2389
|
+
else {
|
2390
|
+
return !value;
|
2391
|
+
}
|
2392
|
+
}
|
2393
|
+
/** @internal */
|
2394
|
+
function registerInput({ name, statePath, validator = () => true, initialValue, }) {
|
2395
|
+
const writableValue = {
|
2396
|
+
subscribe(run) {
|
2397
|
+
return formData.subscribe(formData => {
|
2398
|
+
run(formData[name]?.value);
|
2399
|
+
});
|
2400
|
+
},
|
2401
|
+
set(value) {
|
2402
|
+
formData.update(prev => ({
|
2403
|
+
...prev,
|
2404
|
+
[name]: {
|
2405
|
+
statePath,
|
2406
|
+
value,
|
2407
|
+
isValid: validator(value),
|
2408
|
+
},
|
2409
|
+
}));
|
2410
|
+
},
|
2411
|
+
update(updater) {
|
2412
|
+
formData.update(prev => {
|
2413
|
+
const prevValue = prev[name]?.value;
|
2414
|
+
return {
|
2415
|
+
...prev,
|
2416
|
+
[name]: {
|
2417
|
+
statePath,
|
2418
|
+
value: updater(prevValue),
|
2419
|
+
isValid: validator(prevValue),
|
2420
|
+
},
|
2421
|
+
};
|
2422
|
+
});
|
2423
|
+
},
|
2424
|
+
};
|
2425
|
+
if (isEmpty(get(writableValue))) {
|
2426
|
+
writableValue.set(initialValue);
|
2427
|
+
}
|
2428
|
+
return writableValue;
|
2429
|
+
}
|
2430
|
+
/** @internal */
|
2431
|
+
const getValuesAreValidReader = statePath => ({
|
2432
|
+
subscribe(callback) {
|
2433
|
+
return formData.subscribe(formData => {
|
2434
|
+
const valuesAreValid = Object.entries(formData)
|
2435
|
+
.filter(([_, { statePath: s }]) => s === statePath) // eslint-disable-line @typescript-eslint/no-unused-vars
|
2436
|
+
.every(([_, { isValid }]) => isValid); // eslint-disable-line @typescript-eslint/no-unused-vars
|
2437
|
+
callback(valuesAreValid);
|
2438
|
+
});
|
2439
|
+
},
|
2440
|
+
});
|
2441
|
+
function formDataToEventValues(campaignId, formData) {
|
2442
|
+
const questions = [];
|
2443
|
+
const answersMap = {};
|
2444
|
+
Object.entries(formData).forEach(([name, dataItem]) => {
|
2445
|
+
questions.push(name);
|
2446
|
+
const value = dataItem.value;
|
2447
|
+
const answerKey = `question_${name}`;
|
2448
|
+
if (Array.isArray(value)) {
|
2449
|
+
answersMap[answerKey] = {
|
2450
|
+
choices: value,
|
2451
|
+
};
|
2452
|
+
}
|
2453
|
+
else if (typeof value === 'string') {
|
2454
|
+
answersMap[answerKey] = {
|
2455
|
+
free_answer: value,
|
2456
|
+
};
|
2457
|
+
}
|
2458
|
+
});
|
2459
|
+
return {
|
2460
|
+
[campaignId]: {
|
2461
|
+
questions,
|
2462
|
+
...answersMap,
|
2463
|
+
},
|
2464
|
+
};
|
2465
|
+
}
|
2466
|
+
/** @internal */
|
2467
|
+
function submit() {
|
2468
|
+
const systemConfig = getSystem();
|
2469
|
+
const campaignId = systemConfig.campaignId;
|
2470
|
+
if (campaignId) {
|
2471
|
+
const formData$1 = get(formData);
|
2472
|
+
const values = formDataToEventValues(campaignId, formData$1);
|
2473
|
+
return values;
|
2474
|
+
}
|
2475
|
+
{
|
2476
|
+
const formData$1 = get(formData);
|
2477
|
+
const values = formDataToEventValues('mock', formData$1);
|
2478
|
+
console.log('values: ', values);
|
2479
|
+
return values;
|
2480
|
+
}
|
2481
|
+
}
|
2482
|
+
|
2483
|
+
/**
|
2484
|
+
* モーダル(ポップアップ)のコンポーネントが利用するコードの管理
|
2485
|
+
*/
|
2486
|
+
function _moveTo(to) {
|
2487
|
+
window.dispatchEvent(new CustomEvent(ACTION_CHANGE_STATE_EVENT, { detail: { to, actionId } }));
|
2488
|
+
}
|
2489
|
+
/** @internal */
|
2490
|
+
const moveTo = (to) => () => {
|
2491
|
+
_moveTo(to);
|
2492
|
+
};
|
2493
|
+
/** @internal */
|
2494
|
+
const linkTo = (to, targetBlank = true) => () => {
|
2495
|
+
send_event('message_click', { url: to, state: getState$1() });
|
2496
|
+
if (targetBlank) {
|
2497
|
+
window.open(to);
|
2498
|
+
}
|
2499
|
+
else {
|
2500
|
+
location.href = to;
|
2501
|
+
}
|
2502
|
+
};
|
2503
|
+
/** @internal */
|
2504
|
+
const closeApp = (trigger) => () => {
|
2505
|
+
window.dispatchEvent(new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger } }));
|
2506
|
+
};
|
2507
|
+
/** @internal */
|
2508
|
+
const runScript = (handlerName) => () => {
|
2509
|
+
const handlers = getEventHandlers();
|
2510
|
+
const handler = handlers[handlerName];
|
2511
|
+
if (!handler)
|
2512
|
+
return;
|
2513
|
+
try {
|
2514
|
+
handler();
|
2515
|
+
}
|
2516
|
+
catch (e) {
|
2517
|
+
console.warn('Failed to run custom handler', handlerName, e);
|
2518
|
+
}
|
2519
|
+
};
|
2520
|
+
/** @internal */
|
2521
|
+
const submitForm = (to) => () => {
|
2522
|
+
const values = submit();
|
2523
|
+
send_event('_answer_question', values);
|
2524
|
+
_moveTo(to);
|
2525
|
+
};
|
2526
|
+
/** @internal */
|
2527
|
+
const execOnClickOperation = (onClickOperation) => {
|
2528
|
+
if (onClickOperation.operation === 'linkTo') {
|
2529
|
+
linkTo(...onClickOperation.args)();
|
2530
|
+
}
|
2531
|
+
else if (onClickOperation.operation === 'moveTo') {
|
2532
|
+
moveTo(...onClickOperation.args)();
|
2533
|
+
}
|
2534
|
+
else if (onClickOperation.operation === 'closeApp') {
|
2535
|
+
closeApp(onClickOperation.args[0] || 'button')();
|
2536
|
+
}
|
2537
|
+
else if (onClickOperation.operation === 'runScript') {
|
2538
|
+
runScript(onClickOperation.args[0])();
|
2539
|
+
}
|
2540
|
+
else if (onClickOperation.operation === 'submitForm') {
|
2541
|
+
submitForm(onClickOperation.args[0])();
|
2542
|
+
}
|
2543
|
+
};
|
2544
|
+
/** @internal */
|
2545
|
+
const haveFunction = (onClickOperation) => {
|
2546
|
+
return onClickOperation.operation !== 'none';
|
2547
|
+
};
|
2548
|
+
/**
|
2549
|
+
* The function to activate svelte animation.
|
2550
|
+
*
|
2551
|
+
* @param node - A target node of animation. This argument is passed by svelte, by default.
|
2552
|
+
* @param customAnimationOptions - A custom animation option object
|
2553
|
+
*
|
2554
|
+
* @see {@link https://svelte.dev/docs#template-syntax-element-directives-transition-fn-custom-transition-functions| Custom transition functions} for detail documentation
|
2555
|
+
*
|
2556
|
+
* @internal
|
2557
|
+
*/
|
2558
|
+
function customAnimation(node, { transform, animationStyle, delay = 0, duration = 1000 }) {
|
2559
|
+
{
|
2560
|
+
return {};
|
2561
|
+
}
|
2562
|
+
}
|
2563
|
+
|
2546
2564
|
/* src/components/BackgroundOverray.svelte generated by Svelte v3.53.1 */
|
2547
2565
|
|
2548
2566
|
function add_css$s(target) {
|
@@ -2650,8 +2668,8 @@ function add_css$r(target) {
|
|
2650
2668
|
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}");
|
2651
2669
|
}
|
2652
2670
|
|
2653
|
-
// (
|
2654
|
-
function create_else_block$
|
2671
|
+
// (49:0) {:else}
|
2672
|
+
function create_else_block$3(ctx) {
|
2655
2673
|
let button;
|
2656
2674
|
let current;
|
2657
2675
|
let mounted;
|
@@ -2728,7 +2746,7 @@ function create_else_block$2(ctx) {
|
|
2728
2746
|
};
|
2729
2747
|
}
|
2730
2748
|
|
2731
|
-
// (
|
2749
|
+
// (45:39)
|
2732
2750
|
function create_if_block_2(ctx) {
|
2733
2751
|
let div;
|
2734
2752
|
let current;
|
@@ -2797,7 +2815,7 @@ function create_if_block_2(ctx) {
|
|
2797
2815
|
};
|
2798
2816
|
}
|
2799
2817
|
|
2800
|
-
// (
|
2818
|
+
// (41:41)
|
2801
2819
|
function create_if_block_1$2(ctx) {
|
2802
2820
|
let a;
|
2803
2821
|
let a_href_value;
|
@@ -2893,7 +2911,7 @@ function create_if_block_1$2(ctx) {
|
|
2893
2911
|
};
|
2894
2912
|
}
|
2895
2913
|
|
2896
|
-
// (
|
2914
|
+
// (37:0) {#if disabled}
|
2897
2915
|
function create_if_block$6(ctx) {
|
2898
2916
|
let div;
|
2899
2917
|
let current;
|
@@ -2967,7 +2985,7 @@ function create_fragment$u(ctx) {
|
|
2967
2985
|
let if_block;
|
2968
2986
|
let if_block_anchor;
|
2969
2987
|
let current;
|
2970
|
-
const if_block_creators = [create_if_block$6, create_if_block_1$2, create_if_block_2, create_else_block$
|
2988
|
+
const if_block_creators = [create_if_block$6, create_if_block_1$2, create_if_block_2, create_else_block$3];
|
2971
2989
|
const if_blocks = [];
|
2972
2990
|
|
2973
2991
|
function select_block_type(ctx, dirty) {
|
@@ -3136,7 +3154,7 @@ function add_css$q(target) {
|
|
3136
3154
|
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}");
|
3137
3155
|
}
|
3138
3156
|
|
3139
|
-
// (
|
3157
|
+
// (146:0) {#if visible}
|
3140
3158
|
function create_if_block$5(ctx) {
|
3141
3159
|
let div;
|
3142
3160
|
let button;
|
@@ -3231,7 +3249,7 @@ function create_if_block$5(ctx) {
|
|
3231
3249
|
};
|
3232
3250
|
}
|
3233
3251
|
|
3234
|
-
// (
|
3252
|
+
// (163:6) {#if closable}
|
3235
3253
|
function create_if_block_1$1(ctx) {
|
3236
3254
|
let div;
|
3237
3255
|
let button;
|
@@ -3303,7 +3321,7 @@ function create_if_block_1$1(ctx) {
|
|
3303
3321
|
};
|
3304
3322
|
}
|
3305
3323
|
|
3306
|
-
// (
|
3324
|
+
// (165:10) <Button onClick={onClose} style={_closeStyle} eventName={closeEventName} eventValue={closeEventValue}>
|
3307
3325
|
function create_default_slot_1$1(ctx) {
|
3308
3326
|
let svg;
|
3309
3327
|
let path;
|
@@ -3360,7 +3378,7 @@ function create_default_slot_1$1(ctx) {
|
|
3360
3378
|
};
|
3361
3379
|
}
|
3362
3380
|
|
3363
|
-
// (
|
3381
|
+
// (162:4) <Button {onClick} eventName={clickEventName} eventValue={clickEventValue}>
|
3364
3382
|
function create_default_slot$6(ctx) {
|
3365
3383
|
let t;
|
3366
3384
|
let div;
|
@@ -4068,7 +4086,7 @@ function get_each_context$6(ctx, list, i) {
|
|
4068
4086
|
}
|
4069
4087
|
|
4070
4088
|
// (13:2) {:else}
|
4071
|
-
function create_else_block$
|
4089
|
+
function create_else_block$2(ctx) {
|
4072
4090
|
let t_value = /*item*/ ctx[2] + "";
|
4073
4091
|
let t;
|
4074
4092
|
|
@@ -4121,7 +4139,7 @@ function create_each_block$6(ctx) {
|
|
4121
4139
|
if (dirty & /*items*/ 1) show_if = null;
|
4122
4140
|
if (show_if == null) show_if = !!/*item*/ ctx[2].match(regexp);
|
4123
4141
|
if (show_if) return create_if_block$4;
|
4124
|
-
return create_else_block$
|
4142
|
+
return create_else_block$2;
|
4125
4143
|
}
|
4126
4144
|
|
4127
4145
|
let current_block_type = select_block_type(ctx, -1);
|
@@ -4254,159 +4272,163 @@ class RenderText extends SvelteComponent {
|
|
4254
4272
|
/* src/components/TextElement.svelte generated by Svelte v3.53.1 */
|
4255
4273
|
|
4256
4274
|
function add_css$o(target) {
|
4257
|
-
append_styles(target, "svelte-
|
4275
|
+
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}");
|
4258
4276
|
}
|
4259
4277
|
|
4260
|
-
// (
|
4261
|
-
function
|
4262
|
-
let div0;
|
4263
|
-
let t0;
|
4264
|
-
let t1;
|
4278
|
+
// (78:2) {:else}
|
4279
|
+
function create_else_block$1(ctx) {
|
4265
4280
|
let div1;
|
4266
|
-
let
|
4281
|
+
let div0;
|
4282
|
+
let rendertext;
|
4283
|
+
let div1_class_value;
|
4284
|
+
let current;
|
4285
|
+
rendertext = new RenderText({ props: { text: /*text*/ ctx[0] } });
|
4267
4286
|
|
4268
4287
|
return {
|
4269
4288
|
c() {
|
4270
|
-
div0 = element("div");
|
4271
|
-
t0 = text("コピーしました");
|
4272
|
-
t1 = space();
|
4273
4289
|
div1 = element("div");
|
4274
|
-
|
4290
|
+
div0 = element("div");
|
4291
|
+
create_component(rendertext.$$.fragment);
|
4275
4292
|
this.h();
|
4276
4293
|
},
|
4277
4294
|
l(nodes) {
|
4278
|
-
|
4295
|
+
div1 = claim_element(nodes, "DIV", { class: true, style: true });
|
4296
|
+
var div1_nodes = children(div1);
|
4297
|
+
div0 = claim_element(div1_nodes, "DIV", { class: true });
|
4279
4298
|
var div0_nodes = children(div0);
|
4280
|
-
|
4299
|
+
claim_component(rendertext.$$.fragment, div0_nodes);
|
4281
4300
|
div0_nodes.forEach(detach);
|
4282
|
-
t1 = claim_space(nodes);
|
4283
|
-
div1 = claim_element(nodes, "DIV", { class: true });
|
4284
|
-
var div1_nodes = children(div1);
|
4285
|
-
t2 = claim_text(div1_nodes, "コピーできませんでした");
|
4286
4301
|
div1_nodes.forEach(detach);
|
4287
4302
|
this.h();
|
4288
4303
|
},
|
4289
4304
|
h() {
|
4290
|
-
attr(div0, "class", "
|
4291
|
-
attr(div1, "class", "
|
4305
|
+
attr(div0, "class", "text-element-inner svelte-600oh0");
|
4306
|
+
attr(div1, "class", div1_class_value = "" + (null_to_empty(`text-element text-direction-${/*textDirection*/ ctx[1]}`) + " svelte-600oh0"));
|
4307
|
+
attr(div1, "style", /*style*/ ctx[5]);
|
4292
4308
|
},
|
4293
4309
|
m(target, anchor) {
|
4294
|
-
insert_hydration(target, div0, anchor);
|
4295
|
-
append_hydration(div0, t0);
|
4296
|
-
/*div0_binding*/ ctx[9](div0);
|
4297
|
-
insert_hydration(target, t1, anchor);
|
4298
4310
|
insert_hydration(target, div1, anchor);
|
4299
|
-
append_hydration(div1,
|
4300
|
-
|
4311
|
+
append_hydration(div1, div0);
|
4312
|
+
mount_component(rendertext, div0, null);
|
4313
|
+
current = true;
|
4314
|
+
},
|
4315
|
+
p(ctx, dirty) {
|
4316
|
+
const rendertext_changes = {};
|
4317
|
+
if (dirty & /*text*/ 1) rendertext_changes.text = /*text*/ ctx[0];
|
4318
|
+
rendertext.$set(rendertext_changes);
|
4319
|
+
|
4320
|
+
if (!current || dirty & /*textDirection*/ 2 && div1_class_value !== (div1_class_value = "" + (null_to_empty(`text-element text-direction-${/*textDirection*/ ctx[1]}`) + " svelte-600oh0"))) {
|
4321
|
+
attr(div1, "class", div1_class_value);
|
4322
|
+
}
|
4323
|
+
|
4324
|
+
if (!current || dirty & /*style*/ 32) {
|
4325
|
+
attr(div1, "style", /*style*/ ctx[5]);
|
4326
|
+
}
|
4327
|
+
},
|
4328
|
+
i(local) {
|
4329
|
+
if (current) return;
|
4330
|
+
transition_in(rendertext.$$.fragment, local);
|
4331
|
+
current = true;
|
4332
|
+
},
|
4333
|
+
o(local) {
|
4334
|
+
transition_out(rendertext.$$.fragment, local);
|
4335
|
+
current = false;
|
4301
4336
|
},
|
4302
|
-
p: noop,
|
4303
4337
|
d(detaching) {
|
4304
|
-
if (detaching) detach(div0);
|
4305
|
-
/*div0_binding*/ ctx[9](null);
|
4306
|
-
if (detaching) detach(t1);
|
4307
4338
|
if (detaching) detach(div1);
|
4308
|
-
|
4339
|
+
destroy_component(rendertext);
|
4309
4340
|
}
|
4310
4341
|
};
|
4311
4342
|
}
|
4312
4343
|
|
4313
|
-
|
4314
|
-
|
4315
|
-
let
|
4316
|
-
let link_href_value;
|
4317
|
-
let t0;
|
4318
|
-
let div1;
|
4344
|
+
// (69:2) {#if enableCopy}
|
4345
|
+
function create_if_block$3(ctx) {
|
4346
|
+
let a;
|
4319
4347
|
let div0;
|
4320
4348
|
let rendertext;
|
4321
|
-
let
|
4349
|
+
let a_class_value;
|
4350
|
+
let t0;
|
4351
|
+
let div1;
|
4322
4352
|
let t1;
|
4353
|
+
let t2;
|
4354
|
+
let div2;
|
4355
|
+
let t3;
|
4323
4356
|
let current;
|
4324
4357
|
let mounted;
|
4325
4358
|
let dispose;
|
4326
4359
|
rendertext = new RenderText({ props: { text: /*text*/ ctx[0] } });
|
4327
|
-
let if_block = /*enableCopy*/ ctx[1] && create_if_block$3(ctx);
|
4328
4360
|
|
4329
4361
|
return {
|
4330
4362
|
c() {
|
4331
|
-
|
4332
|
-
link = element("link");
|
4333
|
-
t0 = space();
|
4334
|
-
div1 = element("div");
|
4363
|
+
a = element("a");
|
4335
4364
|
div0 = element("div");
|
4336
4365
|
create_component(rendertext.$$.fragment);
|
4337
|
-
|
4338
|
-
|
4366
|
+
t0 = space();
|
4367
|
+
div1 = element("div");
|
4368
|
+
t1 = text("コピーしました");
|
4369
|
+
t2 = space();
|
4370
|
+
div2 = element("div");
|
4371
|
+
t3 = text("コピーできませんでした");
|
4339
4372
|
this.h();
|
4340
4373
|
},
|
4341
4374
|
l(nodes) {
|
4342
|
-
|
4343
|
-
var
|
4344
|
-
|
4345
|
-
t0 = claim_space(div2_nodes);
|
4346
|
-
div1 = claim_element(div2_nodes, "DIV", { class: true, style: true });
|
4347
|
-
var div1_nodes = children(div1);
|
4348
|
-
div0 = claim_element(div1_nodes, "DIV", { class: true });
|
4375
|
+
a = claim_element(nodes, "A", { href: true, class: true, style: true });
|
4376
|
+
var a_nodes = children(a);
|
4377
|
+
div0 = claim_element(a_nodes, "DIV", { class: true });
|
4349
4378
|
var div0_nodes = children(div0);
|
4350
4379
|
claim_component(rendertext.$$.fragment, div0_nodes);
|
4351
4380
|
div0_nodes.forEach(detach);
|
4381
|
+
a_nodes.forEach(detach);
|
4382
|
+
t0 = claim_space(nodes);
|
4383
|
+
div1 = claim_element(nodes, "DIV", { class: true });
|
4384
|
+
var div1_nodes = children(div1);
|
4385
|
+
t1 = claim_text(div1_nodes, "コピーしました");
|
4352
4386
|
div1_nodes.forEach(detach);
|
4353
|
-
|
4354
|
-
|
4387
|
+
t2 = claim_space(nodes);
|
4388
|
+
div2 = claim_element(nodes, "DIV", { class: true });
|
4389
|
+
var div2_nodes = children(div2);
|
4390
|
+
t3 = claim_text(div2_nodes, "コピーできませんでした");
|
4355
4391
|
div2_nodes.forEach(detach);
|
4356
4392
|
this.h();
|
4357
4393
|
},
|
4358
4394
|
h() {
|
4359
|
-
attr(
|
4360
|
-
attr(
|
4361
|
-
attr(
|
4362
|
-
attr(
|
4363
|
-
attr(div1, "
|
4364
|
-
attr(div2, "class", "
|
4395
|
+
attr(div0, "class", "text-element-inner svelte-600oh0");
|
4396
|
+
attr(a, "href", '');
|
4397
|
+
attr(a, "class", a_class_value = "" + (null_to_empty(`text-element text-link-element text-direction-${/*textDirection*/ ctx[1]}`) + " svelte-600oh0"));
|
4398
|
+
attr(a, "style", /*style*/ ctx[5]);
|
4399
|
+
attr(div1, "class", "tooltip svelte-600oh0");
|
4400
|
+
attr(div2, "class", "tooltip tooltip-error svelte-600oh0");
|
4365
4401
|
},
|
4366
4402
|
m(target, anchor) {
|
4367
|
-
insert_hydration(target,
|
4368
|
-
append_hydration(
|
4369
|
-
append_hydration(div2, t0);
|
4370
|
-
append_hydration(div2, div1);
|
4371
|
-
append_hydration(div1, div0);
|
4403
|
+
insert_hydration(target, a, anchor);
|
4404
|
+
append_hydration(a, div0);
|
4372
4405
|
mount_component(rendertext, div0, null);
|
4373
|
-
|
4374
|
-
|
4406
|
+
insert_hydration(target, t0, anchor);
|
4407
|
+
insert_hydration(target, div1, anchor);
|
4408
|
+
append_hydration(div1, t1);
|
4409
|
+
/*div1_binding*/ ctx[10](div1);
|
4410
|
+
insert_hydration(target, t2, anchor);
|
4411
|
+
insert_hydration(target, div2, anchor);
|
4412
|
+
append_hydration(div2, t3);
|
4413
|
+
/*div2_binding*/ ctx[11](div2);
|
4375
4414
|
current = true;
|
4376
4415
|
|
4377
4416
|
if (!mounted) {
|
4378
|
-
dispose = listen(
|
4417
|
+
dispose = listen(a, "click", /*onCopy*/ ctx[6]);
|
4379
4418
|
mounted = true;
|
4380
4419
|
}
|
4381
4420
|
},
|
4382
|
-
p(ctx,
|
4383
|
-
if (!current || dirty & /*text*/ 1 && link_href_value !== (link_href_value = `https://fonts.googleapis.com/css2?${getGoogleFontsParam()}&display=swap&text=${/*text*/ ctx[0]}`)) {
|
4384
|
-
attr(link, "href", link_href_value);
|
4385
|
-
}
|
4386
|
-
|
4421
|
+
p(ctx, dirty) {
|
4387
4422
|
const rendertext_changes = {};
|
4388
4423
|
if (dirty & /*text*/ 1) rendertext_changes.text = /*text*/ ctx[0];
|
4389
4424
|
rendertext.$set(rendertext_changes);
|
4390
4425
|
|
4391
|
-
if (!current || dirty & /*textDirection*/
|
4392
|
-
attr(
|
4426
|
+
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"))) {
|
4427
|
+
attr(a, "class", a_class_value);
|
4393
4428
|
}
|
4394
4429
|
|
4395
4430
|
if (!current || dirty & /*style*/ 32) {
|
4396
|
-
attr(
|
4397
|
-
}
|
4398
|
-
|
4399
|
-
if (/*enableCopy*/ ctx[1]) {
|
4400
|
-
if (if_block) {
|
4401
|
-
if_block.p(ctx, dirty);
|
4402
|
-
} else {
|
4403
|
-
if_block = create_if_block$3(ctx);
|
4404
|
-
if_block.c();
|
4405
|
-
if_block.m(div2, null);
|
4406
|
-
}
|
4407
|
-
} else if (if_block) {
|
4408
|
-
if_block.d(1);
|
4409
|
-
if_block = null;
|
4431
|
+
attr(a, "style", /*style*/ ctx[5]);
|
4410
4432
|
}
|
4411
4433
|
},
|
4412
4434
|
i(local) {
|
@@ -4419,53 +4441,159 @@ function create_fragment$p(ctx) {
|
|
4419
4441
|
current = false;
|
4420
4442
|
},
|
4421
4443
|
d(detaching) {
|
4422
|
-
if (detaching) detach(
|
4444
|
+
if (detaching) detach(a);
|
4423
4445
|
destroy_component(rendertext);
|
4424
|
-
if (
|
4446
|
+
if (detaching) detach(t0);
|
4447
|
+
if (detaching) detach(div1);
|
4448
|
+
/*div1_binding*/ ctx[10](null);
|
4449
|
+
if (detaching) detach(t2);
|
4450
|
+
if (detaching) detach(div2);
|
4451
|
+
/*div2_binding*/ ctx[11](null);
|
4425
4452
|
mounted = false;
|
4426
4453
|
dispose();
|
4427
4454
|
}
|
4428
4455
|
};
|
4429
4456
|
}
|
4430
4457
|
|
4458
|
+
function create_fragment$p(ctx) {
|
4459
|
+
let div;
|
4460
|
+
let link;
|
4461
|
+
let link_href_value;
|
4462
|
+
let t;
|
4463
|
+
let current_block_type_index;
|
4464
|
+
let if_block;
|
4465
|
+
let current;
|
4466
|
+
const if_block_creators = [create_if_block$3, create_else_block$1];
|
4467
|
+
const if_blocks = [];
|
4468
|
+
|
4469
|
+
function select_block_type(ctx, dirty) {
|
4470
|
+
if (/*enableCopy*/ ctx[2]) return 0;
|
4471
|
+
return 1;
|
4472
|
+
}
|
4473
|
+
|
4474
|
+
current_block_type_index = select_block_type(ctx);
|
4475
|
+
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
|
4476
|
+
|
4477
|
+
return {
|
4478
|
+
c() {
|
4479
|
+
div = element("div");
|
4480
|
+
link = element("link");
|
4481
|
+
t = space();
|
4482
|
+
if_block.c();
|
4483
|
+
this.h();
|
4484
|
+
},
|
4485
|
+
l(nodes) {
|
4486
|
+
div = claim_element(nodes, "DIV", { class: true });
|
4487
|
+
var div_nodes = children(div);
|
4488
|
+
link = claim_element(div_nodes, "LINK", { href: true, rel: true });
|
4489
|
+
t = claim_space(div_nodes);
|
4490
|
+
if_block.l(div_nodes);
|
4491
|
+
div_nodes.forEach(detach);
|
4492
|
+
this.h();
|
4493
|
+
},
|
4494
|
+
h() {
|
4495
|
+
attr(link, "href", link_href_value = `https://fonts.googleapis.com/css2?${getGoogleFontsParam()}&display=swap&text=${/*text*/ ctx[0]}`);
|
4496
|
+
attr(link, "rel", "stylesheet");
|
4497
|
+
attr(div, "class", "text-element-wrapper svelte-600oh0");
|
4498
|
+
},
|
4499
|
+
m(target, anchor) {
|
4500
|
+
insert_hydration(target, div, anchor);
|
4501
|
+
append_hydration(div, link);
|
4502
|
+
append_hydration(div, t);
|
4503
|
+
if_blocks[current_block_type_index].m(div, null);
|
4504
|
+
current = true;
|
4505
|
+
},
|
4506
|
+
p(ctx, [dirty]) {
|
4507
|
+
if (!current || dirty & /*text*/ 1 && link_href_value !== (link_href_value = `https://fonts.googleapis.com/css2?${getGoogleFontsParam()}&display=swap&text=${/*text*/ ctx[0]}`)) {
|
4508
|
+
attr(link, "href", link_href_value);
|
4509
|
+
}
|
4510
|
+
|
4511
|
+
let previous_block_index = current_block_type_index;
|
4512
|
+
current_block_type_index = select_block_type(ctx);
|
4513
|
+
|
4514
|
+
if (current_block_type_index === previous_block_index) {
|
4515
|
+
if_blocks[current_block_type_index].p(ctx, dirty);
|
4516
|
+
} else {
|
4517
|
+
group_outros();
|
4518
|
+
|
4519
|
+
transition_out(if_blocks[previous_block_index], 1, 1, () => {
|
4520
|
+
if_blocks[previous_block_index] = null;
|
4521
|
+
});
|
4522
|
+
|
4523
|
+
check_outros();
|
4524
|
+
if_block = if_blocks[current_block_type_index];
|
4525
|
+
|
4526
|
+
if (!if_block) {
|
4527
|
+
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
|
4528
|
+
if_block.c();
|
4529
|
+
} else {
|
4530
|
+
if_block.p(ctx, dirty);
|
4531
|
+
}
|
4532
|
+
|
4533
|
+
transition_in(if_block, 1);
|
4534
|
+
if_block.m(div, null);
|
4535
|
+
}
|
4536
|
+
},
|
4537
|
+
i(local) {
|
4538
|
+
if (current) return;
|
4539
|
+
transition_in(if_block);
|
4540
|
+
current = true;
|
4541
|
+
},
|
4542
|
+
o(local) {
|
4543
|
+
transition_out(if_block);
|
4544
|
+
current = false;
|
4545
|
+
},
|
4546
|
+
d(detaching) {
|
4547
|
+
if (detaching) detach(div);
|
4548
|
+
if_blocks[current_block_type_index].d();
|
4549
|
+
}
|
4550
|
+
};
|
4551
|
+
}
|
4552
|
+
|
4431
4553
|
function instance$p($$self, $$props, $$invalidate) {
|
4432
4554
|
let style;
|
4433
4555
|
let { text = 'サンプルSample' } = $$props;
|
4556
|
+
let { _textStyle = 'font-size:12px; line-height: 1.5;' } = $$props;
|
4557
|
+
let { textDirection = 'horizontal' } = $$props;
|
4558
|
+
let { _style = '' } = $$props;
|
4434
4559
|
let { enableCopy = false } = $$props;
|
4560
|
+
let { eventName = '' } = $$props;
|
4561
|
+
let eventValue = undefined;
|
4435
4562
|
let tooltipEl;
|
4436
4563
|
let tooltipErrorEl;
|
4437
4564
|
|
4438
|
-
const
|
4439
|
-
|
4440
|
-
|
4441
|
-
|
4442
|
-
|
4443
|
-
|
4444
|
-
|
4445
|
-
|
4446
|
-
|
4447
|
-
|
4448
|
-
|
4449
|
-
|
4450
|
-
|
4451
|
-
},
|
4452
|
-
1000
|
4453
|
-
);
|
4565
|
+
const onCopy = async e => {
|
4566
|
+
e.preventDefault();
|
4567
|
+
|
4568
|
+
try {
|
4569
|
+
await navigator.clipboard.writeText(text);
|
4570
|
+
|
4571
|
+
if (eventName) {
|
4572
|
+
send_event(eventName, eventValue);
|
4573
|
+
}
|
4574
|
+
|
4575
|
+
tooltipEl.classList.add('show');
|
4576
|
+
} catch(err) {
|
4577
|
+
tooltipErrorEl.classList.add('show');
|
4454
4578
|
}
|
4455
|
-
};
|
4456
4579
|
|
4457
|
-
|
4458
|
-
|
4459
|
-
|
4580
|
+
setTimeout(
|
4581
|
+
() => {
|
4582
|
+
tooltipEl.classList.remove('show');
|
4583
|
+
tooltipErrorEl.classList.remove('show');
|
4584
|
+
},
|
4585
|
+
1000
|
4586
|
+
);
|
4587
|
+
};
|
4460
4588
|
|
4461
|
-
function
|
4589
|
+
function div1_binding($$value) {
|
4462
4590
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
4463
4591
|
tooltipEl = $$value;
|
4464
4592
|
$$invalidate(3, tooltipEl);
|
4465
4593
|
});
|
4466
4594
|
}
|
4467
4595
|
|
4468
|
-
function
|
4596
|
+
function div2_binding($$value) {
|
4469
4597
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
4470
4598
|
tooltipErrorEl = $$value;
|
4471
4599
|
$$invalidate(4, tooltipErrorEl);
|
@@ -4474,10 +4602,11 @@ function instance$p($$self, $$props, $$invalidate) {
|
|
4474
4602
|
|
4475
4603
|
$$self.$$set = $$props => {
|
4476
4604
|
if ('text' in $$props) $$invalidate(0, text = $$props.text);
|
4477
|
-
if ('enableCopy' in $$props) $$invalidate(1, enableCopy = $$props.enableCopy);
|
4478
4605
|
if ('_textStyle' in $$props) $$invalidate(7, _textStyle = $$props._textStyle);
|
4479
|
-
if ('textDirection' in $$props) $$invalidate(
|
4606
|
+
if ('textDirection' in $$props) $$invalidate(1, textDirection = $$props.textDirection);
|
4480
4607
|
if ('_style' in $$props) $$invalidate(8, _style = $$props._style);
|
4608
|
+
if ('enableCopy' in $$props) $$invalidate(2, enableCopy = $$props.enableCopy);
|
4609
|
+
if ('eventName' in $$props) $$invalidate(9, eventName = $$props.eventName);
|
4481
4610
|
};
|
4482
4611
|
|
4483
4612
|
$$self.$$.update = () => {
|
@@ -4488,16 +4617,17 @@ function instance$p($$self, $$props, $$invalidate) {
|
|
4488
4617
|
|
4489
4618
|
return [
|
4490
4619
|
text,
|
4491
|
-
enableCopy,
|
4492
4620
|
textDirection,
|
4621
|
+
enableCopy,
|
4493
4622
|
tooltipEl,
|
4494
4623
|
tooltipErrorEl,
|
4495
4624
|
style,
|
4496
|
-
|
4625
|
+
onCopy,
|
4497
4626
|
_textStyle,
|
4498
4627
|
_style,
|
4499
|
-
|
4500
|
-
div1_binding
|
4628
|
+
eventName,
|
4629
|
+
div1_binding,
|
4630
|
+
div2_binding
|
4501
4631
|
];
|
4502
4632
|
}
|
4503
4633
|
|
@@ -4513,10 +4643,11 @@ class TextElement extends SvelteComponent {
|
|
4513
4643
|
safe_not_equal,
|
4514
4644
|
{
|
4515
4645
|
text: 0,
|
4516
|
-
enableCopy: 1,
|
4517
4646
|
_textStyle: 7,
|
4518
|
-
textDirection:
|
4519
|
-
_style: 8
|
4647
|
+
textDirection: 1,
|
4648
|
+
_style: 8,
|
4649
|
+
enableCopy: 2,
|
4650
|
+
eventName: 9
|
4520
4651
|
},
|
4521
4652
|
add_css$o
|
4522
4653
|
);
|