@measured/puck 0.17.1 → 0.17.2-canary.bbe0a8d

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.mts CHANGED
@@ -39,7 +39,7 @@ declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }:
39
39
  type FieldNoLabel<Props extends any = any> = Omit<Field<Props>, "label">;
40
40
  declare function AutoField<ValueType = any, FieldType extends FieldNoLabel<ValueType> = FieldNoLabel<ValueType>>(props: FieldProps<ValueType, FieldType>): react_jsx_runtime.JSX.Element;
41
41
 
42
- declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, }: {
42
+ declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, ...props }: {
43
43
  children: ReactNode;
44
44
  href?: string;
45
45
  onClick?: (e: any) => void | Promise<void>;
package/dist/index.d.ts CHANGED
@@ -39,7 +39,7 @@ declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }:
39
39
  type FieldNoLabel<Props extends any = any> = Omit<Field<Props>, "label">;
40
40
  declare function AutoField<ValueType = any, FieldType extends FieldNoLabel<ValueType> = FieldNoLabel<ValueType>>(props: FieldProps<ValueType, FieldType>): react_jsx_runtime.JSX.Element;
41
41
 
42
- declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, }: {
42
+ declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, ...props }: {
43
43
  children: ReactNode;
44
44
  href?: string;
45
45
  onClick?: (e: any) => void | Promise<void>;
package/dist/index.js CHANGED
@@ -1801,29 +1801,57 @@ var import_react10 = require("react");
1801
1801
  init_react_import();
1802
1802
  var Button_module_default = { "Button": "_Button_1t64k_1", "Button--medium": "_Button--medium_1t64k_29", "Button--large": "_Button--large_1t64k_37", "Button-icon": "_Button-icon_1t64k_44", "Button--primary": "_Button--primary_1t64k_48", "Button--secondary": "_Button--secondary_1t64k_67", "Button--flush": "_Button--flush_1t64k_84", "Button--disabled": "_Button--disabled_1t64k_88", "Button--fullWidth": "_Button--fullWidth_1t64k_95", "Button-spinner": "_Button-spinner_1t64k_100" };
1803
1803
 
1804
+ // lib/filter-data-attrs.ts
1805
+ init_react_import();
1806
+ var dataAttrRe = /^(data-.*)$/;
1807
+ var filterDataAttrs = (props) => {
1808
+ let filteredProps = {};
1809
+ for (const prop in props) {
1810
+ if (Object.prototype.hasOwnProperty.call(props, prop) && dataAttrRe.test(prop)) {
1811
+ filteredProps[prop] = props[prop];
1812
+ }
1813
+ }
1814
+ return filteredProps;
1815
+ };
1816
+
1804
1817
  // components/Button/Button.tsx
1805
1818
  var import_jsx_runtime13 = require("react/jsx-runtime");
1806
1819
  var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
1807
- var Button = ({
1808
- children,
1809
- href,
1810
- onClick,
1811
- variant = "primary",
1812
- type,
1813
- disabled,
1814
- tabIndex,
1815
- newTab,
1816
- fullWidth,
1817
- icon,
1818
- size = "medium",
1819
- loading: loadingProp = false
1820
- }) => {
1820
+ var Button = (_a) => {
1821
+ var _b = _a, {
1822
+ children,
1823
+ href,
1824
+ onClick,
1825
+ variant = "primary",
1826
+ type,
1827
+ disabled,
1828
+ tabIndex,
1829
+ newTab,
1830
+ fullWidth,
1831
+ icon,
1832
+ size = "medium",
1833
+ loading: loadingProp = false
1834
+ } = _b, props = __objRest(_b, [
1835
+ "children",
1836
+ "href",
1837
+ "onClick",
1838
+ "variant",
1839
+ "type",
1840
+ "disabled",
1841
+ "tabIndex",
1842
+ "newTab",
1843
+ "fullWidth",
1844
+ "icon",
1845
+ "size",
1846
+ "loading"
1847
+ ]);
1821
1848
  const [loading, setLoading] = (0, import_react10.useState)(loadingProp);
1822
1849
  (0, import_react10.useEffect)(() => setLoading(loadingProp), [loadingProp]);
1823
1850
  const ElementType = href ? "a" : type ? "button" : "span";
1851
+ const dataAttrs = filterDataAttrs(props);
1824
1852
  const el = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1825
1853
  ElementType,
1826
- {
1854
+ __spreadProps(__spreadValues({
1827
1855
  className: getClassName9({
1828
1856
  primary: variant === "primary",
1829
1857
  secondary: variant === "secondary",
@@ -1843,13 +1871,14 @@ var Button = ({
1843
1871
  tabIndex,
1844
1872
  target: newTab ? "_blank" : void 0,
1845
1873
  rel: newTab ? "noreferrer" : void 0,
1846
- href,
1874
+ href
1875
+ }, dataAttrs), {
1847
1876
  children: [
1848
1877
  icon && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassName9("icon"), children: icon }),
1849
1878
  children,
1850
1879
  loading && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 14 }) })
1851
1880
  ]
1852
- }
1881
+ })
1853
1882
  );
