@plasmicapp/react-web 0.2.206 → 0.2.208

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.
@@ -1,7 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { AnyPlasmicClass, PlasmicClassArgs, PlasmicClassOverrides, PlasmicClassVariants, VariantDef } from "../plume-utils";
3
3
  interface CommonProps {
4
- htmlType?: "submit" | "button";
5
4
  showStartIcon?: boolean;
6
5
  showEndIcon?: boolean;
7
6
  startIcon?: React.ReactNode;
@@ -10,9 +9,11 @@ interface CommonProps {
10
9
  isDisabled?: boolean;
11
10
  }
12
11
  interface HtmlButtonProps extends Omit<React.ComponentProps<"button">, "ref" | "disabled"> {
12
+ submitsForm?: boolean;
13
13
  }
14
- interface HtmlAnchorProps extends Omit<React.ComponentProps<"a">, "ref" | "href"> {
14
+ interface HtmlAnchorProps extends Omit<React.ComponentProps<"a">, "ref" | "href" | "target"> {
15
15
  link?: string;
16
+ target?: React.ComponentProps<"a">["target"] | boolean;
16
17
  }
17
18
  export type BaseButtonProps = CommonProps & HtmlButtonProps & HtmlAnchorProps;
18
19
  export type HtmlAnchorOnlyProps = Exclude<keyof HtmlAnchorProps, keyof HtmlButtonProps>;
@@ -2589,16 +2589,28 @@ function getPlumeType(child) {
2589
2589
  function useButton(plasmicClass, props, config, ref) {
2590
2590
  var _a, _b, _c, _d;
2591
2591
  if (ref === void 0) { ref = null; }
2592
- var link = props.link, isDisabled = props.isDisabled, startIcon = props.startIcon, endIcon = props.endIcon, showStartIcon = props.showStartIcon, showEndIcon = props.showEndIcon, children = props.children, htmlType = props.htmlType, rest = __rest(props, ["link", "isDisabled", "startIcon", "endIcon", "showStartIcon", "showEndIcon", "children", "htmlType"]);
2592
+ 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"]);
2593
2593
  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 }));
2594
2594
  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));
2595
+ var buttonType = undefined;
2596
+ if (!link) {
2597
+ if (!plasmicClass.internalVariantProps.includes("type") &&
2598
+ !plasmicClass.internalArgProps.includes("type") &&
2599
+ "type" in rest) {
2600
+ // There's no Plasmic-defined variant or arg called "type",
2601
+ // but the user passed in a "type" arg, so must be an override
2602
+ // or direct instantiation. We use that value
2603
+ buttonType = rest.type;
2604
+ }
2605
+ else {
2606
+ // Otherwise, we set buttonType depending in submitsForm
2607
+ buttonType = submitsForm ? "submit" : "button";
2608
+ }
2609
+ }
2595
2610
  var overrides = (_d = {},
2596
2611
  _d[config.root] = {
2597
2612
  as: link ? "a" : "button",
2598
- props: __assign(__assign(__assign({
2599
- // Put this at the top, as user may also have set `type` as
2600
- // inherited from "button", so let `rest` override it
2601
- type: htmlType }, omit.apply(void 0, __spreadArray(__spreadArray([rest], __read(plasmicClass.internalArgProps), false), __read(plasmicClass.internalVariantProps), false))), { ref: ref, disabled: isDisabled }), (!!link && { href: link })),
2613
+ 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 })),
2602
2614
  },
2603
2615
  _d);
2604
2616
  return {