UNPKG

@fidely-ui/react

Version:

Fidely UI is a modern, beautifully crafted React design system powered by Ark UI and Panda CSS, delivering accessible and themeable components for building exceptional web apps

201 lines (194 loc) 7.42 kB
'use client' "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; 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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/components/dialog/index.ts var dialog_exports = {}; __export(dialog_exports, { Dialog: () => namespace_exports, DialogBackdrop: () => DialogBackdrop, DialogBody: () => DialogBody, DialogCloseAction: () => DialogCloseAction, DialogCloseTrigger: () => DialogCloseTrigger, DialogContent: () => DialogContent, DialogContext: () => DialogContext, DialogDescription: () => DialogDescription, DialogFooter: () => DialogFooter, DialogHeader: () => DialogHeader, DialogPositioner: () => DialogPositioner, DialogRoot: () => DialogRoot, DialogRootProvider: () => DialogRootProvider, DialogTitle: () => DialogTitle, DialogTrigger: () => DialogTrigger, useDialog: () => import_dialog4.useDialog, useDialogContext: () => import_dialog4.useDialogContext }); module.exports = __toCommonJS(dialog_exports); // src/components/dialog/dialog.tsx var import_factory = require("@ark-ui/react/factory"); var import_dialog = require("@ark-ui/react/dialog"); var import_recipes = require("@fidely-ui/styled-system/recipes"); var import_jsx2 = require("@fidely-ui/styled-system/jsx"); // src/system/make-style-context.tsx var React = __toESM(require("react"), 1); var import_jsx = require("@fidely-ui/styled-system/jsx"); var import_css = require("@fidely-ui/styled-system/css"); var import_jsx_runtime = require("react/jsx-runtime"); var canForward = (prop, variantKeys, opts = {}) => opts.forwardProps?.includes(prop) || !variantKeys.includes(prop) && !(0, import_jsx.isCssProperty)(prop); function makeStyleContext(recipe) { const Ctx = React.createContext(null); function withSlotRootProvider2(Component) { const Comp = (props) => { const [variantProps, rest] = recipe.splitVariantProps(props); const slots = recipe(variantProps); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Ctx.Provider, { value: slots, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ...rest }) }); }; Comp.displayName = "FidelyRoot"; return Comp; } function withSlotProvider(Component, slot, opts) { const Styled = (0, import_jsx.styled)( Component, {}, { shouldForwardProp: (prop, variantKeys) => canForward(prop, variantKeys, opts) } ); const Comp = React.forwardRef((props, ref) => { const [variantProps, rest] = recipe.splitVariantProps(props); const slots = recipe(variantProps); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Ctx.Provider, { value: slots, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( Styled, { ...rest, ref, className: (0, import_css.cx)(slots?.[slot], props.className) } ) }); }); Comp.displayName = `FidelySlotProvider(${String(slot)})`; return Comp; } function withSlotContext2(Component, slot) { const Styled = (0, import_jsx.styled)(Component); const Comp = React.forwardRef((props, ref) => { const slots = React.useContext(Ctx); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( Styled, { ...props, ref, className: (0, import_css.cx)(slots?.[slot], props.className) } ); }); Comp.displayName = `FidelySlotConsumer(${String(slot)})`; return Comp; } return { withSlotRootProvider: withSlotRootProvider2, withSlotProvider, withSlotContext: withSlotContext2 }; } // src/components/dialog/dialog.tsx var import_react = require("react"); var import_jsx_runtime2 = require("react/jsx-runtime"); var { withSlotRootProvider, withSlotContext } = makeStyleContext(import_recipes.dialog); var DialogRootProvider = withSlotRootProvider( import_dialog.Dialog.RootProvider ); var DialogRoot = withSlotRootProvider(import_dialog.Dialog.Root); var DialogContent = withSlotContext(import_dialog.Dialog.Content, "content"); var DialogDescription = withSlotContext(import_dialog.Dialog.Description, "description"); var DialogTitle = withSlotContext(import_dialog.Dialog.Title, "title"); var DialogCloseTrigger = withSlotContext(import_dialog.Dialog.CloseTrigger, "closeTrigger"); var DialogTrigger = withSlotContext(import_dialog.Dialog.Trigger, "trigger"); var StyledCloseAction = (0, import_jsx2.styled)(import_factory.ark.button); var DialogCloseAction = (0, import_react.forwardRef)(function DialogCloseAction2(props, ref) { const dialog2 = (0, import_dialog.useDialogContext)(); return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( StyledCloseAction, { ...props, ref, onClick: () => dialog2.setOpen(false) } ); }); var DialogPositioner = withSlotContext(import_dialog.Dialog.Positioner, "positioner"); var DialogBackdrop = withSlotContext(import_dialog.Dialog.Backdrop, "backdrop"); var DialogBody = withSlotContext( "div", "body" ); var DialogHeader = withSlotContext( "div", "header" ); var DialogFooter = withSlotContext( "div", "footer" ); var DialogContext = import_dialog.Dialog.Context; // src/components/dialog/index.ts var import_dialog4 = require("@ark-ui/react/dialog"); // src/components/dialog/namespace.ts var namespace_exports = {}; __export(namespace_exports, { Backdrop: () => DialogBackdrop, Body: () => DialogBody, CloseAction: () => DialogCloseAction, CloseTrigger: () => DialogCloseTrigger, Content: () => DialogContent, Context: () => DialogContext, Description: () => DialogDescription, Footer: () => DialogFooter, Header: () => DialogHeader, Positioner: () => DialogPositioner, Root: () => DialogRoot, RootProvider: () => DialogRootProvider, Title: () => DialogTitle, Trigger: () => DialogTrigger }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Dialog, DialogBackdrop, DialogBody, DialogCloseAction, DialogCloseTrigger, DialogContent, DialogContext, DialogDescription, DialogFooter, DialogHeader, DialogPositioner, DialogRoot, DialogRootProvider, DialogTitle, DialogTrigger, useDialog, useDialogContext });