@propellerads/switch 7.0.0 → 9.0.0
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.
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react from 'react';
|
|
2
2
|
import { ReactNode, Ref } from 'react';
|
|
3
3
|
|
|
4
4
|
type SwitchProps = {
|
|
@@ -33,7 +33,7 @@ type SwitchProps = {
|
|
|
33
33
|
* it. The track stays v5's 40 by 20 pixels, so a screen laid out around the old
|
|
34
34
|
* switch does not move.
|
|
35
35
|
*/
|
|
36
|
-
declare const Switch: ({ isActive, onChange, containerClassName, controlClassName, elementId, isDisabled, label, description, labelPlacement, isInvalid, "aria-label": ariaLabel, name, inputRef, }: SwitchProps) =>
|
|
36
|
+
declare const Switch: ({ isActive, onChange, containerClassName, controlClassName, elementId, isDisabled, label, description, labelPlacement, isInvalid, "aria-label": ariaLabel, name, inputRef, }: SwitchProps) => react.JSX.Element;
|
|
37
37
|
|
|
38
38
|
export { Switch, Switch as default };
|
|
39
39
|
export type { SwitchProps };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Switch as e } from "@base-ui-components/react/switch";
|
|
|
2
2
|
import { useId as t } from "react";
|
|
3
3
|
import { clsx as n } from "clsx";
|
|
4
4
|
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
|
-
import './index.css'
|
|
5
|
+
import './index.css';// src/cn.ts
|
|
6
6
|
var a = (...e) => n(e), o = ({ isActive: n, onChange: o, containerClassName: s, controlClassName: c, elementId: l, isDisabled: u = !1, label: d, description: f, labelPlacement: p = "end", isInvalid: m = !1, "aria-label": h, name: g, inputRef: _ }) => {
|
|
7
7
|
let v = t(), y = l ?? v, b = `${y}-description`, x = d !== void 0 || f !== void 0;
|
|
8
8
|
return /* @__PURE__ */ i("div", {
|
|
@@ -39,7 +39,6 @@ var a = (...e) => n(e), o = ({ isActive: n, onChange: o, containerClassName: s,
|
|
|
39
39
|
})]
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
|
-
//#endregion
|
|
43
42
|
export { o as Switch, o as default };
|
|
44
43
|
|
|
45
44
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/cn.ts","../src/index.tsx"],"sourcesContent":["import {type ClassValue, clsx} from 'clsx';\n\n/**\n * Joins class names. There is no tailwind-merge here on purpose: the switch\n * ships its own stylesheet instead of utility classes, so there is nothing to\n * deduplicate.\n */\nconst cn = (...inputs: ClassValue[]): string => clsx(inputs);\n\nexport {cn};\n","import {Switch as BaseSwitch} from '@base-ui-components/react/switch';\nimport {type ReactNode, type Ref, useId} from 'react';\nimport './switch.css';\nimport {cn} from './cn';\n\ntype SwitchProps = {\n /** On or off. Controlled by the caller. */\n isActive: boolean;\n /** Called with the value the switch is turning to. */\n onChange: (nextValue: boolean) => void;\n /** On the outer box, as in v5. */\n containerClassName?: string;\n /** On the box around the track, as in v5. */\n controlClassName?: string;\n /** The switch's id, as in v5: products and tests find it by it. */\n elementId?: string;\n isDisabled?: boolean;\n /** Text beside the switch; a click on it toggles the switch. */\n label?: ReactNode;\n /** A line under the label. The switch is described by it. */\n description?: ReactNode;\n /** Which side the label stands on. `start` puts it first and the switch at the end of the row. @default 'end' */\n labelPlacement?: 'start' | 'end';\n /** Marks the switch invalid: a danger ring round the track, the label in danger, `aria-invalid`. */\n isInvalid?: boolean;\n /** Names the switch when there is no `label`. */\n 'aria-label'?: string;\n /** Submits the value with a form under this name. */\n name?: string;\n /** The hidden checkbox Base UI renders for forms. */\n inputRef?: Ref<HTMLInputElement>;\n};\n\n/**\n * shadcn's switch on Base UI: a `role=\"switch\"` button, Space and Enter toggle\n * it. The track stays v5's 40 by 20 pixels, so a screen laid out around the old\n * switch does not move.\n */\nconst Switch = ({\n isActive,\n onChange,\n containerClassName,\n controlClassName,\n elementId,\n isDisabled = false,\n label,\n description,\n labelPlacement = 'end',\n isInvalid = false,\n 'aria-label': ariaLabel,\n name,\n inputRef,\n}: SwitchProps) => {\n const fallbackId = useId();\n const id = elementId ?? fallbackId;\n const descriptionId = `${id}-description`;\n const hasText = label !== undefined || description !== undefined;\n\n return (\n <div\n className={cn('switch', containerClassName)}\n data-disabled={isDisabled || undefined}\n data-invalid={isInvalid || undefined}\n data-label-placement={labelPlacement}\n >\n <span className={cn('switch__control', controlClassName)}>\n <BaseSwitch.Root\n id={id}\n className=\"switch__track\"\n checked={isActive}\n onCheckedChange={(checked) => onChange(checked)}\n disabled={isDisabled}\n name={name}\n inputRef={inputRef}\n aria-label={ariaLabel}\n {...(isInvalid ? {'aria-invalid': true} : {})}\n {...(description !== undefined ? {'aria-describedby': descriptionId} : {})}\n >\n <BaseSwitch.Thumb className=\"switch__thumb\" />\n </BaseSwitch.Root>\n </span>\n {hasText && (\n <span className=\"switch__text\">\n {label !== undefined && (\n <label className=\"switch__label\" htmlFor={id}>\n {label}\n </label>\n )}\n {description !== undefined && (\n <span id={descriptionId} className=\"switch__description\">\n {description}\n </span>\n )}\n </span>\n )}\n </div>\n );\n};\n\nexport default Switch;\n\nexport type {SwitchProps};\nexport {Switch};\n"],"mappings":";;;;;AAOA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["BaseSwitch","Switch$1","cn","inputs","clsx","Switch","ariaLabel","fallbackId","useId","id","elementId","descriptionId","hasText","label","description","containerClassName","isDisabled","isInvalid","labelPlacement","controlClassName","isActive","onChange","checked"],"sources":["../src/cn.ts","../src/index.tsx"],"sourcesContent":["import {type ClassValue, clsx} from 'clsx';\n\n/**\n * Joins class names. There is no tailwind-merge here on purpose: the switch\n * ships its own stylesheet instead of utility classes, so there is nothing to\n * deduplicate.\n */\nconst cn = (...inputs: ClassValue[]): string => clsx(inputs);\n\nexport {cn};\n","import {Switch as BaseSwitch} from '@base-ui-components/react/switch';\nimport {type ReactNode, type Ref, useId} from 'react';\nimport './switch.css';\nimport {cn} from './cn';\n\ntype SwitchProps = {\n /** On or off. Controlled by the caller. */\n isActive: boolean;\n /** Called with the value the switch is turning to. */\n onChange: (nextValue: boolean) => void;\n /** On the outer box, as in v5. */\n containerClassName?: string;\n /** On the box around the track, as in v5. */\n controlClassName?: string;\n /** The switch's id, as in v5: products and tests find it by it. */\n elementId?: string;\n isDisabled?: boolean;\n /** Text beside the switch; a click on it toggles the switch. */\n label?: ReactNode;\n /** A line under the label. The switch is described by it. */\n description?: ReactNode;\n /** Which side the label stands on. `start` puts it first and the switch at the end of the row. @default 'end' */\n labelPlacement?: 'start' | 'end';\n /** Marks the switch invalid: a danger ring round the track, the label in danger, `aria-invalid`. */\n isInvalid?: boolean;\n /** Names the switch when there is no `label`. */\n 'aria-label'?: string;\n /** Submits the value with a form under this name. */\n name?: string;\n /** The hidden checkbox Base UI renders for forms. */\n inputRef?: Ref<HTMLInputElement>;\n};\n\n/**\n * shadcn's switch on Base UI: a `role=\"switch\"` button, Space and Enter toggle\n * it. The track stays v5's 40 by 20 pixels, so a screen laid out around the old\n * switch does not move.\n */\nconst Switch = ({\n isActive,\n onChange,\n containerClassName,\n controlClassName,\n elementId,\n isDisabled = false,\n label,\n description,\n labelPlacement = 'end',\n isInvalid = false,\n 'aria-label': ariaLabel,\n name,\n inputRef,\n}: SwitchProps) => {\n const fallbackId = useId();\n const id = elementId ?? fallbackId;\n const descriptionId = `${id}-description`;\n const hasText = label !== undefined || description !== undefined;\n\n return (\n <div\n className={cn('switch', containerClassName)}\n data-disabled={isDisabled || undefined}\n data-invalid={isInvalid || undefined}\n data-label-placement={labelPlacement}\n >\n <span className={cn('switch__control', controlClassName)}>\n <BaseSwitch.Root\n id={id}\n className=\"switch__track\"\n checked={isActive}\n onCheckedChange={(checked) => onChange(checked)}\n disabled={isDisabled}\n name={name}\n inputRef={inputRef}\n aria-label={ariaLabel}\n {...(isInvalid ? {'aria-invalid': true} : {})}\n {...(description !== undefined ? {'aria-describedby': descriptionId} : {})}\n >\n <BaseSwitch.Thumb className=\"switch__thumb\" />\n </BaseSwitch.Root>\n </span>\n {hasText && (\n <span className=\"switch__text\">\n {label !== undefined && (\n <label className=\"switch__label\" htmlFor={id}>\n {label}\n </label>\n )}\n {description !== undefined && (\n <span id={descriptionId} className=\"switch__description\">\n {description}\n </span>\n )}\n </span>\n )}\n </div>\n );\n};\n\nexport default Switch;\n\nexport type {SwitchProps};\nexport {Switch};\n"],"mappings":";;;;;AAOA,IAAME,KAAM,GAAGC,MAAiCC,EAAKD,CAAM,GC+BrDE,KAAU,EACd,aACA,aACA,uBACA,qBACA,cACA,gBAAa,IACb,UACA,gBACA,oBAAiB,OACjB,eAAY,IACZ,cAAcC,GACd,SACA,kBACiB;CACjB,IAAMC,IAAaC,EAAM,GACnBC,IAAKC,KAAaH,GAClBI,IAAgB,GAAGF,EAAG,eACtBG,IAAUC,MAAU,KAAA,KAAaC,MAAgB,KAAA;CAEvD,OACE,kBAAC,OAAD;EACE,WAAWZ,EAAG,UAAUa,CAAkB;EAC1C,iBAAeC,KAAc,KAAA;EAC7B,gBAAcC,KAAa,KAAA;EAC3B,wBAAsBC;EAJxB,UAAA,CAME,kBAAC,QAAD;GAAM,WAAWhB,EAAG,mBAAmBiB,CAAgB;GACrD,UAAA,kBAACnB,EAAW,MAAZ;IACM;IACJ,WAAU;IACV,SAASoB;IACT,kBAAkB,MAAYC,EAASC,CAAO;IAC9C,UAAUN;IACJ;IACI;IACV,cAAYV;IACZ,GAAKW,IAAY,EAAC,gBAAgB,GAAI,IAAI,CAAC;IAC3C,GAAKH,MAAgB,KAAA,IAAkD,CAAC,IAAvC,EAAC,oBAAoBH,EAAa;IAEnE,UAAA,kBAACX,EAAW,OAAZ,EAAkB,WAAU,gBAAiB,CAAA;GAC9B,CAAA;EACb,CAAA,GACLY,KACC,kBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACGC,MAAU,KAAA,KACT,kBAAC,SAAD;IAAO,WAAU;IAAgB,SAASJ;IACvC,UAAAI;GACI,CAAA,GAERC,MAAgB,KAAA,KACf,kBAAC,QAAD;IAAM,IAAIH;IAAe,WAAU;IAChC,UAAAG;GACG,CAAA,CAEJ;EAEL,CAAA,CAAA;;AAET"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/switch",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/index.css",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"url": "https://github.com/propellerads/ui-components/issues"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsc && vite build &&
|
|
27
|
+
"build": "tsc && vite build && rollup -c rollup.dts.config.mjs"
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
30
30
|
"private": false,
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"clsx": "^2.1.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@propellerads/tokens": ">=0.
|
|
36
|
+
"@propellerads/tokens": ">=0.5.0",
|
|
37
37
|
"react": "^18.0.0 || ^19.0.0",
|
|
38
38
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
39
39
|
},
|