@planetaexo/design-system 0.3.0 → 0.3.1
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.cjs +23 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +23 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -5
package/dist/index.d.cts
CHANGED
|
@@ -13,7 +13,12 @@ interface OfferOptionalItem {
|
|
|
13
13
|
label: string;
|
|
14
14
|
/** e.g. "R$150.00 per person" */
|
|
15
15
|
pricePerPerson: string;
|
|
16
|
+
/** Uncontrolled: estado inicial gerenciado internamente pelo DS. */
|
|
16
17
|
defaultChecked?: boolean;
|
|
18
|
+
/** Controlled: quando presente, o host app é dono do estado de seleção. */
|
|
19
|
+
checked?: boolean;
|
|
20
|
+
/** Controlled: chamado ao marcar/desmarcar. Ignorado se `checked` não for passado. */
|
|
21
|
+
onCheckedChange?: (id: string, checked: boolean) => void;
|
|
17
22
|
}
|
|
18
23
|
interface OfferAdventureItem {
|
|
19
24
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,12 @@ interface OfferOptionalItem {
|
|
|
13
13
|
label: string;
|
|
14
14
|
/** e.g. "R$150.00 per person" */
|
|
15
15
|
pricePerPerson: string;
|
|
16
|
+
/** Uncontrolled: estado inicial gerenciado internamente pelo DS. */
|
|
16
17
|
defaultChecked?: boolean;
|
|
18
|
+
/** Controlled: quando presente, o host app é dono do estado de seleção. */
|
|
19
|
+
checked?: boolean;
|
|
20
|
+
/** Controlled: chamado ao marcar/desmarcar. Ignorado se `checked` não for passado. */
|
|
21
|
+
onCheckedChange?: (id: string, checked: boolean) => void;
|
|
17
22
|
}
|
|
18
23
|
interface OfferAdventureItem {
|
|
19
24
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -1048,21 +1048,33 @@ function CountrySearchField({
|
|
|
1048
1048
|
] });
|
|
1049
1049
|
}
|
|
1050
1050
|
function AdventureCard({ adventure }) {
|
|
1051
|
-
var _a, _b, _c;
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1051
|
+
var _a, _b, _c, _d, _e;
|
|
1052
|
+
const isControlled = (_b = (_a = adventure.optionals) == null ? void 0 : _a.some((o) => o.onCheckedChange !== void 0)) != null ? _b : false;
|
|
1053
|
+
const [checkedInternal, setCheckedInternal] = React18.useState(
|
|
1054
|
+
new Set((_d = (_c = adventure.optionals) == null ? void 0 : _c.filter((o) => o.defaultChecked).map((o) => o.id)) != null ? _d : [])
|
|
1054
1055
|
);
|
|
1055
|
-
const
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1056
|
+
const isChecked = (opt) => {
|
|
1057
|
+
var _a2;
|
|
1058
|
+
return isControlled ? (_a2 = opt.checked) != null ? _a2 : false : checkedInternal.has(opt.id);
|
|
1059
|
+
};
|
|
1060
|
+
const toggleOptional = (opt) => {
|
|
1061
|
+
var _a2;
|
|
1062
|
+
if (isControlled) {
|
|
1063
|
+
(_a2 = opt.onCheckedChange) == null ? void 0 : _a2.call(opt, opt.id, !opt.checked);
|
|
1064
|
+
} else {
|
|
1065
|
+
setCheckedInternal((prev) => {
|
|
1066
|
+
const next = new Set(prev);
|
|
1067
|
+
next.has(opt.id) ? next.delete(opt.id) : next.add(opt.id);
|
|
1068
|
+
return next;
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
};
|
|
1060
1072
|
return /* @__PURE__ */ jsxs("div", { className: "rounded-2xl border border-border bg-card overflow-hidden", children: [
|
|
1061
1073
|
/* @__PURE__ */ jsx("div", { className: "aspect-[16/7] overflow-hidden bg-muted", children: /* @__PURE__ */ jsx(
|
|
1062
1074
|
"img",
|
|
1063
1075
|
{
|
|
1064
1076
|
src: adventure.image,
|
|
1065
|
-
alt: (
|
|
1077
|
+
alt: (_e = adventure.imageAlt) != null ? _e : adventure.title,
|
|
1066
1078
|
className: "w-full h-full object-cover"
|
|
1067
1079
|
}
|
|
1068
1080
|
) }),
|
|
@@ -1104,8 +1116,8 @@ function AdventureCard({ adventure }) {
|
|
|
1104
1116
|
"input",
|
|
1105
1117
|
{
|
|
1106
1118
|
type: "checkbox",
|
|
1107
|
-
checked:
|
|
1108
|
-
onChange: () => toggleOptional(opt
|
|
1119
|
+
checked: isChecked(opt),
|
|
1120
|
+
onChange: () => toggleOptional(opt),
|
|
1109
1121
|
className: "h-4 w-4 shrink-0 rounded border-border accent-primary cursor-pointer"
|
|
1110
1122
|
}
|
|
1111
1123
|
),
|