@hitachivantara/uikit-react-core 5.39.4 → 5.40.1

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.
Files changed (58) hide show
  1. package/dist/cjs/AvatarGroup/AvatarGroup.cjs +103 -0
  2. package/dist/cjs/AvatarGroup/AvatarGroup.cjs.map +1 -0
  3. package/dist/cjs/AvatarGroup/AvatarGroup.styles.cjs +24 -0
  4. package/dist/cjs/AvatarGroup/AvatarGroup.styles.cjs.map +1 -0
  5. package/dist/cjs/QueryBuilder/Context.cjs.map +1 -1
  6. package/dist/cjs/QueryBuilder/QueryBuilder.cjs +5 -2
  7. package/dist/cjs/QueryBuilder/QueryBuilder.cjs.map +1 -1
  8. package/dist/cjs/QueryBuilder/QueryBuilder.styles.cjs +4 -2
  9. package/dist/cjs/QueryBuilder/QueryBuilder.styles.cjs.map +1 -1
  10. package/dist/cjs/QueryBuilder/Rule/Operator/Operator.cjs +1 -1
  11. package/dist/cjs/QueryBuilder/Rule/Operator/Operator.cjs.map +1 -1
  12. package/dist/cjs/QueryBuilder/Rule/Rule.cjs +1 -2
  13. package/dist/cjs/QueryBuilder/Rule/Rule.cjs.map +1 -1
  14. package/dist/cjs/QueryBuilder/Rule/Rule.styles.cjs +1 -1
  15. package/dist/cjs/QueryBuilder/Rule/Rule.styles.cjs.map +1 -1
  16. package/dist/cjs/QueryBuilder/Rule/Value/EmptyValue/EmptyValue.cjs +17 -0
  17. package/dist/cjs/QueryBuilder/Rule/Value/EmptyValue/EmptyValue.cjs.map +1 -0
  18. package/dist/cjs/QueryBuilder/Rule/Value/Value.cjs +29 -19
  19. package/dist/cjs/QueryBuilder/Rule/Value/Value.cjs.map +1 -1
  20. package/dist/cjs/QueryBuilder/RuleGroup/RuleGroup.cjs +2 -0
  21. package/dist/cjs/QueryBuilder/RuleGroup/RuleGroup.cjs.map +1 -1
  22. package/dist/cjs/QueryBuilder/types.cjs +5 -0
  23. package/dist/cjs/QueryBuilder/types.cjs.map +1 -0
  24. package/dist/cjs/TimePicker/TimePicker.cjs.map +1 -1
  25. package/dist/cjs/Typography/Typography.cjs +2 -1
  26. package/dist/cjs/Typography/Typography.cjs.map +1 -1
  27. package/dist/cjs/index.cjs +4 -0
  28. package/dist/cjs/index.cjs.map +1 -1
  29. package/dist/esm/AvatarGroup/AvatarGroup.js +104 -0
  30. package/dist/esm/AvatarGroup/AvatarGroup.js.map +1 -0
  31. package/dist/esm/AvatarGroup/AvatarGroup.styles.js +24 -0
  32. package/dist/esm/AvatarGroup/AvatarGroup.styles.js.map +1 -0
  33. package/dist/esm/QueryBuilder/Context.js.map +1 -1
  34. package/dist/esm/QueryBuilder/QueryBuilder.js +5 -2
  35. package/dist/esm/QueryBuilder/QueryBuilder.js.map +1 -1
  36. package/dist/esm/QueryBuilder/QueryBuilder.styles.js +4 -2
  37. package/dist/esm/QueryBuilder/QueryBuilder.styles.js.map +1 -1
  38. package/dist/esm/QueryBuilder/Rule/Operator/Operator.js +1 -1
  39. package/dist/esm/QueryBuilder/Rule/Operator/Operator.js.map +1 -1
  40. package/dist/esm/QueryBuilder/Rule/Rule.js +1 -2
  41. package/dist/esm/QueryBuilder/Rule/Rule.js.map +1 -1
  42. package/dist/esm/QueryBuilder/Rule/Rule.styles.js +1 -1
  43. package/dist/esm/QueryBuilder/Rule/Rule.styles.js.map +1 -1
  44. package/dist/esm/QueryBuilder/Rule/Value/EmptyValue/EmptyValue.js +17 -0
  45. package/dist/esm/QueryBuilder/Rule/Value/EmptyValue/EmptyValue.js.map +1 -0
  46. package/dist/esm/QueryBuilder/Rule/Value/Value.js +29 -19
  47. package/dist/esm/QueryBuilder/Rule/Value/Value.js.map +1 -1
  48. package/dist/esm/QueryBuilder/RuleGroup/RuleGroup.js +2 -0
  49. package/dist/esm/QueryBuilder/RuleGroup/RuleGroup.js.map +1 -1
  50. package/dist/esm/QueryBuilder/types.js +5 -0
  51. package/dist/esm/QueryBuilder/types.js.map +1 -0
  52. package/dist/esm/TimePicker/TimePicker.js.map +1 -1
  53. package/dist/esm/Typography/Typography.js +2 -1
  54. package/dist/esm/Typography/Typography.js.map +1 -1
  55. package/dist/esm/index.js +194 -190
  56. package/dist/esm/index.js.map +1 -1
  57. package/dist/types/index.d.ts +388 -322
  58. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"Operator.js","sources":["../../../../../src/QueryBuilder/Rule/Operator/Operator.tsx"],"sourcesContent":["import { memo, useMemo } from \"react\";\n\nimport { HvDropdown } from \"../../../Dropdown\";\n\nimport { useQueryBuilderContext } from \"../../Context\";\nimport { isBigList } from \"../../utils\";\n\nexport interface OperatorProps {\n id: React.Key;\n combinator: string;\n attribute: string;\n operator?: string;\n}\n\nexport const Operator = ({\n id,\n combinator,\n attribute,\n operator,\n}: OperatorProps) => {\n const { dispatchAction, attributes, operators, labels, readOnly } =\n useQueryBuilderContext();\n\n const value = operator ?? null;\n\n const values = useMemo(() => {\n const attributeSpec =\n attribute && attributes ? attributes[attribute] : null;\n const options = attributeSpec\n ? operators[attributeSpec.type].filter((o) =>\n o.combinators.includes(combinator)\n ) ?? []\n : [];\n return options.map((key) => ({\n id: key.operator,\n label: key.label,\n selected: key.operator === value,\n }));\n }, [attribute, attributes, operators, combinator, value]);\n\n return (\n <HvDropdown\n required\n status=\"valid\"\n singleSelectionToggle={false}\n label={labels.rule.operator.label}\n placeholder={labels.rule.operator.placeholder}\n values={values}\n disabled={values.length === 0}\n readOnly={readOnly}\n onChange={(selected) => {\n if (selected && !Array.isArray(selected) && selected.id) {\n dispatchAction({\n type: \"set-operator\",\n id,\n operator: selected.id.toString(),\n value:\n value === \"range\" ||\n selected.id === \"range\" ||\n selected.id === \"IsNotEmpty\" ||\n selected.id === \"Empty\"\n ? null\n : undefined,\n });\n } else {\n dispatchAction({\n type: \"set-operator\",\n id,\n operator: null,\n value: null,\n });\n }\n }}\n showSearch={isBigList(values)}\n {...(isBigList(values) && { virtualized: true, height: 300 })}\n />\n );\n};\n\nexport default memo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YAAY,UAAU,MAAM;AAAA,MAC3B,GAAI,UAAU,MAAM,KAAK,EAAE,aAAa,MAAM,QAAQ,IAAI;AAAA,IAAA;AAAA,EAAA;AAGjE;AAEe,KAAK,QAAQ;"}
1
+ {"version":3,"file":"Operator.js","sources":["../../../../../src/QueryBuilder/Rule/Operator/Operator.tsx"],"sourcesContent":["import { memo, useMemo } from \"react\";\n\nimport { HvDropdown } from \"../../../Dropdown\";\n\nimport { useQueryBuilderContext } from \"../../Context\";\nimport { isBigList } from \"../../utils\";\n\nexport interface OperatorProps {\n id: React.Key;\n combinator: string;\n attribute: string;\n operator?: string;\n}\n\nexport const Operator = ({\n id,\n combinator,\n attribute,\n operator,\n}: OperatorProps) => {\n const { dispatchAction, attributes, operators, labels, readOnly } =\n useQueryBuilderContext();\n\n const value = operator ?? null;\n\n const values = useMemo(() => {\n const attributeSpec =\n attribute && attributes ? attributes[attribute] : null;\n const options = attributeSpec\n ? operators[attributeSpec.type].filter((o) =>\n o.combinators.includes(combinator)\n ) ?? []\n : [];\n return options.map((key) => ({\n id: key.operator,\n label: key.label,\n selected: key.operator === value,\n }));\n }, [attribute, attributes, operators, combinator, value]);\n\n return (\n <HvDropdown\n required\n status=\"valid\"\n singleSelectionToggle={false}\n label={labels.rule.operator.label}\n placeholder={labels.rule.operator.placeholder}\n values={values}\n disabled={values.length === 0}\n readOnly={readOnly}\n onChange={(selected) => {\n if (selected && !Array.isArray(selected) && selected.id) {\n dispatchAction({\n type: \"set-operator\",\n id,\n operator: selected.id.toString(),\n value:\n value === \"range\" || selected.id === \"range\" ? null : undefined,\n });\n } else {\n dispatchAction({\n type: \"set-operator\",\n id,\n operator: null,\n value: null,\n });\n }\n }}\n showSearch={isBigList(values)}\n {...(isBigList(values) && { virtualized: true, height: 300 })}\n />\n );\n};\n\nexport default memo(Operator);\n"],"names":[],"mappings":";;;;;AAcO,MAAM,WAAW,CAAC;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAqB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@ -48,7 +48,6 @@ const Rule = (props) => {
48
48
  }
49
49
  return -1;
50
50
  }, [attribute, attributes, combinator, operators]);
51
- const shouldShowValueInput = operator !== "Empty" && operator !== "IsNotEmpty";
52
51
  return /* @__PURE__ */ jsxs(
53
52
  HvGrid,
54
53
  {
@@ -74,7 +73,7 @@ const Rule = (props) => {
74
73
  operator
75
74
  }
76
75
  ) }),
