{"version":3,"file":"TextWidget-jU1qWYEP.cjs","names":["borderWidthClasses","borderColorClasses","getFontSizeField","getFontWeightField","getColorField","AlignLeft","AlignCenter","AlignRight","getPaddingField","getBorderRadiusField","getBorderWidthField","getBorderColorField"],"sources":["../../widgets/src/widgets/TextWidget.tsx"],"sourcesContent":["import type { WidgetPropertySchema } from \"@fluid-app/portal-core/registries\";\nimport type { ComponentProps } from \"react\";\nimport type React from \"react\";\nimport {\n  getBorderRadiusField,\n  getBorderWidthField,\n  getBorderColorField,\n  getColorField,\n  getFontSizeField,\n  getFontWeightField,\n  getPaddingField,\n  borderWidthClasses,\n  borderColorClasses,\n} from \"../core/fields\";\nimport type {\n  BackgroundValue,\n  BorderRadiusOptions,\n  BorderWidthOptions,\n  ColorOptions,\n  FontSizeOptions,\n  FontWeightOptions,\n  PaddingOptions,\n} from \"@fluid-app/portal-core/types\";\nimport { AlignCenter, AlignLeft, AlignRight } from \"lucide-react\";\n\ntype TextAlignment = \"left\" | \"center\" | \"right\";\n\nconst textAlignmentClasses: Record<TextAlignment, string> = {\n  left: \"text-left\",\n  center: \"text-center\",\n  right: \"text-right\",\n} as const;\n\ntype TextWidgetProps = ComponentProps<\"div\"> & {\n  // Title\n  titleEnabled?: boolean;\n  title?: string;\n  titleFontSize?: FontSizeOptions;\n  titleFontWeight?: FontWeightOptions;\n  titleColor?: ColorOptions;\n  titleAlignment?: TextAlignment;\n\n  // Description\n  description?: string;\n  /**\n   * Alias for `description`. Authoring tools and agents reach for `content`\n   * often enough that silently dropping it (and rendering placeholder copy)\n   * reads as a broken widget — accept it, lowest precedence.\n   */\n  content?: string;\n  descriptionFontSize?: FontSizeOptions;\n  descriptionFontWeight?: FontWeightOptions;\n  descriptionColor?: ColorOptions;\n  descriptionAlignment?: TextAlignment;\n\n  // Styling\n  background?: BackgroundValue;\n  padding?: PaddingOptions;\n  borderRadius?: BorderRadiusOptions;\n  borderWidth?: BorderWidthOptions;\n  borderColor?: ColorOptions;\n};\n\nexport function TextWidget({\n  titleEnabled = true,\n  title = \"Text Widget\",\n  titleFontSize = \"xl\",\n  titleFontWeight = \"bold\",\n  titleColor = \"foreground\",\n  titleAlignment = \"left\",\n  description,\n  content,\n  descriptionFontSize = \"md\",\n  descriptionFontWeight = \"normal\",\n  descriptionColor = \"foreground\",\n  descriptionAlignment = \"left\",\n  background = {\n    type: \"solid\",\n    color: \"background\",\n  },\n  padding = 4,\n  borderRadius = \"md\",\n  borderWidth = \"none\",\n  borderColor = \"muted\",\n  className,\n  ...props\n}: TextWidgetProps): React.JSX.Element {\n  const resolvedDescription = description ?? content ?? \"This is a text widget\";\n  const backgroundColor = background.color || \"background\";\n  const backgroundImage =\n    (background.resource?.image_url || background.resource?.imageUrl) &&\n    background.type === \"image\"\n      ? `url(${background.resource.image_url || background.resource.imageUrl})`\n      : \"none\";\n  return (\n    <div\n      className={`bg-${backgroundColor} p-${padding} rounded-${borderRadius} ${borderWidthClasses[borderWidth]} ${borderWidth !== \"none\" ? borderColorClasses[borderColor] : \"\"} ${className ?? \"\"}`}\n      style={{ backgroundImage }}\n      {...props}\n    >\n      {titleEnabled && (\n        <h2\n          className={`text-${titleFontSize} text-${titleColor} ${textAlignmentClasses[titleAlignment]} font-header font-${titleFontWeight}`}\n        >\n          {title}\n        </h2>\n      )}\n      <p\n        className={`text-${descriptionFontSize} text-${descriptionColor} ${textAlignmentClasses[descriptionAlignment]} font-${descriptionFontWeight}`}\n      >\n        {resolvedDescription}\n      </p>\n    </div>\n  );\n}\n\nexport const textWidgetPropertySchema: WidgetPropertySchema = {\n  widgetType: \"TextWidget\",\n  displayName: \"Text Widget\",\n  tabsConfig: [{ id: \"content\", label: \"Content\" }],\n  dataSourceTargetProps: [\"title\", \"description\"],\n  fields: [\n    // Content Tab - Title Group\n    {\n      key: \"titleEnabled\",\n      label: \"Widget Title\",\n      type: \"boolean\",\n      description: \"Enable the title displayed above the text\",\n      defaultValue: true,\n      tab: \"content\",\n      group: \"Title\",\n    },\n    {\n      key: \"title\",\n      label: \"Title\",\n      type: \"text\",\n      description: \"The title\",\n      defaultValue: \"Heads up!\",\n      tab: \"content\",\n      group: \"Title\",\n      requiresKeyToBeTrue: \"titleEnabled\",\n    },\n    getFontSizeField({\n      key: \"titleFontSize\",\n      label: \"Title Font Size\",\n      description: \"Font size for the title\",\n      defaultValue: \"xl\",\n      tab: \"content\",\n      group: \"Title\",\n      requiresKeyToBeTrue: \"titleEnabled\",\n    }),\n    getFontWeightField({\n      key: \"titleFontWeight\",\n      label: \"Title Font Weight\",\n      description: \"Font weight for the title\",\n      defaultValue: \"bold\",\n      tab: \"content\",\n      group: \"Title\",\n      requiresKeyToBeTrue: \"titleEnabled\",\n    }),\n    getColorField({\n      key: \"titleColor\",\n      label: \"Title Color\",\n      description: \"The color of the title\",\n      defaultValue: \"foreground\",\n      tab: \"content\",\n      group: \"Title\",\n      requiresKeyToBeTrue: \"titleEnabled\",\n    }),\n    {\n      key: \"titleAlignment\",\n      label: \"Alignment\",\n      type: \"buttonGroup\",\n      description: \"Text alignment for the title\",\n      options: [\n        { icon: AlignLeft, ariaLabel: \"Align left\", value: \"left\" },\n        { icon: AlignCenter, ariaLabel: \"Align center\", value: \"center\" },\n        { icon: AlignRight, ariaLabel: \"Align right\", value: \"right\" },\n      ],\n      defaultValue: \"left\",\n      tab: \"content\",\n      group: \"Title\",\n      requiresKeyToBeTrue: \"titleEnabled\",\n    },\n    // Content Tab - Description Group\n    {\n      key: \"description\",\n      label: \"Description\",\n      type: \"textarea\",\n      description: \"The text message\",\n      rows: 3,\n      defaultValue:\n        \"You can add components and dependencies to your app using the cli.\",\n      tab: \"content\",\n      group: \"Description\",\n    },\n    getFontSizeField({\n      key: \"descriptionFontSize\",\n      label: \"Description Font Size\",\n      description: \"Font size for the text\",\n      defaultValue: \"md\",\n      tab: \"content\",\n      group: \"Description\",\n    }),\n    getFontWeightField({\n      key: \"descriptionFontWeight\",\n      label: \"Description Font Weight\",\n      description: \"Font weight for the text\",\n      defaultValue: \"normal\",\n      tab: \"content\",\n      group: \"Description\",\n    }),\n    getColorField({\n      key: \"descriptionColor\",\n      label: \"Description Color\",\n      description: \"The color of the text\",\n      defaultValue: \"foreground\",\n      tab: \"content\",\n      group: \"Description\",\n    }),\n    {\n      key: \"descriptionAlignment\",\n      label: \"Alignment\",\n      type: \"buttonGroup\",\n      description: \"Text alignment for the description\",\n      options: [\n        { icon: AlignLeft, ariaLabel: \"Align left\", value: \"left\" },\n        { icon: AlignCenter, ariaLabel: \"Align center\", value: \"center\" },\n        { icon: AlignRight, ariaLabel: \"Align right\", value: \"right\" },\n      ],\n      defaultValue: \"left\",\n      tab: \"content\",\n      group: \"Description\",\n    },\n    // Content Tab - Style Group\n    {\n      type: \"background\",\n      key: \"background\",\n      label: \"Background\",\n      description: \"Background for the text container\",\n      defaultValue: { type: \"solid\", color: \"background\" },\n      tab: \"content\",\n      group: \"Style\",\n    },\n    getPaddingField({\n      key: \"padding\",\n      label: \"Padding\",\n      description: \"The padding of the text container\",\n      defaultValue: 4,\n      tab: \"content\",\n      group: \"Style\",\n    }),\n    getBorderRadiusField({\n      key: \"borderRadius\",\n      description: \"The border radius of the text container\",\n      label: \"Border Radius\",\n      tab: \"content\",\n      group: \"Design\",\n    }),\n    getBorderWidthField({\n      key: \"borderWidth\",\n      label: \"Border Width\",\n      description: \"The border width of the text container\",\n      defaultValue: \"none\",\n      tab: \"content\",\n      group: \"Design\",\n    }),\n    getBorderColorField({\n      key: \"borderColor\",\n      label: \"Border Color\",\n      description: \"The border color of the text container\",\n      defaultValue: \"muted\",\n      tab: \"content\",\n      group: \"Design\",\n    }),\n  ],\n};\n"],"mappings":";;;;;;;;;AA2BA,MAAM,uBAAsD;CAC1D,MAAM;CACN,QAAQ;CACR,OAAO;CACR;AAgCD,SAAgB,WAAW,EACzB,eAAe,MACf,QAAQ,eACR,gBAAgB,MAChB,kBAAkB,QAClB,aAAa,cACb,iBAAiB,QACjB,aACA,SACA,sBAAsB,MACtB,wBAAwB,UACxB,mB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