1854
1883
  return el;
1855
1884
  };
package/dist/index.mjs CHANGED
@@ -1619,29 +1619,57 @@ import { useEffect as useEffect6, useState as useState7 } from "react";
1619
1619
  init_react_import();
1620
1620
  var Button_module_default = { "Button": "_Button_1t64k_1", "Button--medium": "_Button--medium_1t64k_29", "Button--large": "_Button--large_1t64k_37", "Button-icon": "_Button-icon_1t64k_44", "Button--primary": "_Button--primary_1t64k_48", "Button--secondary": "_Button--secondary_1t64k_67", "Button--flush": "_Button--flush_1t64k_84", "Button--disabled": "_Button--disabled_1t64k_88", "Button--fullWidth": "_Button--fullWidth_1t64k_95", "Button-spinner": "_Button-spinner_1t64k_100" };
1621
1621
 
1622
+ // lib/filter-data-attrs.ts
1623
+ init_react_import();
1624
+ var dataAttrRe = /^(data-.*)$/;
1625
+ var filterDataAttrs = (props) => {
1626
+ let filteredProps = {};
1627
+ for (const prop in props) {
1628
+ if (Object.prototype.hasOwnProperty.call(props, prop) && dataAttrRe.test(prop)) {
1629
+ filteredProps[prop] = props[prop];
1630
+ }
1631
+ }
1632
+ return filteredProps;
1633
+ };
1634
+
1622
1635
  // components/Button/Button.tsx
1623
1636
  import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
1624
1637
  var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
1625
- var Button = ({
1626
- children,
1627
- href,
1628
- onClick,
1629
- variant = "primary",
1630
- type,
1631
- disabled,
1632
- tabIndex,
1633
- newTab,
1634
- fullWidth,
1635
- icon,
1636
- size = "medium",
1637
- loading: loadingProp = false
1638
- }) => {
1638
+ var Button = (_a) => {
1639
+ var _b = _a, {
1640
+ children,
1641
+ href,
1642
+ onClick,
1643
+ variant = "primary",
1644
+ type,
1645
+ disabled,
1646
+ tabIndex,
1647
+ newTab,
1648
+ fullWidth,
1649
+ icon,
1650
+ size = "medium",
1651
+ loading: loadingProp = false
1652
+ } = _b, props = __objRest(_b, [
1653
+ "children",
1654
+ "href",
1655
+ "onClick",
1656
+ "variant",
1657
+ "type",
1658
+ "disabled",
1659
+ "tabIndex",
1660
+ "newTab",
1661
+ "fullWidth",
1662
+ "icon",
1663
+ "size",
1664
+ "loading"
1665
+ ]);
1639
1666
  const [loading, setLoading] = useState7(loadingProp);
1640
1667
  useEffect6(() => setLoading(loadingProp), [loadingProp]);
1641
1668
  const ElementType = href ? "a" : type ? "button" : "span";
1669
+ const dataAttrs = filterDataAttrs(props);
1642
1670
  const el = /* @__PURE__ */ jsxs6(
1643
1671
  ElementType,
1644
- {
1672
+ __spreadProps(__spreadValues({
1645
1673
  className: getClassName9({
1646
1674
  primary: variant === "primary",
1647
1675
  secondary: variant === "secondary",
@@ -1661,13 +1689,14 @@ var Button = ({
1661
1689
  tabIndex,
1662
1690
  target: newTab ? "_blank" : void 0,
1663
1691
  rel: newTab ? "noreferrer" : void 0,
1664
- href,
1692
+ href
1693
+ }, dataAttrs), {
1665
1694
  children: [
1666
1695
  icon && /* @__PURE__ */ jsx13("div", { className: getClassName9("icon"), children: icon }),
1667
1696
  children,
1668
1697
  loading && /* @__PURE__ */ jsx13("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ jsx13(Loader, { size: 14 }) })
1669
1698
  ]
1670
- }
1699
+ })
1671
1700
  );
1672
1701
  return el;
1673
1702
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.17.1",
3
+ "version": "0.17.2-canary.bbe0a8d",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",