@plasmicapp/react-web 0.2.205 → 0.2.207

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.205",
3
+ "version": "0.2.207",
4
4
  "description": "plasmic library for rendering in the presentational style",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
@@ -74,7 +74,7 @@
74
74
  },
75
75
  "prettier": {},
76
76
  "dependencies": {
77
- "@plasmicapp/data-sources": "0.1.73",
77
+ "@plasmicapp/data-sources": "0.1.74",
78
78
  "@plasmicapp/data-sources-context": "0.1.11",
79
79
  "@plasmicapp/host": "1.0.132",
80
80
  "@plasmicapp/query": "0.1.63",
@@ -142,5 +142,5 @@
142
142
  "react": ">=16.8.0",
143
143
  "react-dom": ">=16.8.0"
144
144
  },
145
- "gitHead": "4f587351ab80419692218f3362a55faf1e987182"
145
+ "gitHead": "30e8db6a6a212aba7bb77c6ec124685a81bc6004"
146
146
  }
@@ -9,9 +9,11 @@ interface CommonProps {
9
9
  isDisabled?: boolean;
10
10
  }
11
11
  interface HtmlButtonProps extends Omit<React.ComponentProps<"button">, "ref" | "disabled"> {
12
+ submitsForm?: boolean;
12
13
  }
13
- interface HtmlAnchorProps extends Omit<React.ComponentProps<"a">, "ref" | "href"> {
14
+ interface HtmlAnchorProps extends Omit<React.ComponentProps<"a">, "ref" | "href" | "target"> {
14
15
  link?: string;
16
+ target?: React.ComponentProps<"a">["target"] | boolean;
15
17
  }
16
18
  export type BaseButtonProps = CommonProps & HtmlButtonProps & HtmlAnchorProps;
17
19
  export type HtmlAnchorOnlyProps = Exclude<keyof HtmlAnchorProps, keyof HtmlButtonProps>;
@@ -5,13 +5,28 @@ import 'react';
5
5
  function useButton(plasmicClass, props, config, ref) {
6
6
  var _a, _b, _c, _d;
7
7
  if (ref === void 0) { ref = null; }
8
- var link = props.link, isDisabled = props.isDisabled, startIcon = props.startIcon, endIcon = props.endIcon, showStartIcon = props.showStartIcon, showEndIcon = props.showEndIcon, children = props.children, rest = __rest(props, ["link", "isDisabled", "startIcon", "endIcon", "showStartIcon", "showEndIcon", "children"]);
8
+ var link = props.link, isDisabled = props.isDisabled, startIcon = props.startIcon, endIcon = props.endIcon, showStartIcon = props.showStartIcon, showEndIcon = props.showEndIcon, children = props.children, target = props.target, _e = props.submitsForm, submitsForm = _e === void 0 ? false : _e, rest = __rest(props, ["link", "isDisabled", "startIcon", "endIcon", "showStartIcon", "showEndIcon", "children", "target", "submitsForm"]);
9
9
  var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.showStartIconVariant, active: showStartIcon }, { def: config.showEndIconVariant, active: showEndIcon }, { def: config.isDisabledVariant, active: isDisabled }));
10
10
  var args = __assign(__assign(__assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (config.startIconSlot && (_a = {}, _a[config.startIconSlot] = startIcon, _a))), (config.endIconSlot && (_b = {}, _b[config.endIconSlot] = endIcon, _b))), (_c = {}, _c[config.contentSlot] = children, _c));
11
+ var buttonType = undefined;
12
+ if (!link) {
13
+ if (!plasmicClass.internalVariantProps.includes("type") &&
14
+ !plasmicClass.internalArgProps.includes("type") &&
15
+ "type" in rest) {
16
+ // There's no Plasmic-defined variant or arg called "type",
17
+ // but the user passed in a "type" arg, so must be an override
18
+ // or direct instantiation. We use that value
19
+ buttonType = rest.type;
20
+ }
21
+ else {
22
+ // Otherwise, we set buttonType depending in submitsForm
23
+ buttonType = submitsForm ? "submit" : "button";
24
+ }
25
+ }
11
26
  var overrides = (_d = {},
12
27
  _d[config.root] = {
13
- as: !!link ? "a" : "button",
14
- props: __assign(__assign(__assign({}, omit.apply(void 0, __spreadArray(__spreadArray([rest], __read(plasmicClass.internalArgProps), false), __read(plasmicClass.internalVariantProps), false))), { ref: ref, disabled: isDisabled }), (!!link && { href: link })),
28
+ as: link ? "a" : "button",
29
+ props: __assign(__assign(__assign({}, omit.apply(void 0, __spreadArray(__spreadArray([rest], __read(plasmicClass.internalArgProps), false), __read(plasmicClass.internalVariantProps), false))), { type: buttonType, ref: ref, disabled: isDisabled, target: target === true ? "_blank" : target === false ? undefined : target }), (!!link && { href: link })),
15
30
  },
16
31
  _d);
