@idds/react 1.2.9 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js
CHANGED
|
@@ -6119,18 +6119,67 @@ const ConfirmationContext = createContext({
|
|
|
6119
6119
|
confirm: () => Promise.resolve(false)
|
|
6120
6120
|
});
|
|
6121
6121
|
const useConfirmation = () => useContext(ConfirmationContext);
|
|
6122
|
+
const defaultFooterActions = (cancelClassName, confirmClassName, cancelText, confirmText) => {
|
|
6123
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
6124
|
+
/* @__PURE__ */ jsx(Button, { hierarchy: "custom", size: "sm", className: cancelClassName, children: cancelText }),
|
|
6125
|
+
/* @__PURE__ */ jsx(Button, { hierarchy: "custom", size: "sm", className: confirmClassName, children: confirmText })
|
|
6126
|
+
] });
|
|
6127
|
+
};
|
|
6122
6128
|
const ConfirmationProvider = ({
|
|
6123
6129
|
children
|
|
6124
6130
|
}) => {
|
|
6125
|
-
const [options, setOptions] = useState(
|
|
6131
|
+
const [options, setOptions] = useState({
|
|
6132
|
+
title: "Confirmation",
|
|
6133
|
+
message: "Are you sure you want to confirm?",
|
|
6134
|
+
confirmText: "Yes",
|
|
6135
|
+
cancelText: "No",
|
|
6136
|
+
cancelClassName: "bg-background-primary border border-content-primary text-content-primary hover:bg-background-secondary",
|
|
6137
|
+
confirmClassName: "bg-primary-primary text-white hover:bg-primary-primary/90",
|
|
6138
|
+
footerActions: defaultFooterActions(
|
|
6139
|
+
"bg-background-primary border border-content-primary text-content-primary hover:bg-background-secondary",
|
|
6140
|
+
"bg-primary-primary text-white hover:bg-primary-primary/90",
|
|
6141
|
+
"Yes",
|
|
6142
|
+
"No"
|
|
6143
|
+
)
|
|
6144
|
+
});
|
|
6126
6145
|
const [pendingPromise, setPendingPromise] = useState(null);
|
|
6146
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
6147
|
+
/* @__PURE__ */ jsx(
|
|
6148
|
+
Button,
|
|
6149
|
+
{
|
|
6150
|
+
hierarchy: "custom",
|
|
6151
|
+
size: "sm",
|
|
6152
|
+
className: options == null ? void 0 : options.cancelClassName,
|
|
6153
|
+
onClick: () => handleClose(false),
|
|
6154
|
+
children: options == null ? void 0 : options.cancelText
|
|
6155
|
+
}
|
|
6156
|
+
),
|
|
6157
|
+
/* @__PURE__ */ jsx(
|
|
6158
|
+
Button,
|
|
6159
|
+
{
|
|
6160
|
+
hierarchy: "custom",
|
|
6161
|
+
size: "sm",
|
|
6162
|
+
className: (options == null ? void 0 : options.confirmClassName) ?? "bg-primary-primary text-white hover:bg-primary-primary/90",
|
|
6163
|
+
onClick: () => handleClose(true),
|
|
6164
|
+
children: options == null ? void 0 : options.confirmText
|
|
6165
|
+
}
|
|
6166
|
+
)
|
|
6167
|
+
] });
|
|
6127
6168
|
const confirm = (opts) => {
|
|
6128
6169
|
return new Promise((resolve) => {
|
|
6129
6170
|
setOptions({
|
|
6130
6171
|
title: opts.title ?? "Confirmation",
|
|
6131
6172
|
message: opts.message,
|
|
6132
6173
|
confirmText: opts.confirmText ?? "Ya",
|
|
6133
|
-
cancelText: opts.cancelText ?? "Batal"
|
|
6174
|
+
cancelText: opts.cancelText ?? "Batal",
|
|
6175
|
+
cancelClassName: opts.cancelClassName ?? "bg-background-primary border border-content-primary text-content-primary hover:bg-background-secondary",
|
|
6176
|
+
confirmClassName: opts.confirmClassName ?? "bg-primary-primary text-white hover:bg-primary-primary/90",
|
|
6177
|
+
footerActions: opts.footerActions ?? defaultFooterActions(
|
|
6178
|
+
opts.cancelClassName ?? "bg-background-primary border border-content-primary text-content-primary hover:bg-background-secondary",
|
|
6179
|
+
opts.confirmClassName ?? "bg-primary-primary text-white hover:bg-primary-primary/90",
|
|
6180
|
+
opts.cancelText ?? "Yes",
|
|
6181
|
+
opts.confirmText ?? "No"
|
|
6182
|
+
)
|
|
6134
6183
|
});
|
|
6135
6184
|
setPendingPromise({ resolve });
|
|
6136
6185
|
});
|
|
@@ -6151,10 +6200,7 @@ const ConfirmationProvider = ({
|
|
|
6151
6200
|
title: options.title,
|
|
6152
6201
|
children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
6153
6202
|
/* @__PURE__ */ jsx("div", { children: options.message }),
|
|
6154
|
-
|
|
6155
|
-
/* @__PURE__ */ jsx(Button, { hierarchy: "custom", onClick: () => handleClose(false), children: options.cancelText }),
|
|
6156
|
-
/* @__PURE__ */ jsx(Button, { hierarchy: "custom", onClick: () => handleClose(true), children: options.confirmText })
|
|
6157
|
-
] })
|
|
6203
|
+
options == null ? void 0 : options.footerActions
|
|
6158
6204
|
] })
|
|
6159
6205
|
}
|
|
6160
6206
|
)
|