@crossed/demo
Version:
A universal & performant styling library for React Native, Next.js & React
127 lines (126 loc) • 5.92 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var pressable_exports = {};
__export(pressable_exports, {
CreateListPressableDemo: () => CreateListPressableDemo
});
module.exports = __toCommonJS(pressable_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_primitive = require("@crossed/primitive");
var import_styled = require("@crossed/styled");
var import_ui = require("@crossed/ui");
var import_react = require("react");
var import_react_native = require("react-native");
const Root = (0, import_styled.styled)(import_react_native.Pressable, {
"className": ["flex flex-col", "px-3 py-1.5"],
":hover": { className: ["bg-neutral-800 cursor-pointer"] },
":focus": { className: ["z-10"] },
":disabled": { className: ["bg-neutral-800 opacity-30 cursor-not-allowed"] },
":active": { className: ["bg-neutral-700"] },
"variants": {
grouped: { true: { className: ["rounded-none"] } },
first: { true: { className: ["rounded-l"] } },
last: { true: { className: ["rounded-r"] } },
orientation: { horizontal: { className: [] }, vertical: { className: [] } }
},
"compoundVariants": [
{
orientation: "vertical",
first: true,
className: ["rounded-b-none rounded-t"]
},
{
orientation: "vertical",
last: true,
className: ["rounded-t-none rounded-b"]
}
]
});
const Button = (0, import_primitive.createButton)({
Text: (0, import_styled.styled)(import_react_native.Text, { className: ["text-white", "text-base"] }),
Element: (0, import_styled.styled)(import_react_native.View, { className: ["flex"] }),
Group: (0, import_styled.styled)(import_react_native.View, {
className: ["flex", "border border-neutral-800 rounded-lg"],
defaultVariants: { orientation: "vertical" },
variants: {
orientation: {
horizontal: { className: ["flex-row"] },
vertical: { className: ["flex-col"] }
}
}
}),
Root: (0, import_react.forwardRef)((props, ref) => {
const { grouped, orientation } = (0, import_primitive.useButtonGroupContext)();
const getItems = (0, import_primitive.useButtonGroupCollection)();
const index = getItems().findIndex(({ id }) => id === props.id);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
Root,
{
grouped,
first: index === 0,
last: index === getItems().length - 1,
orientation,
...props,
ref
}
);
})
});
const List = (0, import_primitive.createList)({
Root: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button.Group, { ...props, orientation: props.orientation ?? "vertical" }),
Item: Button,
SubTitle: (0, import_styled.styled)(import_react_native.Text, { className: ["text-neutral-500 text-sm"] }),
Title: Button.Text,
Divider: (0, import_styled.styled)(import_react_native.View, { className: ["border-t border-neutral-800"] }),
Label: (0, import_styled.styled)(import_react_native.Text, {
className: ["text-neutral-500 text-base font-bold", "px-3 py-1.5"],
variants: { danger: { true: { className: ["text-red-800"] } } }
})
});
const CreateListPressableDemo = () => {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.YBox, { space: "md", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(List, { children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(List.Item, { children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List.Title, { children: "Number 1" }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List.SubTitle, { children: "Description Number 1" })
] }),
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(List.Item, { children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List.Title, { children: "Number 2" }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List.SubTitle, { children: "Description 2" })
] }),
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(List.Item, { disabled: true, children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List.Title, { children: "Number 3" }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List.SubTitle, { children: "Number 3 have description" })
] }),
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(List.Item, { hoverTheme: false, activeTheme: false, focusable: false, children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List.Title, { children: "Number 4" }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List.SubTitle, { children: "Number 4 have description" })
] }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List.Divider, {}),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List.Label, { danger: true, children: "Danger zone" }),
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(List.Item, { hoverTheme: false, activeTheme: false, focusable: false, children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List.Title, { children: "Number 5" }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(List.SubTitle, { children: "Number 5 have description" })
] })
] }) });
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
CreateListPressableDemo
});
//# sourceMappingURL=pressable.js.map