77
- attribute != null && (operator != null || availableOperators === 0) && /* @__PURE__ */ jsx(HvGrid, { item: true, xs: 12, md: true, children: shouldShowValueInput && /* @__PURE__ */ jsx(
76
+ attribute != null && (operator != null || availableOperators === 0) && /* @__PURE__ */ jsx(HvGrid, { item: true, xs: 12, md: true, children: /* @__PURE__ */ jsx(
78
77
  Value,
79
78
  {
80
79
  attribute,
@@ -1 +1 @@
1
- {"version":3,"file":"Rule.js","sources":["../../../../src/QueryBuilder/Rule/Rule.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { Delete } from \"@hitachivantara/uikit-react-icons\";\nimport { useTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\n\nimport { HvGrid } from \"../../Grid\";\nimport { IconButton } from \"../../utils/IconButton\";\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { ExtractNames } from \"../../utils/classes\";\n\nimport { useQueryBuilderContext } from \"../Context\";\nimport { Attribute } from \"./Attribute\";\nimport { Operator } from \"./Operator\";\nimport { Value } from \"./Value\";\nimport { staticClasses, useClasses } from \"./Rule.styles\";\n\nexport { staticClasses as queryBuilderRuleClasses };\n\nexport type HvQueryBuilderRuleClasses = ExtractNames<typeof useClasses>;\n\nexport interface RuleProps {\n id: React.Key;\n combinator: string;\n attribute?: string;\n operator?: string;\n value?: any;\n disabled?: boolean;\n isInvalid: boolean;\n classes?: HvQueryBuilderRuleClasses;\n}\n\nexport const Rule = (props: RuleProps) => {\n const {\n id,\n combinator,\n attribute,\n operator,\n value,\n disabled,\n isInvalid,\n classes: classesProp,\n } = useDefaultProps(\"HvQueryBuilderRule\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const {\n askAction,\n dispatchAction,\n attributes,\n operators,\n labels,\n readOnly,\n disableConfirmation,\n } = useQueryBuilderContext();\n\n const theme = useTheme();\n\n const isMdDown = useMediaQuery(theme.breakpoints.down(\"md\"));\n\n const availableOperators = useMemo(() => {\n const attributeSpec =\n attribute != null && attributes ? attributes[attribute] : null;\n if (attributeSpec != null) {\n const typeOperators = operators[attributeSpec.type];\n if (typeOperators != null) {\n return typeOperators.reduce(\n (count, item) =>\n count + (item.combinators.includes(combinator) ? 1 : 0),\n 0\n );\n }\n }\n\n return -1;\n }, [attribute, attributes, combinator, operators]);\n\n const shouldShowValueInput =\n operator !== \"Empty\" && operator !== \"IsNotEmpty\";\n\n return (\n <HvGrid\n container\n className={cx(classes.root, { [classes.isMdDown]: isMdDown })}\n spacing={0}\n >\n <HvGrid item xs={12} md={3}>\n <Attribute\n attribute={attribute}\n id={id}\n disabled={disabled}\n isInvalid={isInvalid}\n />\n </HvGrid>\n {attribute != null && availableOperators > 0 && (\n <HvGrid item xs={12} md={3}>\n <Operator\n id={id}\n combinator={combinator}\n attribute={attribute}\n operator={operator}\n />\n </HvGrid>\n )}\n {attribute != null && (operator != null || availableOperators === 0) && (\n <HvGrid item xs={12} md>\n {shouldShowValueInput && (\n <Value\n attribute={attribute}\n id={id}\n operator={operator}\n value={value}\n />\n )}\n </HvGrid>\n )}\n <HvGrid item className={classes.actionsContainer}>\n <IconButton\n placement=\"bottom\"\n title={labels.rule.delete.tooltip || labels.rule.delete.ariaLabel}\n onClick={() =>\n disableConfirmation\n ? dispatchAction({ type: \"remove-node\", id })\n : askAction({\n actions: [{ type: \"remove-node\", id }],\n dialog: labels.rule.delete,\n })\n }\n disabled={readOnly}\n >\n <Delete role=\"none\" />\n </IconButton>\n </HvGrid>\n </HvGrid>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA+Ba,MAAA,OAAO,CAAC,UAAqB;A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AAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UAAA;AAAA,QAAA,GAEJ;AAAA,QAED,aAAa,SAAS,YAAY,QAAQ,uBAAuB,MAChE,oBAAC,QAAO,EAAA,MAAI,MAAC,IAAI,IAAI,IAAE,MACpB,UACC,wBAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UAAA;AAAA,QAAA,GAGN;AAAA,4BAED,QAAO,EAAA,MAAI,MAAC,WAAW,QAAQ,kBAC9B,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,OAAO,OAAO,KAAK,OAAO,WAAW,OAAO,KAAK,OAAO;AAAA,YACxD,SAAS,MACP,sBACI,eAAe,EAAE,MAAM,eAAe,IAAI,IAC1C,UAAU;AAAA,cACR,SAAS,CAAC,EAAE,MAAM,eAAe,IAAI;AAAA,cACrC,QAAQ,OAAO,KAAK;AAAA,YAAA,CACrB;AAAA,YAEP,UAAU;AAAA,YAEV,UAAA,oBAAC,QAAO,EAAA,MAAK,OAAO,CAAA;AAAA,UAAA;AAAA,QAAA,GAExB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"Rule.js","sources":["../../../../src/QueryBuilder/Rule/Rule.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { Delete } from \"@hitachivantara/uikit-react-icons\";\nimport { useTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\n\nimport { HvGrid } from \"../../Grid\";\nimport { IconButton } from \"../../utils/IconButton\";\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { ExtractNames } from \"../../utils/classes\";\n\nimport { useQueryBuilderContext } from \"../Context\";\nimport { Attribute } from \"./Attribute\";\nimport { Operator } from \"./Operator\";\nimport { Value } from \"./Value\";\nimport { staticClasses, useClasses } from \"./Rule.styles\";\n\nexport { staticClasses as queryBuilderRuleClasses };\n\nexport type HvQueryBuilderRuleClasses = ExtractNames<typeof useClasses>;\n\nexport interface RuleProps {\n id: React.Key;\n combinator: string;\n attribute?: string;\n operator?: string;\n value?: any;\n disabled?: boolean;\n isInvalid: boolean;\n classes?: HvQueryBuilderRuleClasses;\n}\n\nexport const Rule = (props: RuleProps) => {\n const {\n id,\n combinator,\n attribute,\n operator,\n value,\n disabled,\n isInvalid,\n classes: classesProp,\n } = useDefaultProps(\"HvQueryBuilderRule\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const {\n askAction,\n dispatchAction,\n attributes,\n operators,\n labels,\n readOnly,\n disableConfirmation,\n } = useQueryBuilderContext();\n\n const theme = useTheme();\n\n const isMdDown = useMediaQuery(theme.breakpoints.down(\"md\"));\n\n const availableOperators = useMemo(() => {\n const attributeSpec =\n attribute != null && attributes ? attributes[attribute] : null;\n if (attributeSpec != null) {\n const typeOperators = operators[attributeSpec.type];\n if (typeOperators != null) {\n return typeOperators.reduce(\n (count, item) =>\n count + (item.combinators.includes(combinator) ? 1 : 0),\n 0\n );\n }\n }\n\n return -1;\n }, [attribute, attributes, combinator, operators]);\n\n return (\n <HvGrid\n container\n className={cx(classes.root, { [classes.isMdDown]: isMdDown })}\n spacing={0}\n >\n <HvGrid item xs={12} md={3}>\n <Attribute\n attribute={attribute}\n id={id}\n disabled={disabled}\n isInvalid={isInvalid}\n />\n </HvGrid>\n {attribute != null && availableOperators > 0 && (\n <HvGrid item xs={12} md={3}>\n <Operator\n id={id}\n combinator={combinator}\n attribute={attribute}\n operator={operator}\n />\n </HvGrid>\n )}\n {attribute != null && (operator != null || availableOperators === 0) && (\n <HvGrid item xs={12} md>\n <Value\n attribute={attribute}\n id={id}\n operator={operator}\n value={value}\n />\n </HvGrid>\n )}\n <HvGrid item className={classes.actionsContainer}>\n <IconButton\n placement=\"bottom\"\n title={labels.rule.delete.tooltip || labels.rule.delete.ariaLabel}\n onClick={() =>\n disableConfirmation\n ? dispatchAction({ type: \"remove-node\", id })\n : askAction({\n actions: [{ type: \"remove-node\", id }],\n dialog: labels.rule.delete,\n })\n }\n disabled={readOnly}\n >\n <Delete role=\"none\" />\n </IconButton>\n </HvGrid>\n </HvGrid>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA+Ba,MAAA,OAAO,CAAC,UAAqB;AAClC,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,EAAA,IACP,gBAAgB,sBAAsB,KAAK;AAE/C,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAExC,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,uBAAuB;AAE3B,QAAM,QAAQ;AAEd,QAAM,WAAW,cAAc,MAAM,YAAY,KAAK,IAAI,CAAC;AAErD,QAAA,qBAAqB,QAAQ,MAAM;AACvC,UAAM,gBACJ,aAAa,QAAQ,aAAa,WAAW,SAAS,IAAI;AAC5D,QAAI,iBAAiB,MAAM;AACnB,YAAA,gBAAgB,UAAU,cAAc,IAAI;AAClD,UAAI,iBAAiB,MAAM;AACzB,eAAO,cAAc;AAAA,UACnB,CAAC,OAAO,SACN,SAAS,KAAK,YAAY,SAAS,UAAU,IAAI,IAAI;AAAA,UACvD;AAAA,QAAA;AAAA,MAEJ;AAAA,IACF;AAEO,WAAA;AAAA,KACN,CAAC,WAAW,YAAY,YAAY,SAAS,CAAC;AAG/C,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAS;AAAA,MACT,WAAW,GAAG,QAAQ,MAAM,EAAE,CAAC,QAAQ,QAAQ,GAAG,UAAU;AAAA,MAC5D,SAAS;AAAA,MAET,UAAA;AAAA,QAAA,oBAAC,UAAO,MAAI,MAAC,IAAI,IAAI,IAAI,GACvB,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UAAA;AAAA,QAAA,GAEJ;AAAA,QACC,aAAa,QAAQ,qBAAqB,KACzC,oBAAC,QAAO,EAAA,MAAI,MAAC,IAAI,IAAI,IAAI,GACvB,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UAAA;AAAA,QAAA,GAEJ;AAAA,QAED,aAAa,SAAS,YAAY,QAAQ,uBAAuB,MAC/D,oBAAA,QAAA,EAAO,MAAI,MAAC,IAAI,IAAI,IAAE,MACrB,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UAAA;AAAA,QAAA,GAEJ;AAAA,4BAED,QAAO,EAAA,MAAI,MAAC,WAAW,QAAQ,kBAC9B,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,OAAO,OAAO,KAAK,OAAO,WAAW,OAAO,KAAK,OAAO;AAAA,YACxD,SAAS,MACP,sBACI,eAAe,EAAE,MAAM,eAAe,IAAI,IAC1C,UAAU;AAAA,cACR,SAAS,CAAC,EAAE,MAAM,eAAe,IAAI;AAAA,cACrC,QAAQ,OAAO,KAAK;AAAA,YAAA,CACrB;AAAA,YAEP,UAAU;AAAA,YAEV,UAAA,oBAAC,QAAO,EAAA,MAAK,OAAO,CAAA;AAAA,UAAA;AAAA,QAAA,GAExB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -48,7 +48,7 @@ const { useClasses, staticClasses } = createClasses(
48
48
  "&>div:not(:last-child)": {
49
49
  paddingRight: 0
50
50
  },
51
- "&>div:not(:first-child)": {
51
+ "&>div:not(:first-of-type)": {
52
52
  marginTop: theme.space.xs
53
53
  }
54
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Rule.styles.js","sources":["../../../../src/QueryBuilder/Rule/Rule.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../../utils/classes\";\n\nimport { staticClasses as queryBuilderClasses } from \"../QueryBuilder.styles\";\n\nexport const { useClasses, staticClasses } = createClasses(\n \"HvQueryBuilder-Rule\",\n {\n root: {\n position: \"relative\",\n marginTop: theme.space.xs,\n minHeight: 94,\n\n \"&>div:not(:last-child)\": {\n paddingRight: theme.space.md,\n },\n\n // hide required * as all fields are required\n \"& label>span[aria-hidden]\": {\n visibility: \"hidden\",\n },\n\n \"&::before\": {\n content: '\"\"',\n position: \"absolute\",\n zIndex: 2,\n\n width: \"17px\",\n height: \"39px\",\n\n borderBottom: `1px solid ${theme.colors.atmo4}`,\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n\n top: 0,\n left: `calc(-1 * 17px)`,\n },\n\n [`:not(.${queryBuilderClasses.topRulesContainer})>&:last-child::after`]: {\n content: '\"\"',\n position: \"absolute\",\n zIndex: 1,\n\n width: \"17px\",\n height: \"100%\",\n\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n\n top: 0,\n left: `calc(-1 * 17px)`,\n },\n },\n actionsContainer: {\n marginLeft: \"auto\",\n marginTop: \"24px\",\n\n \"&>:not(:last-child)\": {\n marginRight: theme.space.xs,\n },\n },\n isMdDown: {\n \"&>div:not(:last-child)\": {\n paddingRight: 0,\n },\n \"&>div:not(:first-child)\": {\n marginTop: theme.space.xs,\n },\n },\n }\n);\n"],"names":["queryBuilderClasses"],"mappings":";;;AAMa,MAAA,EAAE,YAAY,cAAA,IAAkB;AAAA,EAC3C;AAAA,EACA;AAAA,IACE,MAAM;AAAA,MACJ,UAAU;AAAA,MACV,WAAW,MAAM,MAAM;AAAA,MACvB,WAAW;AAAA,MAEX,0BAA0B;AAAA,QACxB,cAAc,MAAM,MAAM;AAAA,MAC5B;AAAA;AAAA,MAGA,6BAA6B;AAAA,QAC3B,YAAY;AAAA,MACd;AAAA,MAEA,aAAa;AAAA,QACX,SAAS;AAAA,QACT,UAAU;AAAA,QACV,QAAQ;AAAA,QAER,OAAO;AAAA,QACP,QAAQ;AAAA,QAER,cAAc,aAAa,MAAM,OAAO,KAAK;AAAA,QAC7C,YAAY,aAAa,MAAM,OAAO,KAAK;AAAA,QAE3C,KAAK;AAAA,QACL,MAAM;AAAA,MACR;AAAA,MAEA,CAAC,SAASA,gBAAoB,iBAAiB,uBAAuB,GAAG;AAAA,QACvE,SAAS;AAAA,QACT,UAAU;AAAA,QACV,QAAQ;AAAA,QAER,OAAO;AAAA,QACP,QAAQ;AAAA,QAER,YAAY,aAAa,MAAM,OAAO,KAAK;AAAA,QAE3C,KAAK;AAAA,QACL,MAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,kBAAkB;AAAA,MAChB,YAAY;AAAA,MACZ,WAAW;AAAA,MAEX,uBAAuB;AAAA,QACrB,aAAa,MAAM,MAAM;AAAA,MAC3B;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,0BAA0B;AAAA,QACxB,cAAc;AAAA,MAChB;AAAA,MACA,2BAA2B;AAAA,QACzB,WAAW,MAAM,MAAM;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"Rule.styles.js","sources":["../../../../src/QueryBuilder/Rule/Rule.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../../utils/classes\";\n\nimport { staticClasses as queryBuilderClasses } from \"../QueryBuilder.styles\";\n\nexport const { useClasses, staticClasses } = createClasses(\n \"HvQueryBuilder-Rule\",\n {\n root: {\n position: \"relative\",\n marginTop: theme.space.xs,\n minHeight: 94,\n\n \"&>div:not(:last-child)\": {\n paddingRight: theme.space.md,\n },\n\n // hide required * as all fields are required\n \"& label>span[aria-hidden]\": {\n visibility: \"hidden\",\n },\n\n \"&::before\": {\n content: '\"\"',\n position: \"absolute\",\n zIndex: 2,\n\n width: \"17px\",\n height: \"39px\",\n\n borderBottom: `1px solid ${theme.colors.atmo4}`,\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n\n top: 0,\n left: `calc(-1 * 17px)`,\n },\n\n [`:not(.${queryBuilderClasses.topRulesContainer})>&:last-child::after`]: {\n content: '\"\"',\n position: \"absolute\",\n zIndex: 1,\n\n width: \"17px\",\n height: \"100%\",\n\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n\n top: 0,\n left: `calc(-1 * 17px)`,\n },\n },\n actionsContainer: {\n marginLeft: \"auto\",\n marginTop: \"24px\",\n\n \"&>:not(:last-child)\": {\n marginRight: theme.space.xs,\n },\n },\n isMdDown: {\n \"&>div:not(:last-child)\": {\n paddingRight: 0,\n },\n \"&>div:not(:first-of-type)\": {\n marginTop: theme.space.xs,\n },\n },\n }\n);\n"],"names":["queryBuilderClasses"],"mappings":";;;AAMa,MAAA,EAAE,YAAY,cAAA,IAAkB;AAAA,EAC3C;AAAA,EACA;AAAA,IACE,MAAM;AAAA,MACJ,UAAU;AAAA,MACV,WAAW,MAAM,MAAM;AAAA,MACvB,WAAW;AAAA,MAEX,0BAA0B;AAAA,QACxB,cAAc,MAAM,MAAM;AAAA,MAC5B;AAAA;AAAA,MAGA,6BAA6B;AAAA,QAC3B,YAAY;AAAA,MACd;AAAA,MAEA,aAAa;AAAA,QACX,SAAS;AAAA,QACT,UAAU;AAAA,QACV,QAAQ;AAAA,QAER,OAAO;AAAA,QACP,QAAQ;AAAA,QAER,cAAc,aAAa,MAAM,OAAO,KAAK;AAAA,QAC7C,YAAY,aAAa,MAAM,OAAO,KAAK;AAAA,QAE3C,KAAK;AAAA,QACL,MAAM;AAAA,MACR;AAAA,MAEA,CAAC,SAASA,gBAAoB,iBAAiB,uBAAuB,GAAG;AAAA,QACvE,SAAS;AAAA,QACT,UAAU;AAAA,QACV,QAAQ;AAAA,QAER,OAAO;AAAA,QACP,QAAQ;AAAA,QAER,YAAY,aAAa,MAAM,OAAO,KAAK;AAAA,QAE3C,KAAK;AAAA,QACL,MAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,kBAAkB;AAAA,MAChB,YAAY;AAAA,MACZ,WAAW;AAAA,MAEX,uBAAuB;AAAA,QACrB,aAAa,MAAM,MAAM;AAAA,MAC3B;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,0BAA0B;AAAA,QACxB,cAAc;AAAA,MAChB;AAAA,MACA,6BAA6B;AAAA,QAC3B,WAAW,MAAM,MAAM;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AACF;"}
@@ -0,0 +1,17 @@
1
+ import { useEffect } from "react";
2
+ import { useQueryBuilderContext } from "../../../Context.js";
3
+ const EmptyValue = ({ id }) => {
4
+ const { dispatchAction } = useQueryBuilderContext();
5
+ useEffect(() => {
6
+ dispatchAction({
7
+ type: "set-value",
8
+ id,
9
+ value: null
10
+ });
11
+ }, [dispatchAction, id]);
12
+ return null;
13
+ };
14
+ export {
15
+ EmptyValue
16
+ };
17
+ //# sourceMappingURL=EmptyValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptyValue.js","sources":["../../../../../../src/QueryBuilder/Rule/Value/EmptyValue/EmptyValue.tsx"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { useQueryBuilderContext } from \"../../../Context\";\n\nexport interface EmptyValueProps {\n id: React.Key;\n}\n\nexport const EmptyValue = ({ id }: EmptyValueProps) => {\n const { dispatchAction } = useQueryBuilderContext();\n\n // Clear value on first render\n useEffect(() => {\n dispatchAction({\n type: \"set-value\",\n id,\n value: null,\n });\n }, [dispatchAction, id]);\n\n return null;\n};\n"],"names":[],"mappings":";;AAQO,MAAM,aAAa,CAAC,EAAE,SAA0B;AAC/C,QAAA,EAAE,mBAAmB;AAG3B,YAAU,MAAM;AACC,mBAAA;AAAA,MACb,MAAM;AAAA,MACN;AAAA,MACA,OAAO;AAAA,IAAA,CACR;AAAA,EAAA,GACA,CAAC,gBAAgB,EAAE,CAAC;AAEhB,SAAA;AACT;"}
@@ -1,20 +1,44 @@
1
1
  import { jsx } from "@emotion/react/jsx-runtime";
2
2
  import { memo } from "react";
3
3
  import { useQueryBuilderContext } from "../../Context.js";
4
+ import { defaultRendererKey } from "../../types.js";
5
+ import { EmptyValue } from "./EmptyValue/EmptyValue.js";
4
6
  import { TextValue } from "./TextValue/TextValue.js";
5
7
  import { DateTimeValue } from "./DateTimeValue/DateTimeValue.js";
6
8
  import { NumericValue } from "./NumericValue/NumericValue.js";
7
9
  import { BooleanValue } from "./BooleanValue/BooleanValue.js";
10
+ const getRenderer = (renderer, operator) => (
11
+ // 1. Custom renderer
12
+ typeof renderer === "function" && renderer || // 2. Custom operator renderer
13
+ typeof renderer === "object" && operator && renderer[operator] || // 3. Custom DEFAULT renderer
14
+ typeof renderer === "object" && renderer[defaultRendererKey]
15
+ );
8
16
  const Value = ({
9
17
  id,
10
18
  attribute,
11
19
  operator,
12
20
  value: valueProp
13
21
  }) => {
14
- const { attributes, initialTouched, renderers } = useQueryBuilderContext();
15
- const value = attribute && attributes ? { ...attributes[attribute] } : { type: null };
16
- const { type } = value;
17
- switch (type) {
22
+ const { attributes, initialTouched, renderers, emptyRenderer } = useQueryBuilderContext();
23
+ const attrType = attribute && attributes ? attributes[attribute].type : void 0;
24
+ if (emptyRenderer?.find((op) => op === operator)) {
25
+ return /* @__PURE__ */ jsx(EmptyValue, { id });
26
+ }
27
+ if (attrType && renderers?.[attrType]) {
28
+ const Renderer = getRenderer(renderers[attrType], operator) || getRenderer(renderers[defaultRendererKey], operator) || void 0;
29
+ if (Renderer) {
30
+ return /* @__PURE__ */ jsx(
31
+ Renderer,
32
+ {
33
+ id,
34
+ attribute,
35
+ operator,
36
+ value: valueProp
37
+ }
38
+ );
39
+ }
40
+ }
41
+ switch (attrType) {
18
42
  case "boolean": {
19
43
  return /* @__PURE__ */ jsx(BooleanValue, { id, value: !!valueProp });
20
44
  }
@@ -42,22 +66,8 @@ const Value = ({
42
66
  }
43
67
  case "text":
44
68
  case "textarea":
69
+ default:
45
70
  return /* @__PURE__ */ jsx(TextValue, { id, value: valueProp, initialTouched });
46
- default: {
47
- if (type && renderers?.[type]) {
48
- const Renderer = renderers[type];
49
- return /* @__PURE__ */ jsx(
50
- Renderer,
51
- {
52
- id,
53
- attribute,
54
- operator,
55
- value: valueProp
56
- }
57
- );
58
- }
59
- return /* @__PURE__ */ jsx(TextValue, { id, value: valueProp, initialTouched });
60
- }
61
71
  }
62
72
  };
63
73
  memo(Value);
@@ -1 +1 @@
1
- {"version":3,"file":"Value.js","sources":["../../../../../src/QueryBuilder/Rule/Value/Value.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { useQueryBuilderContext } from \"../../Context\";\nimport { BooleanValue } from \"./BooleanValue\";\nimport { NumericValue } from \"./NumericValue\";\nimport { TextValue } from \"./TextValue\";\nimport { DateTimeValue } from \"./DateTimeValue\";\n\nexport interface ValueProps {\n id: React.Key;\n attribute: string;\n operator?: string;\n value?: any;\n}\n\nexport const Value = ({\n id,\n attribute,\n operator,\n value: valueProp,\n}: ValueProps) => {\n const { attributes, initialTouched, renderers } = useQueryBuilderContext();\n\n const value =\n attribute && attributes ? { ...attributes[attribute] } : { type: null };\n const { type } = value;\n\n switch (type) {\n case \"boolean\": {\n return <BooleanValue id={id} value={!!valueProp} />;\n }\n case \"numeric\": {\n return (\n <NumericValue\n id={id}\n operator={operator}\n value={valueProp}\n initialTouched={initialTouched}\n />\n );\n }\n case \"dateandtime\": {\n return (\n <DateTimeValue\n id={id}\n operator={operator}\n value={valueProp}\n initialTouched={initialTouched}\n />\n );\n }\n case \"text\":\n case \"textarea\":\n return (\n <TextValue id={id} value={valueProp} initialTouched={initialTouched} />\n );\n default: {\n if (type && renderers?.[type]) {\n const Renderer = renderers[type];\n\n return (\n <Renderer\n id={id}\n attribute={attribute}\n operator={operator}\n value={valueProp}\n />\n );\n }\n\n return (\n <TextValue id={id} value={valueProp} initialTouched={initialTouched} />\n );\n }\n }\n};\n\nexport default memo(Value);\n"],"names":[],"mappings":";;;;;;;AAeO,MAAM,QAAQ,CAAC;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AACT,MAAkB;AAChB,QAAM,EAAE,YAAY,gBAAgB,cAAc,uBAAuB;AAEnE,QAAA,QACJ,aAAa,aAAa,EAAE,GAAG,WAAW,SAAS,MAAM,EAAE,MAAM;AAC7D,QAAA,EAAE,KAAS,IAAA;AAEjB,UAAQ,MAAM;AAAA,IACZ,KAAK,WAAW;AACd,iCAAQ,cAAa,EAAA,IAAQ,OAAO,CAAC,CAAC,UAAW,CAAA;AAAA,IACnD;AAAA,IACA,KAAK,WAAW;AAEZ,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA,OAAO;AAAA,UACP;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN;AAAA,IACA,KAAK,eAAe;AAEhB,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA,OAAO;AAAA,UACP;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN;AAAA,IACA,KAAK;AAAA,IACL,KAAK;AACH,aACG,oBAAA,WAAA,EAAU,IAAQ,OAAO,WAAW,eAAgC,CAAA;AAAA,IAEzE,SAAS;AACH,UAAA,QAAQ,YAAY,IAAI,GAAG;AACvB,cAAA,WAAW,UAAU,IAAI;AAG7B,eAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA,OAAO;AAAA,UAAA;AAAA,QAAA;AAAA,MAGb;AAEA,aACG,oBAAA,WAAA,EAAU,IAAQ,OAAO,WAAW,eAAgC,CAAA;AAAA,IAEzE;AAAA,EACF;AACF;AAEe,KAAK,KAAK;"}
1
+ {"version":3,"file":"Value.js","sources":["../../../../../src/QueryBuilder/Rule/Value/Value.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { useQueryBuilderContext } from \"../../Context\";\nimport { BooleanValue } from \"./BooleanValue\";\nimport { NumericValue } from \"./NumericValue\";\nimport { TextValue } from \"./TextValue\";\nimport { DateTimeValue } from \"./DateTimeValue\";\nimport {\n HvQueryBuilderRendererProps,\n ValueRenderer,\n defaultRendererKey,\n} from \"../../types\";\nimport { EmptyValue } from \"./EmptyValue\";\n\nexport interface ValueProps {\n id: React.Key;\n attribute: string;\n operator?: string;\n value?: any;\n}\n\nconst getRenderer = (renderer: ValueRenderer, operator?: string) =>\n // 1. Custom renderer\n (typeof renderer === \"function\" && renderer) ||\n // 2. Custom operator renderer\n (typeof renderer === \"object\" && operator && renderer[operator]) ||\n // 3. Custom DEFAULT renderer\n (typeof renderer === \"object\" && renderer[defaultRendererKey]);\n\nexport const Value = ({\n id,\n attribute,\n operator,\n value: valueProp,\n}: ValueProps) => {\n const { attributes, initialTouched, renderers, emptyRenderer } =\n useQueryBuilderContext();\n\n const attrType =\n attribute && attributes ? attributes[attribute].type : undefined;\n\n // Empty value renderer\n if (emptyRenderer?.find((op) => op === operator)) {\n return <EmptyValue id={id} />;\n }\n\n // Custom renderer\n if (attrType && renderers?.[attrType]) {\n // Renderer to be used by order:\n // 1. Custom attribute renderer\n // 2. Custom attribute-operator renderer\n // 3. Custom attribute-DEFAULT renderer\n // 4. Custom master DEFAULT renderer\n // 5. Custom master DEFAULT-operator renderer\n // 6. Custom master DEFAULT-DEFAULT renderer\n const Renderer: React.FC<HvQueryBuilderRendererProps> | undefined =\n getRenderer(renderers[attrType], operator) ||\n getRenderer(renderers[defaultRendererKey], operator) ||\n undefined;\n\n if (Renderer) {\n return (\n <Renderer\n id={id}\n attribute={attribute}\n operator={operator}\n value={valueProp}\n />\n );\n }\n }\n\n // Built-in attributes\n switch (attrType) {\n case \"boolean\": {\n return <BooleanValue id={id} value={!!valueProp} />;\n }\n case \"numeric\": {\n return (\n <NumericValue\n id={id}\n operator={operator}\n value={valueProp}\n initialTouched={initialTouched}\n />\n );\n }\n case \"dateandtime\": {\n return (\n <DateTimeValue\n id={id}\n operator={operator}\n value={valueProp}\n initialTouched={initialTouched}\n />\n );\n }\n case \"text\":\n case \"textarea\":\n default:\n return (\n <TextValue id={id} value={valueProp} initialTouched={initialTouched} />\n );\n }\n};\n\nexport default memo(Value);\n"],"names":[],"mappings":";;;;;;;;;AAqBA,MAAM,cAAc,CAAC,UAAyB;AAAA;AAAA,EAE3C,OAAO,aAAa,cAAc;AAAA,EAElC,OAAO,aAAa,YAAY,YAAY,SAAS,QAAQ;AAAA,EAE7D,OAAO,aAAa,YAAY,SAAS,kBAAkB;AAAA;AAEvD,MAAM,QAAQ,CAAC;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AACT,MAAkB;AAChB,QAAM,EAAE,YAAY,gBAAgB,WAAW,cAAA,IAC7C;AAEF,QAAM,WACJ,aAAa,aAAa,WAAW,SAAS,EAAE,OAAO;AAGzD,MAAI,eAAe,KAAK,CAAC,OAAO,OAAO,QAAQ,GAAG;AACzC,WAAA,oBAAC,cAAW,GAAQ,CAAA;AAAA,EAC7B;AAGI,MAAA,YAAY,YAAY,QAAQ,GAAG;AAQrC,UAAM,WACJ,YAAY,UAAU,QAAQ,GAAG,QAAQ,KACzC,YAAY,UAAU,kBAAkB,GAAG,QAAQ,KACnD;AAEF,QAAI,UAAU;AAEV,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA,OAAO;AAAA,QAAA;AAAA,MAAA;AAAA,IAGb;AAAA,EACF;AAGA,UAAQ,UAAU;AAAA,IAChB,KAAK,WAAW;AACd,iCAAQ,cAAa,EAAA,IAAQ,OAAO,CAAC,CAAC,UAAW,CAAA;AAAA,IACnD;AAAA,IACA,KAAK,WAAW;AAEZ,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA,OAAO;AAAA,UACP;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN;AAAA,IACA,KAAK,eAAe;AAEhB,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA,OAAO;AAAA,UACP;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN;AAAA,IACA,KAAK;AAAA,IACL,KAAK;AAAA,IACL;AACE,aACG,oBAAA,WAAA,EAAU,IAAQ,OAAO,WAAW,eAAgC,CAAA;AAAA,EAE3E;AACF;AAEe,KAAK,KAAK;"}
@@ -164,6 +164,7 @@ const RuleGroup = ({
164
164
  dispatchAction({ type: "add-rule", id });
165
165
  },
166
166
  className: classes.createConditionButton,
167
+ disabled: readOnly,
167
168
  children: `${labels.empty?.createCondition}`
168
169
  }
169
170
  ),
@@ -178,6 +179,7 @@ const RuleGroup = ({
178
179
  dispatchAction({ type: "add-group", id });
179
180
  },
180
181
  className: classes.createGroupButton,
182
+ disabled: readOnly,
181
183
  children: `${labels.empty?.createGroup}`
182
184
  }
183
185
  )
@@ -1 +1 @@
1
- {"version":3,"file":"RuleGroup.js","sources":["../../../../src/QueryBuilder/RuleGroup/RuleGroup.tsx"],"sourcesContent":["import { useCallback } from \"react\";\nimport { Add, Delete, Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"../../Button\";\nimport { HvEmptyState } from \"../../EmptyState\";\nimport { HvMultiButton } from \"../../MultiButton\";\nimport { HvTypography } from \"../../Typography\";\nimport { IconButton } from \"../../utils/IconButton\";\nimport { ExtractNames } from \"../../utils/classes\";\n\nimport { Rule } from \"../Rule\";\nimport { useQueryBuilderContext } from \"../Context\";\nimport { useClasses } from \"../QueryBuilder.styles\";\nimport { HvQueryBuilderQuery, HvQueryBuilderQueryCombinator } from \"../types\";\n\nexport interface RuleGroupProps {\n id: React.Key;\n level?: number;\n combinator?: string;\n rules?: HvQueryBuilderQuery[\"rules\"];\n classes?: ExtractNames<typeof useClasses>;\n}\n\nexport const RuleGroup = ({\n level = 0,\n id,\n combinator = \"and\",\n rules = [],\n classes: classesProp,\n}: RuleGroupProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const {\n dispatchAction,\n askAction,\n maxDepth,\n combinators,\n labels,\n readOnly,\n disableConfirmation,\n } = useQueryBuilderContext();\n\n const normalizedMaxDepth = maxDepth - 1;\n\n const actionButtons = (\n <>\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addRule?.label != null\n ? labels.query?.addRule?.label\n : labels.group.addRule.label}\n </HvButton>\n </div>\n {level <= normalizedMaxDepth && (\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addGroup?.label != null\n ? labels.query?.addGroup?.label\n : labels.group.addGroup.label}\n </HvButton>\n </div>\n )}\n </>\n );\n\n const onClickCombinator = useCallback(\n (item: HvQueryBuilderQueryCombinator) => {\n dispatchAction({\n type: \"set-combinator\",\n id,\n combinator: item.operand,\n });\n },\n [dispatchAction, id]\n );\n\n return (\n <div\n className={cx(classes.root, {\n [classes.topGroup]: level === 0,\n [classes.subGroup]: level > 0,\n })}\n >\n <HvMultiButton\n className={cx(classes.combinator, classes.topCombinator)}\n disabled={readOnly}\n >\n {combinators?.map((item) => (\n <HvButton\n key={item.operand}\n className={classes.combinatorButton}\n selected={item.operand === combinator}\n onClick={() => item.operand && onClickCombinator(item)}\n disabled={readOnly}\n size=\"xs\"\n >\n {item.label}\n </HvButton>\n ))}\n </HvMultiButton>\n <div className={cx(classes.buttonBackground, classes.topRemoveButton)}>\n <IconButton\n className={classes.removeButton}\n onClick={() =>\n disableConfirmation\n ? dispatchAction({ type: \"remove-node\", id })\n : askAction({\n actions: [{ type: \"remove-node\", id }],\n dialog:\n level === 0 && labels.query?.delete != null\n ? labels.query.delete\n : labels.group.delete,\n })\n }\n title={\n (level === 0 && labels.query?.delete?.tooltip) ||\n labels.group.delete.tooltip ||\n (level === 0 && labels.query?.delete?.ariaLabel) ||\n labels.group.delete.ariaLabel\n }\n disabled={readOnly}\n >\n <Delete\n role=\"none\"\n className={cx({ [classes.topRemoveButtonDisabled]: readOnly })}\n />\n </IconButton>\n </div>\n {rules?.length > 0 && (\n <div\n className={cx(classes.rulesContainer, {\n [classes.subRulesContainer]: level > 0,\n [classes.topRulesContainer]: level === 0,\n })}\n >\n {rules.map((rule, index) => {\n if (\"combinator\" in rule) {\n return (\n <RuleGroup\n key={rule.id}\n level={level + 1}\n {...rule}\n id={rule.id}\n classes={classes}\n />\n );\n }\n\n const isInvalid =\n combinator === \"and\" &&\n rules.some((r, i) => {\n if (\"attribute\" in r) {\n if (\n r.attribute === rule.attribute &&\n r.id !== rule.id &&\n i < index\n ) {\n return true;\n }\n }\n return false;\n });\n\n return (\n <Rule\n key={rule.id}\n {...rule}\n isInvalid={isInvalid}\n id={rule.id}\n combinator={combinator}\n />\n );\n })}\n </div>\n )}\n {rules?.length === 0 && (\n <HvEmptyState\n title={labels.empty?.title}\n message={\n <>\n <HvTypography\n link\n component=\"button\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n className={classes.createConditionButton}\n >\n {`${labels.empty?.createCondition}`}\n </HvTypography>\n {level <= normalizedMaxDepth && (\n <>\n {`${labels.empty?.spacer}`}\n <HvTypography\n link\n component=\"button\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n className={classes.createGroupButton}\n >\n {`${labels.empty?.createGroup}`}\n </HvTypography>\n </>\n )}\n </>\n }\n icon={<Info />}\n />\n )}\n <div\n className={cx(\n classes.actionButtonContainer,\n classes.topActionButtonContainer\n )}\n >\n {actionButtons}\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAuBO,MAAM,YAAY,CAAC;AAAA,EACxB,QAAQ;AAAA,EACR;AAAA,EACA,aAAa;AAAA,EACb,QAAQ,CAAC;AAAA,EACT,SAAS;AACX,MAAsB;AACpB,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW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AA,EAAA,UAAA;AAAA,gBAAG,GAAA,OAAO,OAAO,MAAM;AAAA,gBACxB;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,MAAI;AAAA,oBACJ,WAAU;AAAA,oBACV,SAAS,MAAM;AACb,qCAAe,EAAE,MAAM,aAAa,GAAI,CAAA;AAAA,oBAC1C;AAAA,oBACA,WAAW,QAAQ;AAAA,oBAElB,UAAA,GAAG,OAAO,OAAO,WAAW;AAAA,kBAAA;AAAA,gBAC/B;AAAA,cAAA,GACF;AAAA,YAAA,GAEJ;AAAA,YAEF,0BAAO,MAAK,EAAA;AAAA,UAAA;AAAA,QACd;AAAA,QAEF;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,cACT,QAAQ;AAAA,cACR,QAAQ;AAAA,YACV;AAAA,YAEC,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"RuleGroup.js","sources":["../../../../src/QueryBuilder/RuleGroup/RuleGroup.tsx"],"sourcesContent":["import { useCallback } from \"react\";\nimport { Add, Delete, Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"../../Button\";\nimport { HvEmptyState } from \"../../EmptyState\";\nimport { HvMultiButton } from \"../../MultiButton\";\nimport { HvTypography } from \"../../Typography\";\nimport { IconButton } from \"../../utils/IconButton\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { Rule } from \"../Rule\";\nimport { useQueryBuilderContext } from \"../Context\";\nimport { useClasses } from \"../QueryBuilder.styles\";\nimport { HvQueryBuilderQuery, HvQueryBuilderQueryCombinator } from \"../types\";\n\nexport interface RuleGroupProps {\n id: React.Key;\n level?: number;\n combinator?: string;\n rules?: HvQueryBuilderQuery[\"rules\"];\n classes?: ExtractNames<typeof useClasses>;\n}\n\nexport const RuleGroup = ({\n level = 0,\n id,\n combinator = \"and\",\n rules = [],\n classes: classesProp,\n}: RuleGroupProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const {\n dispatchAction,\n askAction,\n maxDepth,\n combinators,\n labels,\n readOnly,\n disableConfirmation,\n } = useQueryBuilderContext();\n\n const normalizedMaxDepth = maxDepth - 1;\n\n const actionButtons = (\n <>\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addRule?.label != null\n ? labels.query?.addRule?.label\n : labels.group.addRule.label}\n </HvButton>\n </div>\n {level <= normalizedMaxDepth && (\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addGroup?.label != null\n ? labels.query?.addGroup?.label\n : labels.group.addGroup.label}\n </HvButton>\n </div>\n )}\n </>\n );\n\n const onClickCombinator = useCallback(\n (item: HvQueryBuilderQueryCombinator) => {\n dispatchAction({\n type: \"set-combinator\",\n id,\n combinator: item.operand,\n });\n },\n [dispatchAction, id]\n );\n\n return (\n <div\n className={cx(classes.root, {\n [classes.topGroup]: level === 0,\n [classes.subGroup]: level > 0,\n })}\n >\n <HvMultiButton\n className={cx(classes.combinator, classes.topCombinator)}\n disabled={readOnly}\n >\n {combinators?.map((item) => (\n <HvButton\n key={item.operand}\n className={classes.combinatorButton}\n selected={item.operand === combinator}\n onClick={() => item.operand && onClickCombinator(item)}\n disabled={readOnly}\n size=\"xs\"\n >\n {item.label}\n </HvButton>\n ))}\n </HvMultiButton>\n <div className={cx(classes.buttonBackground, classes.topRemoveButton)}>\n <IconButton\n className={classes.removeButton}\n onClick={() =>\n disableConfirmation\n ? dispatchAction({ type: \"remove-node\", id })\n : askAction({\n actions: [{ type: \"remove-node\", id }],\n dialog:\n level === 0 && labels.query?.delete != null\n ? labels.query.delete\n : labels.group.delete,\n })\n }\n title={\n (level === 0 && labels.query?.delete?.tooltip) ||\n labels.group.delete.tooltip ||\n (level === 0 && labels.query?.delete?.ariaLabel) ||\n labels.group.delete.ariaLabel\n }\n disabled={readOnly}\n >\n <Delete\n role=\"none\"\n className={cx({ [classes.topRemoveButtonDisabled]: readOnly })}\n />\n </IconButton>\n </div>\n {rules?.length > 0 && (\n <div\n className={cx(classes.rulesContainer, {\n [classes.subRulesContainer]: level > 0,\n [classes.topRulesContainer]: level === 0,\n })}\n >\n {rules.map((rule, index) => {\n if (\"combinator\" in rule) {\n return (\n <RuleGroup\n key={rule.id}\n level={level + 1}\n {...rule}\n id={rule.id}\n classes={classes}\n />\n );\n }\n\n const isInvalid =\n combinator === \"and\" &&\n rules.some((r, i) => {\n if (\"attribute\" in r) {\n if (\n r.attribute === rule.attribute &&\n r.id !== rule.id &&\n i < index\n ) {\n return true;\n }\n }\n return false;\n });\n\n return (\n <Rule\n key={rule.id}\n {...rule}\n isInvalid={isInvalid}\n id={rule.id}\n combinator={combinator}\n />\n );\n })}\n </div>\n )}\n {rules?.length === 0 && (\n <HvEmptyState\n title={labels.empty?.title}\n message={\n <>\n <HvTypography\n link\n component=\"button\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n className={classes.createConditionButton}\n disabled={readOnly}\n >\n {`${labels.empty?.createCondition}`}\n </HvTypography>\n {level <= normalizedMaxDepth && (\n <>\n {`${labels.empty?.spacer}`}\n <HvTypography\n link\n component=\"button\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n className={classes.createGroupButton}\n disabled={readOnly}\n >\n {`${labels.empty?.createGroup}`}\n </HvTypography>\n </>\n )}\n </>\n }\n icon={<Info />}\n />\n )}\n <div\n className={cx(\n classes.actionButtonContainer,\n classes.topActionButtonContainer\n )}\n >\n {actionButtons}\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAsBO,MAAM,YAAY,CAAC;AAAA,EACxB,QAAQ;AAAA,EACR;AAAA,EACA,aAAa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AAA,kBACnB,UAAU;AAAA,kBAET,UAAA,GAAG,OAAO,OAAO,eAAe;AAAA,gBAAA;AAAA,cACnC;AAAA,cACC,SAAS,sBAEL,qBAAA,UAAA,EAAA,UAAA;AAAA,gBAAG,GAAA,OAAO,OAAO,MAAM;AAAA,gBACxB;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,MAAI;AAAA,oBACJ,WAAU;AAAA,oBACV,SAAS,MAAM;AACb,qCAAe,EAAE,MAAM,aAAa,GAAI,CAAA;AAAA,oBAC1C;AAAA,oBACA,WAAW,QAAQ;AAAA,oBACnB,UAAU;AAAA,oBAET,UAAA,GAAG,OAAO,OAAO,WAAW;AAAA,kBAAA;AAAA,gBAC/B;AAAA,cAAA,GACF;AAAA,YAAA,GAEJ;AAAA,YAEF,0BAAO,MAAK,EAAA;AAAA,UAAA;AAAA,QACd;AAAA,QAEF;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,cACT,QAAQ;AAAA,cACR,QAAQ;AAAA,YACV;AAAA,YAEC,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -0,0 +1,5 @@
1
+ const defaultRendererKey = "DEFAULT";
2
+ export {
3
+ defaultRendererKey
4
+ };
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../src/QueryBuilder/types.ts"],"sourcesContent":["export const defaultRendererKey = \"DEFAULT\";\n\nconst defaultAttributes = [\n \"boolean\",\n \"numeric\",\n \"dateandtime\",\n \"text\",\n \"textarea\",\n] as const;\ntype DefaultAttributes = (typeof defaultAttributes)[number];\n\nexport interface HvQueryBuilderAttribute extends Record<string, unknown> {\n id?: string;\n label: string;\n type: DefaultAttributes | (string & {});\n}\n\nexport interface HvQueryBuilderNumericRange {\n from: number | string;\n to: number | string;\n}\n\nexport interface HvQueryBuilderDateTimeStrings {\n date?: string;\n time?: string;\n}\n\nexport interface HvQueryBuilderDateTimeRange {\n start?: HvQueryBuilderDateTimeStrings;\n end?: HvQueryBuilderDateTimeStrings;\n}\n\nexport type HvQueryBuilderQueryRuleValue =\n | string\n | number\n | boolean\n | HvQueryBuilderNumericRange\n | HvQueryBuilderDateTimeStrings\n | HvQueryBuilderDateTimeRange;\n\nexport interface HvQueryBuilderQueryRule {\n id: React.Key;\n attribute?: string;\n operator?: string;\n value?: HvQueryBuilderQueryRuleValue;\n}\n\nexport interface HvQueryBuilderQueryGroup {\n id: React.Key;\n combinator: string;\n rules: Array<HvQueryBuilderQueryRule | HvQueryBuilderQueryGroup>;\n}\n\nexport type HvQueryBuilderQuery = HvQueryBuilderQueryGroup;\n\nexport interface HvQueryBuilderChangedQuery\n extends Omit<HvQueryBuilderQuery, \"id\" | \"rules\"> {\n rules: Array<\n Omit<HvQueryBuilderQueryRule, \"id\"> | HvQueryBuilderChangedQuery\n >;\n}\n\nexport interface HvQueryBuilderQueryCombinator {\n operand: string;\n label: string;\n}\n\nexport interface HvQueryBuilderQueryOperator {\n operator: string;\n label: string;\n combinators: string[];\n}\n\ninterface DialogLabels {\n dialogTitle: string;\n dialogMessage: string;\n dialogConfirm: string;\n dialogCancel: string;\n dialogCloseTooltip: string;\n}\n\n/** @private label structure action icon buttons */\ninterface ActionIconLabels extends DialogLabels {\n // TODO: remove in v6 - duplicated labels - `tooltip` *is* the aria-label\n /** @deprecated use `tooltip` label instead */\n ariaLabel: string;\n tooltip?: string;\n}\n\nexport type QueryAction =\n | {\n type: \"reset-query\";\n }\n | {\n type: \"reset-group\";\n id: React.Key;\n }\n | {\n type: \"add-rule\" | \"add-group\" | \"remove-node\";\n id: React.Key;\n }\n | {\n type: \"set-combinator\";\n id: React.Key;\n combinator: string;\n }\n | {\n type: \"set-attribute\";\n id: React.Key;\n attribute?: string | null;\n operator?: string | null;\n value?: HvQueryBuilderQueryRuleValue | null;\n }\n | {\n type: \"set-operator\";\n id: React.Key;\n operator: string | null;\n value?: HvQueryBuilderQueryRuleValue | null;\n }\n | {\n type: \"set-value\";\n id: React.Key;\n value: HvQueryBuilderQueryRuleValue | null | any;\n };\n\nexport interface AskAction {\n actions: QueryAction[];\n dialog: DialogLabels;\n}\n\nexport interface HvQueryBuilderLabels {\n query?: {\n delete?: ActionIconLabels;\n addRule?: {\n label: string;\n };\n addGroup?: {\n label: string;\n };\n };\n rule: {\n attribute: {\n exists: string;\n label: string;\n placeholder: string;\n };\n operator: {\n label: string;\n placeholder: string;\n };\n value: {\n distance: {\n label: string;\n placeholder?: string;\n connectorText: string;\n button: string;\n validation: {\n required: string;\n invalid: string;\n };\n };\n text: {\n label: string;\n placeholder: string;\n validation: {\n required: string;\n };\n };\n boolean: {\n label: string;\n placeholder: string;\n options: Record<string, string>;\n };\n numeric: {\n label: string;\n placeholder: string;\n validation: {\n required: string;\n invalid: string;\n equal: string;\n greaterThan: string;\n };\n range: {\n leftLabel: string;\n rightLabel: string;\n };\n };\n datetime: {\n dateLabel: string;\n datePlaceholder: string;\n timeLabel: string;\n timePlaceholder: string;\n startDateLabel: string;\n startDatePlaceholder: string;\n startTimeLabel: string;\n startTimePlaceholder: string;\n endDateLabel: string;\n endDatePlaceholder: string;\n endTimeLabel: string;\n endTimePlaceholder: string;\n validation: {\n required: string;\n invalidInterval: string;\n };\n };\n };\n delete: ActionIconLabels;\n };\n group: {\n delete: ActionIconLabels;\n reset: ActionIconLabels;\n addRule: {\n label: string;\n };\n addGroup: {\n label: string;\n };\n };\n empty: {\n title: string;\n createCondition: string;\n createGroup: string;\n spacer: string;\n };\n}\n\nexport interface HvQueryBuilderRendererProps<V = any> {\n id: React.Key;\n attribute: string;\n operator?: string;\n value?: V;\n}\n\nexport type ValueRenderer =\n | React.FC<HvQueryBuilderRendererProps>\n | Record<string, React.FC<HvQueryBuilderRendererProps>>;\n\nexport type HvQueryBuilderRenderers = Record<string, ValueRenderer>;\n"],"names":[],"mappings":"AAAO,MAAM,qBAAqB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TimePicker.js","sources":["../../../src/TimePicker/TimePicker.tsx"],"sourcesContent":["import { useState, useRef, useMemo, forwardRef } from \"react\";\n\nimport { Time } from \"@internationalized/date\";\n\nimport { useForkRef } from \"@mui/material/utils\";\n\nimport { useTimeField } from \"@react-aria/datepicker\";\nimport {\n TimeFieldStateOptions,\n useTimeFieldState,\n} from \"@react-stately/datepicker\";\n\nimport { Time as TimeIcon } from \"@hitachivantara/uikit-react-icons\";\n\nimport {\n HvFormElement,\n HvLabel,\n HvWarningText,\n HvInfoMessage,\n HvFormElementProps,\n} from \"../Forms\";\nimport { HvBaseDropdown, HvBaseDropdownProps } from \"../BaseDropdown\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { setId } from \"../utils/setId\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\n\nimport { Unit } from \"./Unit\";\nimport { Placeholder } from \"./Placeholder\";\nimport { staticClasses, useClasses } from \"./TimePicker.styles\";\n\nconst toTime = (value?: HvTimePickerValue) => {\n if (!value) return undefined;\n const { hours, minutes, seconds } = value;\n return new Time(hours, minutes, seconds);\n};\n\nconst getFormat = (timeFormat?: TimeFormat) => {\n if (timeFormat == null) return 24;\n return timeFormat === \"12\" ? 12 : 24;\n};\n\nexport { staticClasses as timePickerClasses };\n\nexport type TimeFormat = \"12\" | \"24\";\n\nexport type HvTimePickerClasses = ExtractNames<typeof useClasses>;\n\nexport type HvTimePickerClassKey =\n | \"root\"\n | \"input\"\n | \"label\"\n | \"placeholder\"\n | \"timePopperContainer\"\n | \"separator\"\n | \"periodContainer\"\n | \"formElementRoot\"\n | \"dropdownPlaceholder\"\n | \"iconBaseRoot\"\n | \"error\"\n | \"labelContainer\"\n | \"description\"\n | \"dropdownHeaderInvalid\"\n | \"dropdownPlaceholderDisabled\"\n | \"dropdownHeaderOpen\";\n\nexport type HvTimePickerValue = {\n hours: number;\n minutes: number;\n seconds: number;\n};\n\nexport interface HvTimePickerProps\n extends Omit<\n HvFormElementProps,\n \"classes\" | \"value\" | \"defaultValue\" | \"onChange\" | \"onFocus\" | \"onBlur\"\n > {\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTimePickerClasses;\n /** Current value of the element when _controlled_. Follows the 24-hour format. */\n value?: HvTimePickerValue;\n /** Initial value of the element when _uncontrolled_. Follows the 24-hour format. */\n defaultValue?: HvTimePickerValue;\n /** The placeholder value when no time is selected. */\n placeholder?: string;\n /** The placeholder of the hours input. */\n hoursPlaceholder?: string;\n /** The placeholder of the minutes input. */\n minutesPlaceholder?: string;\n /** The placeholder of the seconds input. */\n secondsPlaceholder?: string;\n /**\n * Whether the time picker should show the AM/PM 12-hour clock or the 24-hour one.\n * If undefined, the component will use a format according to the passed locale.\n */\n timeFormat?: TimeFormat;\n /** Whether to show the seconds when using the native time picker */\n showSeconds?: boolean;\n /** Locale that will provide the time format(12 or 24 hour format). It is \"overwritten\" by `showAmPm` */\n locale?: string;\n /** Whether the dropdown is expandable. */\n disableExpand?: boolean;\n /**\n * Callback function to be triggered when the input value is changed.\n * It is invoked with a `{hours, minutes, seconds}` object, always in the 24h format\n */\n onChange?: (value: HvTimePickerValue) => void;\n /** Callback called when dropdown changes the expanded state. */\n onToggle?: (event: Event, isOpen: boolean) => void;\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Sets if the calendar container should follow the date picker input out of the screen or stay visible. */\n escapeWithReference?: boolean;\n /** Extra properties to be passed to the TimePicker's dropdown. */\n dropdownProps?: Partial<HvBaseDropdownProps>;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n}\n\n/**\n * A Time Picker allows the user to choose a specific time or a time range.\n */\nexport const HvTimePicker = forwardRef<HTMLDivElement, HvTimePickerProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n\n id: idProp,\n name,\n required = false,\n disabled = false,\n readOnly = false,\n label,\n\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n placeholder,\n hoursPlaceholder = \"hh\",\n minutesPlaceholder = \"mm\",\n secondsPlaceholder = \"ss\",\n\n value: valueProp,\n defaultValue: defaultValueProp,\n\n timeFormat,\n showSeconds,\n disableExpand,\n locale = \"en\",\n\n onToggle,\n onChange,\n\n // misc properties:\n disablePortal = true,\n escapeWithReference = true,\n dropdownProps = {},\n ...others\n } = useDefaultProps(\"HvTimePicker\", props);\n\n const id = useUniqueId(idProp, \"hvtimepicker\");\n\n const { classes, cx } = useClasses(classesProp);\n\n const timeFieldRef = useRef<HTMLDivElement>(null);\n\n const { ref: refProp, ...otherDropdownProps } = dropdownProps;\n const dropdownForkedRef = useForkRef(ref, refProp);\n\n const stateProps: TimeFieldStateOptions = {\n value: toTime(valueProp),\n defaultValue: toTime(defaultValueProp),\n label,\n locale,\n isRequired: required,\n isReadOnly: readOnly,\n isDisabled: disabled,\n granularity: \"second\",\n hourCycle: getFormat(timeFormat),\n onChange: (value) => {\n const { hour: hours, minute: minutes, second: seconds } = value;\n onChange?.({ hours, minutes, seconds });\n },\n };\n const state = useTimeFieldState(stateProps);\n const { labelProps, fieldProps, descriptionProps } = useTimeField(\n {\n ...stateProps,\n id,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n },\n state,\n timeFieldRef\n );\n\n const [open, setOpen] = useState(false);\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n const [validationState] = useControlled(status, \"standBy\");\n\n const placeholders = useMemo(\n () => ({\n hour: hoursPlaceholder,\n minute: minutesPlaceholder,\n second: secondsPlaceholder,\n }),\n [hoursPlaceholder, minutesPlaceholder, secondsPlaceholder]\n );\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isStateInvalid = validationState === \"invalid\";\n const errorMessageId = isStateInvalid\n ? canShowError\n ? setId(id, \"error\")\n : ariaErrorMessage\n : undefined;\n\n return (\n <HvFormElement\n name={name}\n required={required}\n disabled={disabled}\n status={validationState}\n className={cx(classes.root, className)}\n {...others}\n >\n {(label || description) && (\n <div className={classes.labelContainer}>\n {label && (\n <HvLabel\n label={label}\n className={classes.label}\n {...labelProps}\n />\n )}\n {description && (\n <HvInfoMessage\n className={classes.description}\n {...descriptionProps}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n\n <HvBaseDropdown\n ref={dropdownForkedRef}\n role=\"combobox\"\n variableWidth\n disabled={disabled}\n readOnly={readOnly}\n placeholder={\n placeholder && !state.value ? (\n placeholder\n ) : (\n <Placeholder\n ref={timeFieldRef}\n name={name}\n state={state}\n placeholders={placeholders}\n className={cx(classes.placeholder, {\n [classes.placeholderDisabled]: disabled,\n })}\n {...fieldProps}\n />\n )\n }\n classes={{\n header: cx(classes.dropdownHeader, {\n [classes.dropdownHeaderInvalid]: isStateInvalid,\n }),\n panel: classes.dropdownPanel,\n headerOpen: classes.dropdownHeaderOpen,\n }}\n placement=\"right\"\n adornment={\n <TimeIcon\n color={disabled ? \"secondary_60\" : undefined}\n className={classes.icon}\n />\n }\n expanded={open}\n onToggle={(evt, newOpen) => {\n if (disableExpand) return;\n setOpen(newOpen);\n onToggle?.(evt, newOpen);\n }}\n onContainerCreation={(containerRef) => {\n containerRef?.getElementsByTagName(\"input\")[0]?.focus();\n }}\n aria-haspopup=\"dialog\"\n aria-label={ariaLabel}\n aria-labelledby={fieldProps[\"aria-labelledby\"]}\n aria-describedby={fieldProps[\"aria-describedby\"]}\n aria-invalid={isStateInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n disablePortal={disablePortal}\n popperProps={{\n modifiers: [\n { name: \"preventOverflow\", enabled: escapeWithReference },\n ],\n }}\n {...otherDropdownProps}\n >\n <div ref={timeFieldRef} className={classes.timePopperContainer}>\n {state.segments.map((segment, i) => (\n <Unit\n key={i}\n state={state}\n segment={segment}\n placeholder={placeholders[segment.type]}\n onAdd={() => state.increment(segment.type)}\n onSub={() => state.decrement(segment.type)}\n onChange={(evt, val) => {\n state.setSegment(segment.type, Number(val));\n }}\n />\n ))}\n </div>\n </HvBaseDropdown>\n\n {canShowError && (\n <HvWarningText\n id={setId(id, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["Time","TimeIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,SAAS,CAAC,UAA8B;AAC5C,MAAI,CAAC;AAAc,WAAA;AACnB,QAAM,EAAE,OAAO,SAAS,QAAA,IAAY;AACpC,SAAO,IAAIA,OAAK,OAAO,SAAS,OAAO;AACzC;AAEA,MAAM,YAAY,CAAC,eAA4B;AAC7C,MAAI,cAAc;AAAa,WAAA;AACxB,SAAA,eAAe,OAAO,KAAK;AACpC;AA2FO,MAAM,eAAe;AAAA,EAC1B,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ,SAAS;AAAA,MACT;AAAA,MAEA,IAAI;AAAA,MACJ;AAAA,MACA,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX;AAAA,MAEA,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB;AAAA,MACA,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,MACA,qBAAqB;AAAA,MAErB;AAAA,MACA,mBAAmB;AAAA,MACnB,qBAAqB;AAAA,MACrB,qBAAqB;AAAA,MAErB,OAAO;AAAA,MACP,cAAc;AAAA,MAEd;AAAA,MACA;AA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,cACC,IAAI,MAAM,IAAI,OAAO;AAAA,cACrB,eAAa;AAAA,cACb,WAAW,QAAQ;AAAA,cAElB,UAAA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;"}
1
+ {"version":3,"file":"TimePicker.js","sources":["../../../src/TimePicker/TimePicker.tsx"],"sourcesContent":["import { useState, useRef, useMemo, forwardRef } from \"react\";\n\nimport { Time } from \"@internationalized/date\";\n\nimport { useForkRef } from \"@mui/material/utils\";\n\nimport { useTimeField } from \"@react-aria/datepicker\";\nimport {\n TimeFieldStateOptions,\n useTimeFieldState,\n} from \"@react-stately/datepicker\";\n\nimport { Time as TimeIcon } from \"@hitachivantara/uikit-react-icons\";\n\nimport {\n HvFormElement,\n HvLabel,\n HvWarningText,\n HvInfoMessage,\n HvFormElementProps,\n} from \"../Forms\";\nimport { HvBaseDropdown, HvBaseDropdownProps } from \"../BaseDropdown\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { setId } from \"../utils/setId\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\n\nimport { Unit } from \"./Unit\";\nimport { Placeholder } from \"./Placeholder\";\nimport { staticClasses, useClasses } from \"./TimePicker.styles\";\n\nconst toTime = (value?: HvTimePickerValue) => {\n if (!value) return undefined;\n const { hours, minutes, seconds } = value;\n return new Time(hours, minutes, seconds);\n};\n\nconst getFormat = (timeFormat?: TimeFormat) => {\n if (timeFormat == null) return 24;\n return timeFormat === \"12\" ? 12 : 24;\n};\n\nexport { staticClasses as timePickerClasses };\n\nexport type TimeFormat = \"12\" | \"24\";\n\nexport type HvTimePickerClasses = ExtractNames<typeof useClasses>;\n\nexport type HvTimePickerClassKey =\n | \"root\"\n | \"input\"\n | \"label\"\n | \"placeholder\"\n | \"timePopperContainer\"\n | \"separator\"\n | \"periodContainer\"\n | \"formElementRoot\"\n | \"dropdownPlaceholder\"\n | \"iconBaseRoot\"\n | \"error\"\n | \"labelContainer\"\n | \"description\"\n | \"dropdownHeaderInvalid\"\n | \"dropdownPlaceholderDisabled\"\n | \"dropdownHeaderOpen\";\n\nexport type HvTimePickerValue = {\n hours: number;\n minutes: number;\n seconds: number;\n};\n\nexport interface HvTimePickerProps\n extends Omit<\n HvFormElementProps,\n \"classes\" | \"value\" | \"defaultValue\" | \"onChange\"\n > {\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTimePickerClasses;\n /** Current value of the element when _controlled_. Follows the 24-hour format. */\n value?: HvTimePickerValue;\n /** Initial value of the element when _uncontrolled_. Follows the 24-hour format. */\n defaultValue?: HvTimePickerValue;\n /** The placeholder value when no time is selected. */\n placeholder?: string;\n /** The placeholder of the hours input. */\n hoursPlaceholder?: string;\n /** The placeholder of the minutes input. */\n minutesPlaceholder?: string;\n /** The placeholder of the seconds input. */\n secondsPlaceholder?: string;\n /**\n * Whether the time picker should show the AM/PM 12-hour clock or the 24-hour one.\n * If undefined, the component will use a format according to the passed locale.\n */\n timeFormat?: TimeFormat;\n /** Whether to show the seconds when using the native time picker */\n showSeconds?: boolean;\n /** Locale that will provide the time format(12 or 24 hour format). It is \"overwritten\" by `showAmPm` */\n locale?: string;\n /** Whether the dropdown is expandable. */\n disableExpand?: boolean;\n /**\n * Callback function to be triggered when the input value is changed.\n * It is invoked with a `{hours, minutes, seconds}` object, always in the 24h format\n */\n onChange?: (value: HvTimePickerValue) => void;\n /** Callback called when dropdown changes the expanded state. */\n onToggle?: (event: Event, isOpen: boolean) => void;\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Sets if the calendar container should follow the date picker input out of the screen or stay visible. */\n escapeWithReference?: boolean;\n /** Extra properties to be passed to the TimePicker's dropdown. */\n dropdownProps?: Partial<HvBaseDropdownProps>;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n}\n\n/**\n * A Time Picker allows the user to choose a specific time or a time range.\n */\nexport const HvTimePicker = forwardRef<HTMLDivElement, HvTimePickerProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n\n id: idProp,\n name,\n required = false,\n disabled = false,\n readOnly = false,\n label,\n\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n placeholder,\n hoursPlaceholder = \"hh\",\n minutesPlaceholder = \"mm\",\n secondsPlaceholder = \"ss\",\n\n value: valueProp,\n defaultValue: defaultValueProp,\n\n timeFormat,\n showSeconds,\n disableExpand,\n locale = \"en\",\n\n onToggle,\n onChange,\n\n // misc properties:\n disablePortal = true,\n escapeWithReference = true,\n dropdownProps = {},\n ...others\n } = useDefaultProps(\"HvTimePicker\", props);\n\n const id = useUniqueId(idProp, \"hvtimepicker\");\n\n const { classes, cx } = useClasses(classesProp);\n\n const timeFieldRef = useRef<HTMLDivElement>(null);\n\n const { ref: refProp, ...otherDropdownProps } = dropdownProps;\n const dropdownForkedRef = useForkRef(ref, refProp);\n\n const stateProps: TimeFieldStateOptions = {\n value: toTime(valueProp),\n defaultValue: toTime(defaultValueProp),\n label,\n locale,\n isRequired: required,\n isReadOnly: readOnly,\n isDisabled: disabled,\n granularity: \"second\",\n hourCycle: getFormat(timeFormat),\n onChange: (value) => {\n const { hour: hours, minute: minutes, second: seconds } = value;\n onChange?.({ hours, minutes, seconds });\n },\n };\n const state = useTimeFieldState(stateProps);\n const { labelProps, fieldProps, descriptionProps } = useTimeField(\n {\n ...stateProps,\n id,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n },\n state,\n timeFieldRef\n );\n\n const [open, setOpen] = useState(false);\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n const [validationState] = useControlled(status, \"standBy\");\n\n const placeholders = useMemo(\n () => ({\n hour: hoursPlaceholder,\n minute: minutesPlaceholder,\n second: secondsPlaceholder,\n }),\n [hoursPlaceholder, minutesPlaceholder, secondsPlaceholder]\n );\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isStateInvalid = validationState === \"invalid\";\n const errorMessageId = isStateInvalid\n ? canShowError\n ? setId(id, \"error\")\n : ariaErrorMessage\n : undefined;\n\n return (\n <HvFormElement\n name={name}\n required={required}\n disabled={disabled}\n status={validationState}\n className={cx(classes.root, className)}\n {...others}\n >\n {(label || description) && (\n <div className={classes.labelContainer}>\n {label && (\n <HvLabel\n label={label}\n className={classes.label}\n {...labelProps}\n />\n )}\n {description && (\n <HvInfoMessage\n className={classes.description}\n {...descriptionProps}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n\n <HvBaseDropdown\n ref={dropdownForkedRef}\n role=\"combobox\"\n variableWidth\n disabled={disabled}\n readOnly={readOnly}\n placeholder={\n placeholder && !state.value ? (\n placeholder\n ) : (\n <Placeholder\n ref={timeFieldRef}\n name={name}\n state={state}\n placeholders={placeholders}\n className={cx(classes.placeholder, {\n [classes.placeholderDisabled]: disabled,\n })}\n {...fieldProps}\n />\n )\n }\n classes={{\n header: cx(classes.dropdownHeader, {\n [classes.dropdownHeaderInvalid]: isStateInvalid,\n }),\n panel: classes.dropdownPanel,\n headerOpen: classes.dropdownHeaderOpen,\n }}\n placement=\"right\"\n adornment={\n <TimeIcon\n color={disabled ? \"secondary_60\" : undefined}\n className={classes.icon}\n />\n }\n expanded={open}\n onToggle={(evt, newOpen) => {\n if (disableExpand) return;\n setOpen(newOpen);\n onToggle?.(evt, newOpen);\n }}\n onContainerCreation={(containerRef) => {\n containerRef?.getElementsByTagName(\"input\")[0]?.focus();\n }}\n aria-haspopup=\"dialog\"\n aria-label={ariaLabel}\n aria-labelledby={fieldProps[\"aria-labelledby\"]}\n aria-describedby={fieldProps[\"aria-describedby\"]}\n aria-invalid={isStateInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n disablePortal={disablePortal}\n popperProps={{\n modifiers: [\n { name: \"preventOverflow\", enabled: escapeWithReference },\n ],\n }}\n {...otherDropdownProps}\n >\n <div ref={timeFieldRef} className={classes.timePopperContainer}>\n {state.segments.map((segment, i) => (\n <Unit\n key={i}\n state={state}\n segment={segment}\n placeholder={placeholders[segment.type]}\n onAdd={() => state.increment(segment.type)}\n onSub={() => state.decrement(segment.type)}\n onChange={(evt, val) => {\n state.setSegment(segment.type, Number(val));\n }}\n />\n ))}\n </div>\n </HvBaseDropdown>\n\n {canShowError && (\n <HvWarningText\n id={setId(id, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["Time","TimeIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,SAAS,CAAC,UAA8B;AAC5C,MAAI,CAAC;AAAc,WAAA;AACnB,QAAM,EAAE,OAAO,SAAS,QAAA,IAAY;AACpC,SAAO,IAAIA,OAAK,OAAO,SAAS,OAAO;AACzC;AAEA,MAAM,YAAY,CAAC,eAA4B;AAC7C,MAAI,cAAc;AAAa,WAAA;AACxB,SAAA,eAAe,OAAO,KAAK;AACpC;AA2FO,MAAM,eAAe;AAAA,EAC1B,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ,SAAS;AAAA,MACT;AAAA,MAEA,IAAI;AAAA,MACJ;AAAA,MACA,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX;AAAA,MAEA,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB;AAAA,MACA,oBAAoB;AAAA,MACpB;A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AQ,MAAM,OAAO,GAAG,CAAC;AAAA,kBAC5C;AAAA,gBAAA;AAAA,gBARK;AAAA,cAUR,CAAA,GACH;AAAA,YAAA;AAAA,UACF;AAAA,UAEC,gBACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,IAAI,MAAM,IAAI,OAAO;AAAA,cACrB,eAAa;AAAA,cACb,WAAW,QAAQ;AAAA,cAElB,UAAA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;"}
@@ -45,9 +45,9 @@ const HvTypography = forwardRef(
45
45
  classes: classesProp,
46
46
  variant: variantProp = "body",
47
47
  link = false,
48
- disabled = false,
49
48
  noWrap = false,
50
49
  paragraph = false,
50
+ disabled = false,
51
51
  ...others
52
52
  } = useDefaultProps("HvTypography", props);
53
53
  const { classes, cx } = useClasses(classesProp);
@@ -68,6 +68,7 @@ const HvTypography = forwardRef(
68
68
  },
69
69
  className
70
70
  ),
71
+ disabled,
71
72
  ...others
72
73
  }
73
74
  );
@@ -1 +1 @@
1
- {"version":3,"file":"Typography.js","sources":["../../../src/Typography/Typography.tsx"],"sourcesContent":["import { ElementType, forwardRef } from \"react\";\n\nimport { PolymorphicComponentRef, PolymorphicRef } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\n\nimport {\n HvTypographyLegacyVariants,\n HvTypographyVariants,\n mapVariant,\n} from \"./utils\";\nimport { staticClasses, useClasses } from \"./Typography.styles\";\n\nexport { staticClasses as typographyClasses };\n\nexport type HvTypographyClasses = ExtractNames<typeof useClasses>;\n\nconst HvTypographyMap = {\n display: \"h1\",\n title1: \"h1\",\n title2: \"h2\",\n title3: \"h3\",\n title4: \"h4\",\n body: \"p\",\n label: \"span\",\n caption1: \"p\",\n caption2: \"p\",\n // LEGACY\n \"5xlTitle\": \"h1\",\n \"4xlTitle\": \"h1\",\n \"3xlTitle\": \"h1\",\n xxlTitle: \"h1\",\n xlTitle: \"h1\",\n lTitle: \"h2\",\n mTitle: \"h3\",\n sTitle: \"h4\",\n xsTitle: \"h5\",\n xxsTitle: \"h6\",\n sectionTitle: \"p\",\n highlightText: \"p\",\n normalText: \"p\",\n placeholderText: \"p\",\n link: \"p\",\n disabledText: \"p\",\n selectedNavText: \"p\",\n vizText: \"p\",\n vizTextDisabled: \"p\",\n xsInlineLink: \"p\",\n} satisfies Record<\n HvTypographyVariants | HvTypographyLegacyVariants,\n ElementType\n>;\n\nexport type HvTypographyProps<C extends React.ElementType = \"p\"> =\n PolymorphicComponentRef<\n C,\n {\n /** Use the variant prop to change the visual style of the Typography. */\n variant?: HvTypographyVariants | HvTypographyLegacyVariants;\n /** If `true` the typography will display the look of a link. */\n link?: boolean;\n /** If `true` the typography will display the look of a disabled state. */\n disabled?: boolean;\n /** If `true`, the text will have a bottom margin. */\n paragraph?: boolean;\n /**\n * If `true`, the text will not wrap, but instead will truncate with a text overflow ellipsis.\n *\n * Note that text overflow can only happen with block or inline-block level elements\n * (the element needs to have a width in order to overflow).\n */\n noWrap?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTypographyClasses;\n }\n >;\n\n/**\n * Typography component is used to render text and paragraphs within an interface.\n */\nexport const HvTypography: <C extends React.ElementType = \"p\">(\n props: HvTypographyProps<C>\n) => React.ReactElement | null = forwardRef(\n <C extends React.ElementType = \"p\">(\n props: HvTypographyProps<C>,\n ref: PolymorphicRef<C>\n ) => {\n const {\n className,\n component: ComponentProp,\n classes: classesProp,\n variant: variantProp = \"body\",\n link = false,\n disabled = false,\n noWrap = false,\n paragraph = false,\n ...others\n } = useDefaultProps(\"HvTypography\", props);\n const { classes, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const variant = mapVariant(variantProp, activeTheme?.name);\n\n const Component =\n ComponentProp || (paragraph && \"p\") || HvTypographyMap[variant] || \"span\";\n\n return (\n <Component\n ref={ref}\n className={cx(\n classes.root,\n classes[variant],\n {\n [classes.isLink]: link,\n [classes.noWrap]: noWrap,\n [classes.disabled]: disabled,\n },\n className\n )}\n {...others}\n />\n );\n }\n);\n"],"names":[],"mappings":";;;;;;;AAkBA,MAAM,kBAAkB;AAAA,EACtB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AAAA;AAAA,EAEV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,MAAM;AAAA,EACN,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,cAAc;AAChB;AAgCO,MAAM,eAEoB;AAAA,EAC/B,CACE,OACA,QACG;AACG,UAAA;AAAA,MACJ;AAAA,MACA,WAAW;AAAA,MACX,SAAS;AAAA,MACT,SAAS,cAAc;AAAA,MACvB,OAAO;AAAA,MACP,WAAW;AAAA,MACX,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,GAAG;AAAA,IAAA,IACD,gBAAgB,gBAAgB,KAAK;AACzC,UAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AACxC,UAAA,EAAE,gBAAgB;AAExB,UAAM,UAAU,WAAW,aAAa,aAAa,IAAI;AAEzD,UAAM,YACJ,iBAAkB,aAAa,OAAQ,gBAAgB,OAAO,KAAK;AAGnE,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT,QAAQ;AAAA,UACR,QAAQ,OAAO;AAAA,UACf;AAAA,YACE,CAAC,QAAQ,MAAM,GAAG;AAAA,YAClB,CAAC,QAAQ,MAAM,GAAG;AAAA,YAClB,CAAC,QAAQ,QAAQ,GAAG;AAAA,UACtB;AAAA,UACA;AAAA,QACF;AAAA,QACC,GAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;"}
1
+ {"version":3,"file":"Typography.js","sources":["../../../src/Typography/Typography.tsx"],"sourcesContent":["import { ElementType, forwardRef } from \"react\";\n\nimport { PolymorphicComponentRef, PolymorphicRef } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport {\n HvTypographyLegacyVariants,\n HvTypographyVariants,\n mapVariant,\n} from \"./utils\";\nimport { staticClasses, useClasses } from \"./Typography.styles\";\n\nexport { staticClasses as typographyClasses };\n\nexport type HvTypographyClasses = ExtractNames<typeof useClasses>;\n\nconst HvTypographyMap = {\n display: \"h1\",\n title1: \"h1\",\n title2: \"h2\",\n title3: \"h3\",\n title4: \"h4\",\n body: \"p\",\n label: \"span\",\n caption1: \"p\",\n caption2: \"p\",\n // LEGACY\n \"5xlTitle\": \"h1\",\n \"4xlTitle\": \"h1\",\n \"3xlTitle\": \"h1\",\n xxlTitle: \"h1\",\n xlTitle: \"h1\",\n lTitle: \"h2\",\n mTitle: \"h3\",\n sTitle: \"h4\",\n xsTitle: \"h5\",\n xxsTitle: \"h6\",\n sectionTitle: \"p\",\n highlightText: \"p\",\n normalText: \"p\",\n placeholderText: \"p\",\n link: \"p\",\n disabledText: \"p\",\n selectedNavText: \"p\",\n vizText: \"p\",\n vizTextDisabled: \"p\",\n xsInlineLink: \"p\",\n} satisfies Record<\n HvTypographyVariants | HvTypographyLegacyVariants,\n ElementType\n>;\n\nexport type HvTypographyProps<C extends React.ElementType = \"p\"> =\n PolymorphicComponentRef<\n C,\n {\n /** Use the variant prop to change the visual style of the Typography. */\n variant?: HvTypographyVariants | HvTypographyLegacyVariants;\n /** If `true` the typography will display the look of a link. */\n link?: boolean;\n /** If `true` the typography will display the look of a disabled state. */\n disabled?: boolean;\n /** If `true`, the text will have a bottom margin. */\n paragraph?: boolean;\n /**\n * If `true`, the text will not wrap, but instead will truncate with a text overflow ellipsis.\n *\n * Note that text overflow can only happen with block or inline-block level elements\n * (the element needs to have a width in order to overflow).\n */\n noWrap?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTypographyClasses;\n }\n >;\n\n/**\n * Typography component is used to render text and paragraphs within an interface.\n */\nexport const HvTypography: <C extends React.ElementType = \"p\">(\n props: HvTypographyProps<C>\n) => React.ReactElement | null = forwardRef(\n <C extends React.ElementType = \"p\">(\n props: HvTypographyProps<C>,\n ref: PolymorphicRef<C>\n ) => {\n const {\n className,\n component: ComponentProp,\n classes: classesProp,\n variant: variantProp = \"body\",\n link = false,\n noWrap = false,\n paragraph = false,\n disabled = false,\n ...others\n } = useDefaultProps(\"HvTypography\", props);\n const { classes, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const variant = mapVariant(variantProp, activeTheme?.name);\n\n const Component =\n ComponentProp || (paragraph && \"p\") || HvTypographyMap[variant] || \"span\";\n\n return (\n <Component\n ref={ref}\n className={cx(\n classes.root,\n classes[variant],\n {\n [classes.isLink]: link,\n [classes.noWrap]: noWrap,\n [classes.disabled]: disabled,\n },\n className\n )}\n disabled={disabled}\n {...others}\n />\n );\n }\n);\n"],"names":[],"mappings":";;;;;;;AAiBA,MAAM,kBAAkB;AAAA,EACtB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AAAA;AAAA,EAEV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QA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