@trackunit/react-components 0.0.143 → 0.0.146

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,5 +1,7 @@
1
- /// <reference types="react" />
2
- interface PageHeadingProps {
1
+ import { ReactNode } from "react";
2
+ import { CommonProps } from "../../common/CommonProps";
3
+ import "./PageHeading.css";
4
+ export interface PageHeadingProps extends CommonProps {
3
5
  /**
4
6
  * The title of the page.
5
7
  */
@@ -9,16 +11,14 @@ interface PageHeadingProps {
9
11
  */
10
12
  subtitle?: string;
11
13
  /**
12
- * Test id to be used for the component.
14
+ * The addon could be used to tell the state of a pageheading.
13
15
  */
14
- dataTestId?: string;
15
- tag?: string;
16
+ addon?: ReactNode;
16
17
  }
17
18
  /**
18
- * The PageHeading component used on pages.
19
+ * The PageHeading component is used on pages to set the Browser page title.
19
20
  *
20
21
  * @param {PageHeadingProps} props - The props for the PageHeading component
21
22
  * @returns {JSX.Element} PageHeading component
22
23
  */
23
- export declare const PageHeading: ({ title, subtitle, dataTestId, tag }: PageHeadingProps) => JSX.Element;
24
- export {};
24
+ export declare const PageHeading: ({ title, subtitle, dataTestId, addon }: PageHeadingProps) => JSX.Element;
@@ -4,6 +4,7 @@ import { SelectProps } from "./useSelect";
4
4
  export interface SelectOption {
5
5
  label: string;
6
6
  value: string;
7
+ disabled?: boolean;
7
8
  }
8
9
  /**
9
10
  * Selects are input components used to choose a value from a set.
@@ -12,4 +12,4 @@ export declare function isMultiValue<Option>(arg: MultiValue<Option> | SingleVal
12
12
  * @returns {OptionsOrGroups<Option, Group>} An array of ordered options with selected on top
13
13
  */
14
14
  export declare const getOrderedOptions: <Option, Group extends GroupBase<Option>>(options: OptionsOrGroups<Option, Group> | undefined, value: PropsValue<Option> | undefined) => OptionsOrGroups<Option, Group>;
15
- export declare const SelectPrefix: import("tailwind-styled-components/dist/tailwind").TailwindComponent<"div", {}>;
15
+ export declare const SelectPrefix: import("dist/libs/ui/tailwind-styled-components/src/lib/types").TailwindComponent<import("dist/libs/ui/tailwind-styled-components/src/lib/types").TailwindHtmlComponent<"div">, {}>;
package/index.css CHANGED
@@ -211,6 +211,16 @@
211
211
  }
212
212
  }
213
213
 
214
+ .tu-pageheading {
215
+ @apply w-full;
216
+
217
+ &__flex{
218
+ @apply flex
219
+ items-center
220
+ flex-wrap-reverse
221
+ gap-2;
222
+ }
223
+ }
214
224
  /* CSS related to the RadioGroup component */
