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

149 lines (143 loc) 5.48 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/switch/index.ts var switch_exports = {}; __export(switch_exports, { Switch: () => namespace_exports, SwitchContext: () => SwitchContext, SwitchControl: () => SwitchControl, SwitchHiddenInput: () => SwitchHiddenInput, SwitchLabel: () => SwitchLabel, SwitchRoot: () => SwitchRoot, SwitchRootProvider: () => SwitchRootProvider, SwitchThumb: () => SwitchThumb }); module.exports = __toCommonJS(switch_exports); // src/components/switch/switch.tsx var import_switch = require("@ark-ui/react/switch"); var import_recipes = require("@fidely-ui/styled-system/recipes"); // 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 withSlotRootProvider(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 withSlotProvider2(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, withSlotProvider: withSlotProvider2, withSlotContext: withSlotContext2 }; } // src/components/switch/switch.tsx var { withSlotProvider, withSlotContext } = makeStyleContext(import_recipes.switchRecipe); var SwitchRootProvider = withSlotProvider(import_switch.Switch.RootProvider, "root"); var SwitchRoot = withSlotProvider( import_switch.Switch.Root, "root" ); var SwitchControl = withSlotContext(import_switch.Switch.Control, "control"); var SwitchThumb = withSlotContext( import_switch.Switch.Thumb, "thumb" ); var SwitchLabel = withSlotContext( import_switch.Switch.Label, "label" ); var SwitchContext = import_switch.Switch.Context; var SwitchHiddenInput = import_switch.Switch.HiddenInput; // src/components/switch/namespace.ts var namespace_exports = {}; __export(namespace_exports, { Context: () => SwitchContext, Control: () => SwitchControl, HiddenInput: () => SwitchHiddenInput, Label: () => SwitchLabel, Root: () => SwitchRoot, RootProvider: () => SwitchRootProvider, Thumb: () => SwitchThumb }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Switch, SwitchContext, SwitchControl, SwitchHiddenInput, SwitchLabel, SwitchRoot, SwitchRootProvider, SwitchThumb });