@idds/js 1.0.75 → 1.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.iife.js +71 -45
- package/dist/index.js +71 -45
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -2698,72 +2698,98 @@ var InaUI = (() => {
|
|
|
2698
2698
|
}
|
|
2699
2699
|
|
|
2700
2700
|
// src/js/components/stateless/toast.js
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
duration = optionsOrMessage.duration || 3e3;
|
|
2709
|
-
position = optionsOrMessage.position || "top-right";
|
|
2710
|
-
actionHtml = optionsOrMessage.actionHtml || "";
|
|
2711
|
-
} else {
|
|
2712
|
-
message = optionsOrMessage;
|
|
2713
|
-
state = variant;
|
|
2714
|
-
style = "solid";
|
|
2715
|
-
position = "top-right";
|
|
2716
|
-
actionHtml = "";
|
|
2717
|
-
}
|
|
2718
|
-
let containerId = `ina-toast-container-${position}`;
|
|
2701
|
+
var ICONS3 = {
|
|
2702
|
+
default: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>`,
|
|
2703
|
+
destructive: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>`,
|
|
2704
|
+
positive: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>`
|
|
2705
|
+
};
|
|
2706
|
+
function getOrCreateContainer(position) {
|
|
2707
|
+
const containerId = `ina-toast-container-${position}`;
|
|
2719
2708
|
let container = document.getElementById(containerId);
|
|
2720
2709
|
if (!container) {
|
|
2721
2710
|
container = document.createElement("div");
|
|
2722
2711
|
container.id = containerId;
|
|
2723
2712
|
container.className = `ina-toast-container ina-toast-container--${position}`;
|
|
2713
|
+
container.style.maxHeight = "calc(100vh - 32px)";
|
|
2714
|
+
container.style.overflow = "auto";
|
|
2724
2715
|
document.body.appendChild(container);
|
|
2725
2716
|
}
|
|
2717
|
+
return container;
|
|
2718
|
+
}
|
|
2719
|
+
function createToastElement({ title, message, state, style, actionHtml }) {
|
|
2726
2720
|
const toastItem = document.createElement("div");
|
|
2727
2721
|
toastItem.className = "ina-toast-item";
|
|
2728
2722
|
const toast = document.createElement("div");
|
|
2729
|
-
toast.className = `ina-toast ina-toast--state-${state} ina-toast--style-${style} ina-toast--
|
|
2730
|
-
const
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
${actionHtml ? `<div class="ina-toast__action-area">${actionHtml}</div>` : ""}
|
|
2744
|
-
</div>
|
|
2745
|
-
<button class="ina-toast__close-button">
|
|
2746
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="ina-toast__close-icon"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
2747
|
-
</button>
|
|
2723
|
+
toast.className = `ina-toast ina-toast--state-${state} ina-toast--style-${style} ina-toast--hidden`;
|
|
2724
|
+
const iconHtml = ICONS3[state] || ICONS3.default;
|
|
2725
|
+
const contentHtml = `
|
|
2726
|
+
<div class="ina-toast__icon">${iconHtml}</div>
|
|
2727
|
+
<div class="ina-toast__content">
|
|
2728
|
+
<div class="ina-toast__text-area">
|
|
2729
|
+
<p class="ina-toast__title">${title || message || ""}</p>
|
|
2730
|
+
${title && message ? `<p class="ina-toast__description">${message}</p>` : ""}
|
|
2731
|
+
</div>
|
|
2732
|
+
${actionHtml ? `<div class="ina-toast__action-area">${actionHtml}</div>` : ""}
|
|
2733
|
+
</div>
|
|
2734
|
+
<button class="ina-toast__close-button" aria-label="Tutup notifikasi">
|
|
2735
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="ina-toast__close-icon"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
2736
|
+
</button>
|
|
2748
2737
|
`;
|
|
2749
2738
|
toast.innerHTML = contentHtml;
|
|
2750
2739
|
toastItem.appendChild(toast);
|
|
2751
|
-
|
|
2740
|
+
return { toastItem, toast };
|
|
2741
|
+
}
|
|
2742
|
+
function showToast(optionsOrMessage, variant = "default", duration = 5e3) {
|
|
2743
|
+
const options = typeof optionsOrMessage === "string" ? {
|
|
2744
|
+
message: optionsOrMessage,
|
|
2745
|
+
state: variant,
|
|
2746
|
+
duration
|
|
2747
|
+
} : optionsOrMessage || {};
|
|
2748
|
+
const {
|
|
2749
|
+
message = "",
|
|
2750
|
+
title = "",
|
|
2751
|
+
state = "default",
|
|
2752
|
+
style = "solid",
|
|
2753
|
+
duration: autoCloseDuration = 5e3,
|
|
2754
|
+
position = "top-right",
|
|
2755
|
+
actionHtml = ""
|
|
2756
|
+
} = options;
|
|
2757
|
+
const container = getOrCreateContainer(position);
|
|
2758
|
+
const { toastItem, toast } = createToastElement({
|
|
2759
|
+
title,
|
|
2760
|
+
message,
|
|
2761
|
+
state,
|
|
2762
|
+
style,
|
|
2763
|
+
actionHtml
|
|
2764
|
+
});
|
|
2765
|
+
container.appendChild(toastItem);
|
|
2766
|
+
requestAnimationFrame(() => {
|
|
2767
|
+
toast.offsetHeight;
|
|
2768
|
+
toast.classList.remove("ina-toast--hidden");
|
|
2769
|
+
toast.classList.add("ina-toast--visible");
|
|
2770
|
+
});
|
|
2752
2771
|
const close = () => {
|
|
2753
2772
|
toast.classList.remove("ina-toast--visible");
|
|
2754
2773
|
toast.classList.add("ina-toast--hidden");
|
|
2755
2774
|
setTimeout(() => {
|
|
2756
|
-
if (toastItem.parentNode)
|
|
2757
|
-
|
|
2758
|
-
|
|
2775
|
+
if (toastItem.parentNode === container) {
|
|
2776
|
+
container.removeChild(toastItem);
|
|
2777
|
+
}
|
|
2778
|
+
if (container.children.length === 0 && container.parentNode) {
|
|
2779
|
+
container.parentNode.removeChild(container);
|
|
2759
2780
|
}
|
|
2760
2781
|
}, 300);
|
|
2761
2782
|
};
|
|
2762
|
-
closeBtn.
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2783
|
+
const closeBtn = toast.querySelector(".ina-toast__close-button");
|
|
2784
|
+
if (closeBtn) {
|
|
2785
|
+
closeBtn.addEventListener("click", close);
|
|
2786
|
+
}
|
|
2787
|
+
if (autoCloseDuration > 0) {
|
|
2788
|
+
setTimeout(close, autoCloseDuration);
|
|
2766
2789
|
}
|
|
2790
|
+
return {
|
|
2791
|
+
close
|
|
2792
|
+
};
|
|
2767
2793
|
}
|
|
2768
2794
|
|
|
2769
2795
|
// src/js/utils/theme.js
|
package/dist/index.js
CHANGED
|
@@ -2857,72 +2857,98 @@ function initTabHorizontal() {
|
|
|
2857
2857
|
}
|
|
2858
2858
|
|
|
2859
2859
|
// src/js/components/stateless/toast.js
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
duration = optionsOrMessage.duration || 3e3;
|
|
2868
|
-
position = optionsOrMessage.position || "top-right";
|
|
2869
|
-
actionHtml = optionsOrMessage.actionHtml || "";
|
|
2870
|
-
} else {
|
|
2871
|
-
message = optionsOrMessage;
|
|
2872
|
-
state = variant;
|
|
2873
|
-
style = "solid";
|
|
2874
|
-
position = "top-right";
|
|
2875
|
-
actionHtml = "";
|
|
2876
|
-
}
|
|
2877
|
-
let containerId = `ina-toast-container-${position}`;
|
|
2860
|
+
var ICONS3 = {
|
|
2861
|
+
default: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>`,
|
|
2862
|
+
destructive: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>`,
|
|
2863
|
+
positive: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>`
|
|
2864
|
+
};
|
|
2865
|
+
function getOrCreateContainer(position) {
|
|
2866
|
+
const containerId = `ina-toast-container-${position}`;
|
|
2878
2867
|
let container = document.getElementById(containerId);
|
|
2879
2868
|
if (!container) {
|
|
2880
2869
|
container = document.createElement("div");
|
|
2881
2870
|
container.id = containerId;
|
|
2882
2871
|
container.className = `ina-toast-container ina-toast-container--${position}`;
|
|
2872
|
+
container.style.maxHeight = "calc(100vh - 32px)";
|
|
2873
|
+
container.style.overflow = "auto";
|
|
2883
2874
|
document.body.appendChild(container);
|
|
2884
2875
|
}
|
|
2876
|
+
return container;
|
|
2877
|
+
}
|
|
2878
|
+
function createToastElement({ title, message, state, style, actionHtml }) {
|
|
2885
2879
|
const toastItem = document.createElement("div");
|
|
2886
2880
|
toastItem.className = "ina-toast-item";
|
|
2887
2881
|
const toast = document.createElement("div");
|
|
2888
|
-
toast.className = `ina-toast ina-toast--state-${state} ina-toast--style-${style} ina-toast--
|
|
2889
|
-
const
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
${actionHtml ? `<div class="ina-toast__action-area">${actionHtml}</div>` : ""}
|
|
2903
|
-
</div>
|
|
2904
|
-
<button class="ina-toast__close-button">
|
|
2905
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="ina-toast__close-icon"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
2906
|
-
</button>
|
|
2882
|
+
toast.className = `ina-toast ina-toast--state-${state} ina-toast--style-${style} ina-toast--hidden`;
|
|
2883
|
+
const iconHtml = ICONS3[state] || ICONS3.default;
|
|
2884
|
+
const contentHtml = `
|
|
2885
|
+
<div class="ina-toast__icon">${iconHtml}</div>
|
|
2886
|
+
<div class="ina-toast__content">
|
|
2887
|
+
<div class="ina-toast__text-area">
|
|
2888
|
+
<p class="ina-toast__title">${title || message || ""}</p>
|
|
2889
|
+
${title && message ? `<p class="ina-toast__description">${message}</p>` : ""}
|
|
2890
|
+
</div>
|
|
2891
|
+
${actionHtml ? `<div class="ina-toast__action-area">${actionHtml}</div>` : ""}
|
|
2892
|
+
</div>
|
|
2893
|
+
<button class="ina-toast__close-button" aria-label="Tutup notifikasi">
|
|
2894
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="ina-toast__close-icon"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
2895
|
+
</button>
|
|
2907
2896
|
`;
|
|
2908
2897
|
toast.innerHTML = contentHtml;
|
|
2909
2898
|
toastItem.appendChild(toast);
|
|
2910
|
-
|
|
2899
|
+
return { toastItem, toast };
|
|
2900
|
+
}
|
|
2901
|
+
function showToast(optionsOrMessage, variant = "default", duration = 5e3) {
|
|
2902
|
+
const options = typeof optionsOrMessage === "string" ? {
|
|
2903
|
+
message: optionsOrMessage,
|
|
2904
|
+
state: variant,
|
|
2905
|
+
duration
|
|
2906
|
+
} : optionsOrMessage || {};
|
|
2907
|
+
const {
|
|
2908
|
+
message = "",
|
|
2909
|
+
title = "",
|
|
2910
|
+
state = "default",
|
|
2911
|
+
style = "solid",
|
|
2912
|
+
duration: autoCloseDuration = 5e3,
|
|
2913
|
+
position = "top-right",
|
|
2914
|
+
actionHtml = ""
|
|
2915
|
+
} = options;
|
|
2916
|
+
const container = getOrCreateContainer(position);
|
|
2917
|
+
const { toastItem, toast } = createToastElement({
|
|
2918
|
+
title,
|
|
2919
|
+
message,
|
|
2920
|
+
state,
|
|
2921
|
+
style,
|
|
2922
|
+
actionHtml
|
|
2923
|
+
});
|
|
2924
|
+
container.appendChild(toastItem);
|
|
2925
|
+
requestAnimationFrame(() => {
|
|
2926
|
+
toast.offsetHeight;
|
|
2927
|
+
toast.classList.remove("ina-toast--hidden");
|
|
2928
|
+
toast.classList.add("ina-toast--visible");
|
|
2929
|
+
});
|
|
2911
2930
|
const close = () => {
|
|
2912
2931
|
toast.classList.remove("ina-toast--visible");
|
|
2913
2932
|
toast.classList.add("ina-toast--hidden");
|
|
2914
2933
|
setTimeout(() => {
|
|
2915
|
-
if (toastItem.parentNode)
|
|
2916
|
-
|
|
2917
|
-
|
|
2934
|
+
if (toastItem.parentNode === container) {
|
|
2935
|
+
container.removeChild(toastItem);
|
|
2936
|
+
}
|
|
2937
|
+
if (container.children.length === 0 && container.parentNode) {
|
|
2938
|
+
container.parentNode.removeChild(container);
|
|
2918
2939
|
}
|
|
2919
2940
|
}, 300);
|
|
2920
2941
|
};
|
|
2921
|
-
closeBtn.
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2942
|
+
const closeBtn = toast.querySelector(".ina-toast__close-button");
|
|
2943
|
+
if (closeBtn) {
|
|
2944
|
+
closeBtn.addEventListener("click", close);
|
|
2945
|
+
}
|
|
2946
|
+
if (autoCloseDuration > 0) {
|
|
2947
|
+
setTimeout(close, autoCloseDuration);
|
|
2925
2948
|
}
|
|
2949
|
+
return {
|
|
2950
|
+
close
|
|
2951
|
+
};
|
|
2926
2952
|
}
|
|
2927
2953
|
|
|
2928
2954
|
// src/js/utils/theme.js
|