@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
231 lines (221 loc) • 8.59 kB
JavaScript
'use client'
;
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/clipboard/index.ts
var clipboard_exports = {};
__export(clipboard_exports, {
Clipboard: () => namespace_exports,
ClipboardContext: () => ClipboardContext,
ClipboardControl: () => ClipboardControl,
ClipboardIndicator: () => ClipboardIndicator,
ClipboardInput: () => ClipboardInput,
ClipboardLabel: () => ClipboardLabel,
ClipboardRoot: () => ClipboardRoot,
ClipboardRootProvider: () => ClipboardRootProvider,
ClipboardStatus: () => ClipboardStatus,
ClipboardTrigger: () => ClipboardTrigger,
useClipboard: () => import_clipboard4.useClipboard,
useClipboardContext: () => import_clipboard4.useClipboardContext
});
module.exports = __toCommonJS(clipboard_exports);
// src/components/clipboard/clipboard.tsx
var React3 = __toESM(require("react"), 1);
var import_clipboard = require("@ark-ui/react/clipboard");
var import_recipes = require("@fidely-ui/styled-system/recipes");
// src/components/icons/create-icon.tsx
var React = __toESM(require("react"), 1);
var import_factory = require("@ark-ui/react/factory");
var import_jsx_runtime = require("react/jsx-runtime");
function createIcon(path) {
return React.forwardRef(function Icon(props, ref) {
const { size = 20, ...rest } = props;
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_factory.ark.svg,
{
ref,
width: size,
height: size,
viewBox: "0 0 24 24",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...rest,
children: path
}
);
});
}
// src/components/icons/FiCheck.tsx
var import_jsx_runtime2 = require("react/jsx-runtime");
var FiCheck = createIcon(
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M20.29 5.71a1 1 0 0 0-1.41 0L9 15.59l-3.88-3.88a1 1 0 0 0-1.41 1.41l4.59 4.59a1 1 0 0 0 1.41 0L20.29 7.12a1 1 0 0 0 0-1.41z" })
);
// src/components/icons/FiCopy.tsx
var import_jsx_runtime3 = require("react/jsx-runtime");
var FiCopy = createIcon(
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
"rect",
{
x: "9",
y: "9",
width: "13",
height: "13",
rx: "2",
ry: "2",
stroke: "currentColor",
strokeWidth: "2",
fill: "none"
}
),
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
"rect",
{
x: "3",
y: "3",
width: "13",
height: "13",
rx: "2",
ry: "2",
stroke: "currentColor",
strokeWidth: "2",
fill: "none"
}
)
] })
);
// src/system/make-style-context.tsx
var React2 = __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_runtime4 = 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 = React2.createContext(null);
function withSlotRootProvider(Component) {
const Comp = (props) => {
const [variantProps, rest] = recipe.splitVariantProps(props);
const slots = recipe(variantProps);
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Ctx.Provider, { value: slots, children: /* @__PURE__ */ (0, import_jsx_runtime4.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 = React2.forwardRef((props, ref) => {
const [variantProps, rest] = recipe.splitVariantProps(props);
const slots = recipe(variantProps);
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Ctx.Provider, { value: slots, children: /* @__PURE__ */ (0, import_jsx_runtime4.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 = React2.forwardRef((props, ref) => {
const slots = React2.useContext(Ctx);
return /* @__PURE__ */ (0, import_jsx_runtime4.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/clipboard/clipboard.tsx
var import_jsx_runtime5 = require("react/jsx-runtime");
var { withSlotProvider, withSlotContext } = makeStyleContext(import_recipes.clipboard);
var ClipboardRootProvider = withSlotProvider(import_clipboard.Clipboard.RootProvider, "root");
var ClipboardRoot = withSlotProvider(import_clipboard.Clipboard.Root, "root");
var ClipboardControl = withSlotContext(import_clipboard.Clipboard.Control, "control");
var ClipboardTrigger = withSlotContext(import_clipboard.Clipboard.Trigger, "trigger");
var ClipboardIndicator = withSlotContext((props) => {
const {
copiedIcon = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FiCheck, {}),
idleIcon = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FiCopy, {}),
children,
...rest
} = props;
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_clipboard.Clipboard.Indicator, { ...rest, copied: props.copied ?? copiedIcon, children: children ?? idleIcon });
}, "indicator");
var ClipboardInput = withSlotContext(import_clipboard.Clipboard.Input, "input");
var ClipboardLabel = withSlotContext(import_clipboard.Clipboard.Label, "label");
var ClipboardContext = import_clipboard.Clipboard.Context;
var ClipboardStatus = React3.forwardRef(function ClipboardStatus2(props, ref) {
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ClipboardIndicator, { copied: "Copied", ref, ...props, children: "Copy" });
});
// src/components/clipboard/index.ts
var import_clipboard4 = require("@ark-ui/react/clipboard");
// src/components/clipboard/namespace.ts
var namespace_exports = {};
__export(namespace_exports, {
Context: () => ClipboardContext,
Control: () => ClipboardControl,
Indicator: () => ClipboardIndicator,
Input: () => ClipboardInput,
Label: () => ClipboardLabel,
Root: () => ClipboardRoot,
RootProvider: () => ClipboardRootProvider,
Status: () => ClipboardStatus,
Trigger: () => ClipboardTrigger
});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Clipboard,
ClipboardContext,
ClipboardControl,
ClipboardIndicator,
ClipboardInput,
ClipboardLabel,
ClipboardRoot,
ClipboardRootProvider,
ClipboardStatus,
ClipboardTrigger,
useClipboard,
useClipboardContext
});