17
32
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/plume/button/index.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { omit, pick } from \"../../common\";\nimport { Overrides } from \"../../render/elements\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n VariantDef,\n} from \"../plume-utils\";\n\ninterface CommonProps {\n showStartIcon?: boolean;\n showEndIcon?: boolean;\n startIcon?: React.ReactNode;\n endIcon?: React.ReactNode;\n children?: React.ReactNode;\n isDisabled?: boolean;\n}\n\ninterface HtmlButtonProps\n extends Omit<React.ComponentProps<\"button\">, \"ref\" | \"disabled\"> {}\n\ninterface HtmlAnchorProps\n extends Omit<React.ComponentProps<\"a\">, \"ref\" | \"href\"> {\n link?: string;\n}\n\nexport type BaseButtonProps = CommonProps & HtmlButtonProps & HtmlAnchorProps;\n\nexport type HtmlAnchorOnlyProps = Exclude<\n keyof HtmlAnchorProps,\n keyof HtmlButtonProps\n>;\nexport type HtmlButtonOnlyProps = Exclude<\n keyof HtmlButtonProps,\n keyof HtmlAnchorProps\n>;\n\nexport type ButtonRef = React.Ref<HTMLButtonElement | HTMLAnchorElement>;\n\ninterface ButtonConfig<C extends AnyPlasmicClass> {\n showStartIconVariant: VariantDef<PlasmicClassVariants<C>>;\n showEndIconVariant?: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n startIconSlot?: keyof PlasmicClassArgs<C>;\n endIconSlot?: keyof PlasmicClassArgs<C>;\n contentSlot: keyof PlasmicClassArgs<C>;\n root: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useButton<P extends BaseButtonProps, C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: P,\n config: ButtonConfig<C>,\n ref: ButtonRef = null\n) {\n const {\n link,\n isDisabled,\n startIcon,\n endIcon,\n showStartIcon,\n showEndIcon,\n children,\n ...rest\n } = props;\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.showStartIconVariant, active: showStartIcon },\n { def: config.showEndIconVariant, active: showEndIcon },\n { def: config.isDisabledVariant, active: isDisabled }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n ...(config.startIconSlot && { [config.startIconSlot]: startIcon }),\n ...(config.endIconSlot && { [config.endIconSlot]: endIcon }),\n [config.contentSlot]: children,\n };\n\n const overrides: Overrides = {\n [config.root]: {\n as: !!link ? \"a\" : \"button\",\n props: {\n ...omit(\n rest as any,\n ...plasmicClass.internalArgProps,\n ...plasmicClass.internalVariantProps\n ),\n ref: ref,\n disabled: isDisabled,\n ...(!!link && { href: link }),\n },\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n"],"names":[],"mappings":";;;;SAoDgB,SAAS,CACvB,YAAe,EACf,KAAQ,EACR,MAAuB,EACvB,GAAqB;;IAArB,oBAAA,EAAA,UAAqB;IAGnB,IAAA,IAAI,GAQF,KAAK,KARH,EACJ,UAAU,GAOR,KAAK,WAPG,EACV,SAAS,GAMP,KAAK,UANE,EACT,OAAO,GAKL,KAAK,QALA,EACP,aAAa,GAIX,KAAK,cAJM,EACb,WAAW,GAGT,KAAK,YAHI,EACX,QAAQ,GAEN,KAAK,SAFC,EACL,IAAI,UACL,KAAK,EATH,0FASL,CADQ,CACC;IACV,IAAM,QAAQ,yBACT,IAAI,8BAAC,KAAK,UAAK,YAAY,CAAC,oBAAoB,aAChD,mBAAmB,CACpB,EAAE,GAAG,EAAE,MAAM,CAAC,oBAAoB,EAAE,MAAM,EAAE,aAAa,EAAE,EAC3D,EAAE,GAAG,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAAW,EAAE,EACvD,EAAE,GAAG,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,EAAE,UAAU,EAAE,CACtD,CACF,CAAC;IAEF,IAAM,IAAI,2CACL,IAAI,8BAAC,KAAK,UAAK,YAAY,CAAC,gBAAgB,cAC3C,MAAM,CAAC,aAAa,cAAM,GAAC,MAAM,CAAC,aAAa,IAAG,SAAS,KAAE,KAC7D,MAAM,CAAC,WAAW,cAAM,GAAC,MAAM,CAAC,WAAW,IAAG,OAAO,KAAE,iBAC1D,MAAM,CAAC,WAAW,IAAG,QAAQ,MAC/B,CAAC;IAEF,IAAM,SAAS;QACb,GAAC,MAAM,CAAC,IAAI,IAAG;YACb,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ;YAC3B,KAAK,iCACA,IAAI,4CACL,IAAW,UACR,YAAY,CAAC,gBAAgB,kBAC7B,YAAY,CAAC,oBAAoB,eAEtC,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,UAAU,MAChB,CAAC,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAC7B;SACF;WACF,CAAC;IAEF,OAAO;QACL,YAAY,EAAE;YACZ,QAAQ,EAAE,QAAmC;YAC7C,IAAI,EAAE,IAA2B;YACjC,SAAS,EAAE,SAAqC;SACjD;KACF,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/plume/button/index.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { omit, pick } from \"../../common\";\nimport { Overrides } from \"../../render/elements\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n VariantDef,\n} from \"../plume-utils\";\n\ninterface CommonProps {\n showStartIcon?: boolean;\n showEndIcon?: boolean;\n startIcon?: React.ReactNode;\n endIcon?: React.ReactNode;\n children?: React.ReactNode;\n isDisabled?: boolean;\n}\n\ninterface HtmlButtonProps\n extends Omit<React.ComponentProps<\"button\">, \"ref\" | \"disabled\"> {\n submitsForm?: boolean;\n}\n\ninterface HtmlAnchorProps\n extends Omit<React.ComponentProps<\"a\">, \"ref\" | \"href\" | \"target\"> {\n link?: string;\n target?: React.ComponentProps<\"a\">[\"target\"] | boolean;\n}\n\nexport type BaseButtonProps = CommonProps & HtmlButtonProps & HtmlAnchorProps;\n\nexport type HtmlAnchorOnlyProps = Exclude<\n keyof HtmlAnchorProps,\n keyof HtmlButtonProps\n>;\nexport type HtmlButtonOnlyProps = Exclude<\n keyof HtmlButtonProps,\n keyof HtmlAnchorProps\n>;\n\nexport type ButtonRef = React.Ref<HTMLButtonElement | HTMLAnchorElement>;\n\ninterface ButtonConfig<C extends AnyPlasmicClass> {\n showStartIconVariant: VariantDef<PlasmicClassVariants<C>>;\n showEndIconVariant?: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n startIconSlot?: keyof PlasmicClassArgs<C>;\n endIconSlot?: keyof PlasmicClassArgs<C>;\n contentSlot: keyof PlasmicClassArgs<C>;\n root: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useButton<P extends BaseButtonProps, C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: P,\n config: ButtonConfig<C>,\n ref: ButtonRef = null\n) {\n const {\n link,\n isDisabled,\n startIcon,\n endIcon,\n showStartIcon,\n showEndIcon,\n children,\n target,\n submitsForm = false,\n ...rest\n } = props;\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.showStartIconVariant, active: showStartIcon },\n { def: config.showEndIconVariant, active: showEndIcon },\n { def: config.isDisabledVariant, active: isDisabled }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n ...(config.startIconSlot && { [config.startIconSlot]: startIcon }),\n ...(config.endIconSlot && { [config.endIconSlot]: endIcon }),\n [config.contentSlot]: children,\n };\n\n let buttonType = undefined;\n if (!link) {\n if (\n !plasmicClass.internalVariantProps.includes(\"type\") &&\n !plasmicClass.internalArgProps.includes(\"type\") &&\n \"type\" in rest\n ) {\n // There's no Plasmic-defined variant or arg called \"type\",\n // but the user passed in a \"type\" arg, so must be an override\n // or direct instantiation. We use that value\n buttonType = rest.type;\n } else {\n // Otherwise, we set buttonType depending in submitsForm\n buttonType = submitsForm ? \"submit\" : \"button\";\n }\n }\n\n const overrides: Overrides = {\n [config.root]: {\n as: link ? \"a\" : \"button\",\n props: {\n // Put this at the top, as user may also have set `type` as\n // inherited from \"button\", so let `rest` override it\n ...omit(\n rest as any,\n ...plasmicClass.internalArgProps,\n ...plasmicClass.internalVariantProps\n ),\n type: buttonType,\n ref: ref,\n disabled: isDisabled,\n target:\n target === true ? \"_blank\" : target === false ? undefined : target,\n ...(!!link && { href: link }),\n },\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n"],"names":[],"mappings":";;;;SAuDgB,SAAS,CACvB,YAAe,EACf,KAAQ,EACR,MAAuB,EACvB,GAAqB;;IAArB,oBAAA,EAAA,UAAqB;IAGnB,IAAA,IAAI,GAUF,KAAK,KAVH,EACJ,UAAU,GASR,KAAK,WATG,EACV,SAAS,GAQP,KAAK,UARE,EACT,OAAO,GAOL,KAAK,QAPA,EACP,aAAa,GAMX,KAAK,cANM,EACb,WAAW,GAKT,KAAK,YALI,EACX,QAAQ,GAIN,KAAK,SAJC,EACR,MAAM,GAGJ,KAAK,OAHD,EACN,KAEE,KAAK,YAFY,EAAnB,WAAW,mBAAG,KAAK,KAAA,EAChB,IAAI,UACL,KAAK,EAXH,mHA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