215
225
  .tu-radiogroup {
216
226
  @apply flex
package/index.js CHANGED
@@ -2234,7 +2234,7 @@ const PopoverListItem = ({
2234
2234
  }, {
2235
2235
  children: url ? jsx(UnstyledAnchor, Object.assign({
2236
2236
  "$as": renderAs,
2237
- to: url
2237
+ href: url
2238
2238
  }, {
2239
2239
  children: content
2240
2240
  })) : content
@@ -3170,100 +3170,7 @@ const Space = tw.div`
3170
3170
  `;
3171
3171
 
3172
3172
  /**
3173
- * The tag component is used to categorize elements in the ui.
3174
- *
3175
- * This could be to tell the state of an asset, or label a page as Beta.
3176
- *
3177
- * The tag is also used in multiselect components to show selected options.
3178
- *
3179
- * **Do:** Use short labels for easy scanning.
3180
- *
3181
- * @param {TagProps} props - The props for the tag component
3182
- * @returns {JSX.Element} tag component
3183
- */
3184
-
3185
- const Tag = React.forwardRef((_a, ref) => {
3186
- var {
3187
- className,
3188
- dataTestId,
3189
- children,
3190
- size = "medium",
3191
- onClose,
3192
- color = "primary"
3193
- } = _a;
3194
- __rest(_a, ["className", "dataTestId", "children", "size", "onClose", "color"]);
3195
-
3196
- return jsxs(StyledText, Object.assign({
3197
- className: className,
3198
- "$size": size,
3199
- "data-testid": `${dataTestId}-tag`,
3200
- "$as": "span",
3201
- "$color": color,
3202
- "$withXIcon": !!onClose,
3203
- ref: ref
3204
- }, {
3205
- children: [children, onClose && // a fix for multiselect deselecting tags working together with fade out animation
3206
- jsx(IconContainer, Object.assign({
3207
- onMouseDown: onClose
3208
- }, {
3209
- children: jsx(Icon$1, {
3210
- name: "XCircleIcon",
3211
- dataTestId: dataTestId + "Icon",
3212
- type: "solid",
3213
- style: {
3214
- WebkitTransition: "-webkit-transform 0.150s"
3215
- },
3216
- className: size === "medium" ? tws`tu-tag__icon` : tws`tu-tag__icon tu-tag__icon--small`
3217
- })
3218
- }))]
3219
- }));
3220
- });
3221
-
3222
- const getSizeModifierClass = () => ({
3223
- $size,
3224
- $withXIcon
3225
- }) => {
3226
- const tagSizeModifierClass = {
3227
- medium: $withXIcon ? tws`tu-tag--with-icon ` : tws` `,
3228
- small: $withXIcon ? tws`tu-tag--small tu-tag--with-icon` : tws`tu-tag--small`
3229
- };
3230
- return tagSizeModifierClass[$size];
3231
- };
3232
-
3233
- const getColorModifierClass = () => ({
3234
- $color
3235
- }) => {
3236
- const colorClasses = {
3237
- primary: tws`tu-tag--primary`,
3238
- secondary: tws`tu-tag--secondary`,
3239
- accent: tws`tu-tag--accent`,
3240
- success: tws`tu-tag--success`,
3241
- danger: tws`tu-tag--danger`,
3242
- warning: tws`tu-tag--warning`,
3243
- info: tws`tu-tag--info`,
3244
- neutral: tws`tu-tag--neutral`,
3245
- good: tws`tu-tag--good`,
3246
- low: tws`tu-tag--low`,
3247
- critical: tws`tu-tag--critical`,
3248
- working: tws`tu-tag--working`,
3249
- idle: tws`tu-tag--idle`,
3250
- stopped: tws`tu-tag--stopped`,
3251
- unknown: tws`tu-tag--unknown`
3252
- };
3253
- return colorClasses[$color];
3254
- };
3255
-
3256
- const StyledText = tw.span`
3257
- tu-tag
3258
- ${getSizeModifierClass()}
3259
- ${getColorModifierClass()}
3260
- `;
3261
- const IconContainer = tw.div`
3262
- tu-tag__icon-container
3263
- `;
3264
-
3265
- /**
3266
- * The PageHeading component used on pages.
3173
+ * The PageHeading component is used on pages to set the Browser page title.
3267
3174
  *
3268
3175
  * @param {PageHeadingProps} props - The props for the PageHeading component
3269
3176
  * @returns {JSX.Element} PageHeading component
@@ -3273,11 +3180,9 @@ const PageHeading = ({
3273
3180
  title,
3274
3181
  subtitle,
3275
3182
  dataTestId,
3276
- tag
3183
+ addon
3277
3184
  }) => {
3278
- return jsxs("div", Object.assign({
3279
- className: "w-full"
3280
- }, {
3185
+ return jsxs(PageHeadingContainer, {
3281
3186
  children: [jsx(Helmet, {
3282
3187
  title: title
3283
3188
  }), jsxs(StyledFlex, {
@@ -3286,11 +3191,7 @@ const PageHeading = ({
3286
3191
  dataTestId: dataTestId
3287
3192
  }, {
3288
3193
  children: title
3289
- })), tag && jsx(Tag, Object.assign({
3290
- color: "primary"
3291
- }, {
3292
- children: tag
3293
- }))]
3194
+ })), addon]
3294
3195
  }), subtitle && jsx(Heading, Object.assign({
3295
3196
  variant: "subtitle",
3296
3197
  subtle: true
@@ -3299,14 +3200,10 @@ const PageHeading = ({
3299
3200
  })), jsx(Spacer, {
3300
3201
  minHeight: "normal"
3301
3202
  })]
3302
- }));
3203
+ });
3303
3204
  };
3304
- const StyledFlex = tw.div`
3305
- flex
3306
- items-center
3307
- flex-wrap-reverse
3308
- gap-2
3309
- `;
3205
+ const PageHeadingContainer = tw.div`tu-pageheading`;
3206
+ const StyledFlex = tw.div`tu-pageheading__flex`;
3310
3207
 
3311
3208
  function useConfirmExit(confirmExit, when = true) {
3312
3209
  const {
@@ -3611,6 +3508,99 @@ const SelectPrefix = tw.div`
3611
3508
  tu-select__prefix
3612
3509
  `;
3613
3510
 
3511
+ /**
3512
+ * The tag component is used to categorize elements in the ui.
3513
+ *
3514
+ * This could be to tell the state of an asset, or label a page as Beta.
3515
+ *
3516
+ * The tag is also used in multiselect components to show selected options.
3517
+ *
3518
+ * **Do:** Use short labels for easy scanning.
3519
+ *
3520
+ * @param {TagProps} props - The props for the tag component
3521
+ * @returns {JSX.Element} tag component
3522
+ */
3523
+
3524
+ const Tag = React.forwardRef((_a, ref) => {
3525
+ var {
3526
+ className,
3527
+ dataTestId,
3528
+ children,
3529
+ size = "medium",
3530
+ onClose,
3531
+ color = "primary"
3532
+ } = _a;
3533
+ __rest(_a, ["className", "dataTestId", "children", "size", "onClose", "color"]);
3534
+
3535
+ return jsxs(StyledText, Object.assign({
3536
+ className: className,
3537
+ "$size": size,
3538
+ "data-testid": `${dataTestId}-tag`,
3539
+ "$as": "span",
3540
+ "$color": color,
3541
+ "$withXIcon": !!onClose,
3542
+ ref: ref
3543
+ }, {
3544
+ children: [children, onClose && // a fix for multiselect deselecting tags working together with fade out animation
3545
+ jsx(IconContainer, Object.assign({
3546
+ onMouseDown: onClose
3547
+ }, {
3548
+ children: jsx(Icon$1, {
3549
+ name: "XCircleIcon",
3550
+ dataTestId: dataTestId + "Icon",
3551
+ type: "solid",
3552
+ style: {
3553
+ WebkitTransition: "-webkit-transform 0.150s"
3554
+ },
3555
+ className: size === "medium" ? tws`tu-tag__icon` : tws`tu-tag__icon tu-tag__icon--small`
3556
+ })
3557
+ }))]
3558
+ }));
3559
+ });
3560
+
3561
+ const getSizeModifierClass = () => ({
3562
+ $size,
3563
+ $withXIcon
3564
+ }) => {
3565
+ const tagSizeModifierClass = {
3566
+ medium: $withXIcon ? tws`tu-tag--with-icon ` : tws` `,
3567
+ small: $withXIcon ? tws`tu-tag--small tu-tag--with-icon` : tws`tu-tag--small`
3568
+ };
3569
+ return tagSizeModifierClass[$size];
3570
+ };
3571
+
3572
+ const getColorModifierClass = () => ({
3573
+ $color
3574
+ }) => {
3575
+ const colorClasses = {
3576
+ primary: tws`tu-tag--primary`,
3577
+ secondary: tws`tu-tag--secondary`,
3578
+ accent: tws`tu-tag--accent`,
3579
+ success: tws`tu-tag--success`,
3580
+ danger: tws`tu-tag--danger`,
3581
+ warning: tws`tu-tag--warning`,
3582
+ info: tws`tu-tag--info`,
3583
+ neutral: tws`tu-tag--neutral`,
3584
+ good: tws`tu-tag--good`,
3585
+ low: tws`tu-tag--low`,
3586
+ critical: tws`tu-tag--critical`,
3587
+ working: tws`tu-tag--working`,
3588
+ idle: tws`tu-tag--idle`,
3589
+ stopped: tws`tu-tag--stopped`,
3590
+ unknown: tws`tu-tag--unknown`
3591
+ };
3592
+ return colorClasses[$color];
3593
+ };
3594
+
3595
+ const StyledText = tw.span`
3596
+ tu-tag
3597
+ ${getSizeModifierClass()}
3598
+ ${getColorModifierClass()}
3599
+ `;
3600
+ const IconContainer = tw.div`
3601
+ tu-tag__icon-container
3602
+ `;
3603
+
3614
3604
  /**
3615
3605
  * A single select menu item is a basic wrapper around Menu item designed to be used as a single value render in Select list
3616
3606
  *
@@ -3982,7 +3972,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsClosing, refMenuIs
3982
3972
  disabled: disabled,
3983
3973
  dataTestId: props.label
3984
3974
  })) : jsx(SingleSelectMenuItem, Object.assign({}, componentProps, {
3985
- disabled: disabled,
3975
+ disabled: disabled || props.isDisabled,
3986
3976
  dataTestId: props.label
3987
3977
  }))
3988
3978
  }));
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.0.143",
3
+ "version": "0.0.146",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
7
7
  "@trackunit/css-core": "0.0.51",
8
- "@trackunit/tailwind-styled-components": "0.0.44",
8
+ "@trackunit/tailwind-styled-components": "0.0.45",
9
9
  "react": "17.0.2",
10
10
  "@trackunit/ui-design-tokens": "0.0.43",
11
11
  "echarts-for-react": "^3.0.2",