@bitrise/bitkit-v2 0.3.63 → 0.3.64

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.
@@ -0,0 +1,3 @@
1
+ import { BitkitToggleProps } from './BitkitToggle.types';
2
+ declare const BitkitToggle: import('react').ForwardRefExoticComponent<BitkitToggleProps & import('react').RefAttributes<HTMLInputElement>>;
3
+ export default BitkitToggle;
@@ -0,0 +1,80 @@
1
+ import { jsx as e, jsxs as c } from "react/jsx-runtime";
2
+ import { Box as f } from "@chakra-ui/react/box";
3
+ import { Skeleton as b } from "@chakra-ui/react/skeleton";
4
+ import { useSlotRecipe as y } from "@chakra-ui/react/styled-system";
5
+ import { Switch as i } from "@chakra-ui/react/switch";
6
+ import { forwardRef as g } from "react";
7
+ import T from "../../icons/16x16/IconCheck16.js";
8
+ import x from "../../icons/16x16/IconCross16.js";
9
+ import I from "../../icons/24x24/IconCheck24.js";
10
+ import B from "../../icons/24x24/IconCross24.js";
11
+ import C from "./components/BitkitToggleHelperText.js";
12
+ import R from "./components/BitkitToggleLabel.js";
13
+ import w from "./components/BitkitToggleReadOnly.js";
14
+ import j from "./components/BitkitToggleValueText.js";
15
+ const L = g(
16
+ (a, s) => {
17
+ const { label: l, optional: r, tooltip: m, helperText: d, valueText: n, size: t = "md", state: o = "default", ...k } = a, p = y({ key: "switch" })({ size: t }), h = t === "sm" ? x : B, D = t === "sm" ? T : I;
18
+ return /* @__PURE__ */ c(
19
+ i.Root,
20
+ {
21
+ gap: "4",
22
+ size: t,
23
+ required: !r,
24
+ flexDirection: "column",
25
+ alignItems: "flex-start",
26
+ readOnly: o === "readOnly",
27
+ disabled: o === "disabled" || o === "disabledInput" || o === "skeleton",
28
+ ...k,
29
+ children: [
30
+ /* @__PURE__ */ e(i.HiddenInput, { ref: s }),
31
+ /* @__PURE__ */ e(R, { label: l, state: o, tooltip: m, optional: r }),
32
+ /* @__PURE__ */ c(f, { css: p.root, children: [
33
+ /* @__PURE__ */ e(w, { state: o, children: /* @__PURE__ */ e(b, { loading: o === "skeleton", borderRadius: "12", height: t === "sm" ? "16" : "24", children: /* @__PURE__ */ c(i.Control, { children: [
34
+ /* @__PURE__ */ e(i.Thumb, {}),
35
+ /* @__PURE__ */ e(i.Indicator, { fallback: /* @__PURE__ */ e(h, {}), children: /* @__PURE__ */ e(D, {}) })
36
+ ] }) }) }),
37
+ /* @__PURE__ */ e(j, { size: t, state: o, valueText: n })
38
+ ] }),
39
+ /* @__PURE__ */ e(C, { state: o, helperText: d })
40
+ ]
41
+ }
42
+ );
43
+ }
44
+ );
45
+ L.displayName = "BitkitToggleDynamicLabel";
46
+ const O = g((a, s) => {
47
+ const { label: l, optional: r, tooltip: m, helperText: d, size: n = "sm", state: t = "default", ...o } = a, u = y({ key: "switch" })({ size: n }), p = n === "sm" ? x : B, h = n === "sm" ? T : I;
48
+ return /* @__PURE__ */ c(
49
+ i.Root,
50
+ {
51
+ size: n,
52
+ display: "flex",
53
+ required: !r,
54
+ justifyContent: "space-between",
55
+ readOnly: t === "readOnly",
56
+ disabled: t === "disabled" || t === "disabledInput" || t === "skeleton",
57
+ ...o,
58
+ children: [
59
+ /* @__PURE__ */ e(i.HiddenInput, { ref: s }),
60
+ (l || d) && /* @__PURE__ */ c(f, { display: "flex", flexDirection: "column", gap: "4", mr: "24", children: [
61
+ /* @__PURE__ */ e(R, { label: l, state: t, tooltip: m, optional: r }),
62
+ /* @__PURE__ */ e(C, { state: t, helperText: d })
63
+ ] }),
64
+ /* @__PURE__ */ e(f, { css: u.root, children: /* @__PURE__ */ e(w, { state: t, children: /* @__PURE__ */ e(b, { loading: t === "skeleton", borderRadius: "12", height: n === "sm" ? "16" : "24", children: /* @__PURE__ */ c(i.Control, { children: [
65
+ /* @__PURE__ */ e(i.Thumb, {}),
66
+ /* @__PURE__ */ e(i.Indicator, { fallback: /* @__PURE__ */ e(p, {}), children: /* @__PURE__ */ e(h, {}) })
67
+ ] }) }) }) })
68
+ ]
69
+ }
70
+ );
71
+ });
72
+ O.displayName = "BitkitToggleFixedLabel";
73
+ const v = g((a, s) => {
74
+ const { variant: l, ...r } = a;
75
+ return l === "dynamic-label" || l === void 0 ? /* @__PURE__ */ e(L, { ref: s, ...r }) : /* @__PURE__ */ e(O, { ref: s, ...r });
76
+ });
77
+ v.displayName = "BitkitToggle";
78
+ export {
79
+ v as default
80
+ };
@@ -0,0 +1,22 @@
1
+ import { SwitchRootProps } from '@chakra-ui/react/switch';
2
+ import { ReactNode } from 'react';
3
+ export type OnOff = {
4
+ on: ReactNode;
5
+ off: ReactNode;
6
+ };
7
+ export interface BitkitToggleDynamicLabelProps extends Omit<SwitchRootProps, 'disabled' | 'readOnly' | 'required'> {
8
+ variant?: 'dynamic-label';
9
+ tooltip?: string;
10
+ optional?: boolean;
11
+ valueText?: ReactNode | OnOff;
12
+ helperText?: ReactNode | OnOff;
13
+ state?: 'default' | 'disabled' | 'disabledInput' | 'readOnly' | 'skeleton';
14
+ }
15
+ export interface BitkitToggleFixedLabelProps extends Omit<SwitchRootProps, 'disabled' | 'readOnly' | 'required'> {
16
+ variant?: 'fixed-label';
17
+ tooltip?: string;
18
+ optional?: boolean;
19
+ helperText?: ReactNode | OnOff;
20
+ state?: 'default' | 'disabled' | 'disabledInput' | 'readOnly' | 'skeleton';
21
+ }
22
+ export type BitkitToggleProps = BitkitToggleDynamicLabelProps | BitkitToggleFixedLabelProps;
@@ -0,0 +1,3 @@
1
+ import { ReactNode } from 'react';
2
+ import { OnOff } from './BitkitToggle.types';
3
+ export declare function isOnOff(obj: ReactNode | OnOff): obj is OnOff;
@@ -0,0 +1,6 @@
1
+ function f(n) {
2
+ return typeof n == "object" && n !== null && "on" in n && "off" in n;
3
+ }
4
+ export {
5
+ f as isOnOff
6
+ };
@@ -0,0 +1,3 @@
1
+ import { BitkitToggleProps } from '../BitkitToggle.types';
2
+ declare const BitkitToggleHelperText: ({ state, helperText }: Pick<BitkitToggleProps, "state" | "helperText">) => import("react/jsx-runtime").JSX.Element | null;
3
+ export default BitkitToggleHelperText;
@@ -0,0 +1,20 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { Skeleton as l } from "@chakra-ui/react/skeleton";
3
+ import { useSwitchContext as d } from "@chakra-ui/react/switch";
4
+ import { Text as r } from "@chakra-ui/react/text";
5
+ import { isOnOff as f } from "../BitkitToggle.utils.js";
6
+ const b = ({ state: e, helperText: t }) => {
7
+ const { checked: n, disabled: s } = d();
8
+ if (e === "skeleton")
9
+ return /* @__PURE__ */ o(l, { height: "12", width: "128", my: "2" });
10
+ if (!t)
11
+ return null;
12
+ const i = {
13
+ textStyle: "comp/input/helperText",
14
+ color: s && e !== "disabledInput" ? "text/disabled" : "input/text/helper"
15
+ };
16
+ return f(t) ? /* @__PURE__ */ o(r, { ...i, children: n ? t.on : t.off }) : /* @__PURE__ */ o(r, { ...i, children: t });
17
+ };
18
+ export {
19
+ b as default
20
+ };
@@ -0,0 +1,3 @@
1
+ import { BitkitToggleProps } from '../BitkitToggle.types';
2
+ declare const BitkitToggleLabel: ({ label, state, tooltip, optional, }: Pick<BitkitToggleProps, "label" | "state" | "tooltip" | "optional">) => import("react/jsx-runtime").JSX.Element | null;
3
+ export default BitkitToggleLabel;
@@ -0,0 +1,33 @@
1
+ import { jsxs as s, jsx as t } from "react/jsx-runtime";
2
+ import { Flex as m } from "@chakra-ui/react/flex";
3
+ import { useSwitchContext as a } from "@chakra-ui/react/switch";
4
+ import { Text as l } from "@chakra-ui/react/text";
5
+ import c from "../../../icons/16x16/IconInfoCircle16.js";
6
+ import p from "../../BitkitTooltip/BitkitTooltip.js";
7
+ const g = ({
8
+ label: e,
9
+ state: o,
10
+ tooltip: r,
11
+ optional: n
12
+ }) => {
13
+ const { disabled: d } = a();
14
+ if (!e)
15
+ return null;
16
+ const i = d && o !== "disabledInput" && o !== "skeleton";
17
+ return /* @__PURE__ */ s(m, { gap: "4", alignItems: "center", children: [
18
+ /* @__PURE__ */ t(l, { as: "span", textStyle: "body/md/semibold", color: i ? "text/disabled" : "text/body", children: e }),
19
+ !!n && /* @__PURE__ */ t(
20
+ l,
21
+ {
22
+ as: "span",
23
+ textStyle: "body/md/regular",
24
+ color: i ? "text/disabled" : "input/text/helper",
25
+ children: "(optional)"
26
+ }
27
+ ),
28
+ !!r && /* @__PURE__ */ t(p, { text: r, children: /* @__PURE__ */ t(c, { color: "icon/tertiary" }) })
29
+ ] });
30
+ };
31
+ export {
32
+ g as default
33
+ };
@@ -0,0 +1,4 @@
1
+ import { BitkitToggleProps } from '../BitkitToggle.types';
2
+ type Props = Pick<BitkitToggleProps, 'state' | 'children'>;
3
+ declare const BitkitToggleReadOnly: ({ state, children }: Props) => string | number | bigint | boolean | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
4
+ export default BitkitToggleReadOnly;
@@ -0,0 +1,10 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { useSwitchContext as n } from "@chakra-ui/react";
3
+ import i from "../../DataDisplay/BitkitBadge/BitkitBadge.js";
4
+ const d = ({ state: e, children: o }) => {
5
+ const { checked: r } = n();
6
+ return e === "readOnly" && r ? /* @__PURE__ */ t(i, { colorScheme: "positive", variant: "subtle", children: "ON" }) : e === "readOnly" && !r ? /* @__PURE__ */ t(i, { colorScheme: "neutral", variant: "subtle", children: "OFF" }) : o;
7
+ };
8
+ export {
9
+ d as default
10
+ };
@@ -0,0 +1,3 @@
1
+ import { BitkitToggleDynamicLabelProps } from '../BitkitToggle.types';
2
+ declare const BitkitToggleValueText: ({ size, state, valueText, }: Pick<BitkitToggleDynamicLabelProps, "size" | "state" | "valueText">) => import("react/jsx-runtime").JSX.Element | null;
3
+ export default BitkitToggleValueText;
@@ -0,0 +1,15 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { Skeleton as f } from "@chakra-ui/react/skeleton";
3
+ import { useSwitchContext as m, Switch as i } from "@chakra-ui/react/switch";
4
+ import { isOnOff as c } from "../BitkitToggle.utils.js";
5
+ const p = ({
6
+ size: o,
7
+ state: n,
8
+ valueText: r
9
+ }) => {
10
+ const { checked: e } = m();
11
+ return n === "skeleton" ? /* @__PURE__ */ t(f, { height: o === "sm" ? "12" : "16", width: o === "sm" ? "64" : "128" }) : r ? c(r) ? /* @__PURE__ */ t(i.Label, { children: e ? r.on : r.off }) : /* @__PURE__ */ t(i.Label, { children: r }) : null;
12
+ };
13
+ export {
14
+ p as default
15
+ };
@@ -0,0 +1,2 @@
1
+ export { default } from './BitkitToggle';
2
+ export type { BitkitToggleProps } from './BitkitToggle.types';
@@ -0,0 +1,23 @@
1
+ import { jsxs as n } from "react/jsx-runtime";
2
+ import { Badge as a } from "@chakra-ui/react/badge";
3
+ import { forwardRef as o } from "react";
4
+ const m = o((t, d) => {
5
+ const { children: i, icon: r, ...e } = t;
6
+ return /* @__PURE__ */ n(
7
+ a,
8
+ {
9
+ ref: d,
10
+ ...e,
11
+ paddingInlineStart: i && !r ? "8" : "4",
12
+ paddingInlineEnd: i ? "8" : "4",
13
+ children: [
14
+ r,
15
+ i
16
+ ]
17
+ }
18
+ );
19
+ });
20
+ m.displayName = "BitkitBadge";
21
+ export {
22
+ m as default
23
+ };
@@ -2,4 +2,5 @@ export { default as BitkitButton, type BitkitButtonProps } from './BitkitButton/
2
2
  export { default as BitkitField, type BitkitFieldProps } from './BitkitField/BitkitField';
3
3
  export { default as BitkitNumberInput, type BitkitNumberInputProps } from './BitkitNumberInput/BitkitNumberInput';
4
4
  export { default as BitkitTextField, type BitkitTextFieldProps } from './BitkitTextField/BitkitTextField';
5
+ export { default as BitkitToggle, type BitkitToggleProps } from './BitkitToggle';
5
6
  export { default as BitkitTooltip, type BitkitTooltipProps } from './BitkitTooltip/BitkitTooltip';