@canonical/react-components 4.2.0 → 4.3.0

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.
@@ -0,0 +1,30 @@
1
+ import { FC, ReactNode } from "react";
2
+ import "./OutputField.scss";
3
+ export type Props = {
4
+ /**
5
+ * The id of the output element. This is used to associate the label with the output element for form or accessibility purposes.
6
+ */
7
+ id: string;
8
+ /**
9
+ * The label for the output field.
10
+ */
11
+ label: string;
12
+ /**
13
+ * The value to be displayed in the output field.
14
+ */
15
+ value: string;
16
+ /**
17
+ * Optional help text to provide additional information about the output field.
18
+ */
19
+ help?: ReactNode;
20
+ /**
21
+ * Whether the output field is required.
22
+ */
23
+ required?: boolean;
24
+ };
25
+ /**
26
+ *
27
+ * Use output fields to display read-only information with a label and optional help text. Output fields are ideal for displaying calculated values or results of user input in a consistent format.
28
+ */
29
+ export declare const OutputField: FC<Props>;
30
+ export default OutputField;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.OutputField = void 0;
7
+ var _propTypes = _interopRequireDefault(require("prop-types"));
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _Field = _interopRequireDefault(require("../Field"));
10
+ require("./OutputField.scss");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ /**
13
+ *
14
+ * Use output fields to display read-only information with a label and optional help text. Output fields are ideal for displaying calculated values or results of user input in a consistent format.
15
+ */
16
+ const OutputField = _ref => {
17
+ let {
18
+ id,
19
+ label,
20
+ value,
21
+ help,
22
+ required
23
+ } = _ref;
24
+ return /*#__PURE__*/_react.default.createElement(_Field.default, {
25
+ forId: id,
26
+ label: label,
27
+ help: help,
28
+ labelClassName: "u-no-margin--bottom",
29
+ className: "output-field",
30
+ required: required
31
+ }, /*#__PURE__*/_react.default.createElement("output", {
32
+ id: id,
33
+ className: "mono-font u-sv2"
34
+ }, /*#__PURE__*/_react.default.createElement("b", null, value)));
35
+ };
36
+ exports.OutputField = OutputField;
37
+ OutputField.propTypes = {
38
+ id: _propTypes.default.string.isRequired,
39
+ label: _propTypes.default.string.isRequired,
40
+ value: _propTypes.default.string.isRequired,
41
+ help: _propTypes.default.node,
42
+ required: _propTypes.default.bool
43
+ };
44
+ var _default = exports.default = OutputField;
@@ -0,0 +1,11 @@
1
+ @import "vanilla-framework";
2
+
3
+ .output-field {
4
+ .p-form-help-text {
5
+ margin-top: -0.65rem;
6
+ }
7
+
8
+ .p-form__control {
9
+ margin-top: 0.25rem;
10
+ }
11
+ }
@@ -0,0 +1,8 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import OutputField from "./OutputField";
3
+ declare const meta: Meta<typeof OutputField>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof OutputField>;
6
+ export declare const Default: Story;
7
+ export declare const HelpText: Story;
8
+ export declare const Required: Story;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.Required = exports.HelpText = exports.Default = void 0;
7
+ var _OutputField = _interopRequireDefault(require("./OutputField"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ const meta = {
10
+ component: _OutputField.default,
11
+ tags: ["autodocs"],
12
+ argTypes: {
13
+ label: {
14
+ control: {
15
+ type: "text"
16
+ }
17
+ },
18
+ id: {
19
+ control: {
20
+ type: "text"
21
+ }
22
+ },
23
+ value: {
24
+ control: {
25
+ type: "text"
26
+ }
27
+ },
28
+ help: {
29
+ control: {
30
+ type: "text"
31
+ }
32
+ },
33
+ required: {
34
+ control: {
35
+ type: "boolean"
36
+ }
37
+ }
38
+ },
39
+ args: {
40
+ label: "Label",
41
+ id: "output-field",
42
+ value: "Output value",
43
+ help: "",
44
+ required: false
45
+ }
46
+ };
47
+ var _default = exports.default = meta;
48
+ const Default = exports.Default = {
49
+ name: "Default"
50
+ };
51
+ const HelpText = exports.HelpText = {
52
+ name: "Help Text",
53
+ args: {
54
+ help: "This is an output field with text"
55
+ }
56
+ };
57
+ const Required = exports.Required = {
58
+ name: "Required",
59
+ args: {
60
+ required: true
61
+ }
62
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default } from "./OutputField";
2
+ export type { Props as OutputFieldProps } from "./OutputField";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "default", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _OutputField.default;
10
+ }
11
+ });
12
+ var _OutputField = _interopRequireDefault(require("./OutputField"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,30 @@
1
+ import { FC, ReactNode } from "react";
2
+ import "./OutputField.scss";
3
+ export type Props = {
4
+ /**
5
+ * The id of the output element. This is used to associate the label with the output element for form or accessibility purposes.
6
+ */
7
+ id: string;
8
+ /**
9
+ * The label for the output field.
10
+ */
11
+ label: string;
12
+ /**
13
+ * The value to be displayed in the output field.
14
+ */
15
+ value: string;
16
+ /**
17
+ * Optional help text to provide additional information about the output field.
18
+ */
19
+ help?: ReactNode;
20
+ /**
21
+ * Whether the output field is required.
22
+ */
23
+ required?: boolean;
24
+ };
25
+ /**
26
+ *
27
+ * Use output fields to display read-only information with a label and optional help text. Output fields are ideal for displaying calculated values or results of user input in a consistent format.
28
+ */
29
+ export declare const OutputField: FC<Props>;
30
+ export default OutputField;
@@ -0,0 +1,36 @@
1
+ import _pt from "prop-types";
2
+ import React from "react";
3
+ import Field from "../Field";
4
+ import "./OutputField.scss";
5
+ /**
6
+ *
7
+ * Use output fields to display read-only information with a label and optional help text. Output fields are ideal for displaying calculated values or results of user input in a consistent format.
8
+ */
9
+ export var OutputField = _ref => {
10
+ var {
11
+ id,
12
+ label,
13
+ value,
14
+ help,
15
+ required
16
+ } = _ref;
17
+ return /*#__PURE__*/React.createElement(Field, {
18
+ forId: id,
19
+ label: label,
20
+ help: help,
21
+ labelClassName: "u-no-margin--bottom",
22
+ className: "output-field",
23
+ required: required
24
+ }, /*#__PURE__*/React.createElement("output", {
25
+ id: id,
26
+ className: "mono-font u-sv2"
27
+ }, /*#__PURE__*/React.createElement("b", null, value)));
28
+ };
29
+ OutputField.propTypes = {
30
+ id: _pt.string.isRequired,
31
+ label: _pt.string.isRequired,
32
+ value: _pt.string.isRequired,
33
+ help: _pt.node,
34
+ required: _pt.bool
35
+ };
36
+ export default OutputField;
@@ -0,0 +1,11 @@
1
+ @import "vanilla-framework";
2
+
3
+ .output-field {
4
+ .p-form-help-text {
5
+ margin-top: -0.65rem;
6
+ }
7
+
8
+ .p-form__control {
9
+ margin-top: 0.25rem;
10
+ }
11
+ }
@@ -0,0 +1,8 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import OutputField from "./OutputField";
3
+ declare const meta: Meta<typeof OutputField>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof OutputField>;
6
+ export declare const Default: Story;
7
+ export declare const HelpText: Story;
8
+ export declare const Required: Story;
@@ -0,0 +1,55 @@
1
+ import OutputField from "./OutputField";
2
+ var meta = {
3
+ component: OutputField,
4
+ tags: ["autodocs"],
5
+ argTypes: {
6
+ label: {
7
+ control: {
8
+ type: "text"
9
+ }
10
+ },
11
+ id: {
12
+ control: {
13
+ type: "text"
14
+ }
15
+ },
16
+ value: {
17
+ control: {
18
+ type: "text"
19
+ }
20
+ },
21
+ help: {
22
+ control: {
23
+ type: "text"
24
+ }
25
+ },
26
+ required: {
27
+ control: {
28
+ type: "boolean"
29
+ }
30
+ }
31
+ },
32
+ args: {
33
+ label: "Label",
34
+ id: "output-field",
35
+ value: "Output value",
36
+ help: "",
37
+ required: false
38
+ }
39
+ };
40
+ export default meta;
41
+ export var Default = {
42
+ name: "Default"
43
+ };
44
+ export var HelpText = {
45
+ name: "Help Text",
46
+ args: {
47
+ help: "This is an output field with text"
48
+ }
49
+ };
50
+ export var Required = {
51
+ name: "Required",
52
+ args: {
53
+ required: true
54
+ }
55
+ };
@@ -0,0 +1,2 @@
1
+ export { default } from "./OutputField";
2
+ export type { Props as OutputFieldProps } from "./OutputField";
@@ -0,0 +1 @@
1
+ export { default } from "./OutputField";
@@ -40,6 +40,7 @@ export * from "./components/MultiSelect";
40
40
  export { default as Notification, NotificationSeverity, } from "./components/Notifications";
41
41
  export { NotificationConsumer, NotificationProvider, useNotify, info, success, failure, queue, } from "./components/NotificationProvider";
42
42
  export { default as LoginPageLayout } from "./components/LoginPageLayout";
43
+ export { default as OutputField } from "./components/OutputField";
43
44
  export { default as Pagination } from "./components/Pagination";
44
45
  export { default as Panel } from "./components/Panel";
45
46
  export { default as PasswordToggle } from "./components/PasswordToggle";
@@ -118,6 +119,7 @@ export type { GenerateLink, LogoProps, NavigationProps, NavItem, NavLink, NavLin
118
119
  export type { NotificationProps } from "./components/Notifications";
119
120
  export type { NotificationAction, NotificationType, QueuedNotification, NotificationHelper, } from "./components/NotificationProvider";
120
121
  export type { LoginPageLayoutProps } from "./components/LoginPageLayout";
122
+ export type { OutputFieldProps } from "./components/OutputField";
121
123
  export type { PaginationProps } from "./components/Pagination";
122
124
  export type { PanelProps } from "./components/Panel";
123
125
  export type { PrefixedInputProps } from "./components/PrefixedInput";
package/dist/esm/index.js CHANGED
@@ -40,6 +40,7 @@ export * from "./components/MultiSelect";
40
40
  export { default as Notification, NotificationSeverity } from "./components/Notifications";
41
41
  export { NotificationConsumer, NotificationProvider, useNotify, info, success, failure, queue } from "./components/NotificationProvider";
42
42
  export { default as LoginPageLayout } from "./components/LoginPageLayout";
43
+ export { default as OutputField } from "./components/OutputField";
43
44
  export { default as Pagination } from "./components/Pagination";
44
45
  export { default as Panel } from "./components/Panel";
45
46
  export { default as PasswordToggle } from "./components/PasswordToggle";
package/dist/index.d.ts CHANGED
@@ -40,6 +40,7 @@ export * from "./components/MultiSelect";
40
40
  export { default as Notification, NotificationSeverity, } from "./components/Notifications";
41
41
  export { NotificationConsumer, NotificationProvider, useNotify, info, success, failure, queue, } from "./components/NotificationProvider";
42
42
  export { default as LoginPageLayout } from "./components/LoginPageLayout";
43
+ export { default as OutputField } from "./components/OutputField";
43
44
  export { default as Pagination } from "./components/Pagination";
44
45
  export { default as Panel } from "./components/Panel";
45
46
  export { default as PasswordToggle } from "./components/PasswordToggle";
@@ -118,6 +119,7 @@ export type { GenerateLink, LogoProps, NavigationProps, NavItem, NavLink, NavLin
118
119
  export type { NotificationProps } from "./components/Notifications";
119
120
  export type { NotificationAction, NotificationType, QueuedNotification, NotificationHelper, } from "./components/NotificationProvider";
120
121
  export type { LoginPageLayoutProps } from "./components/LoginPageLayout";
122
+ export type { OutputFieldProps } from "./components/OutputField";
121
123
  export type { PaginationProps } from "./components/Pagination";
122
124
  export type { PanelProps } from "./components/Panel";
123
125
  export type { PrefixedInputProps } from "./components/PrefixedInput";
package/dist/index.js CHANGED
@@ -61,6 +61,7 @@ var _exportNames = {
61
61
  failure: true,
62
62
  queue: true,
63
63
  LoginPageLayout: true,
64
+ OutputField: true,
64
65
  Pagination: true,
65
66
  Panel: true,
66
67
  PasswordToggle: true,
@@ -410,6 +411,12 @@ Object.defineProperty(exports, "NotificationSeverity", {
410
411
  return _Notifications.NotificationSeverity;
411
412
  }
412
413
  });
414
+ Object.defineProperty(exports, "OutputField", {
415
+ enumerable: true,
416
+ get: function () {
417
+ return _OutputField.default;
418
+ }
419
+ });
413
420
  Object.defineProperty(exports, "Pagination", {
414
421
  enumerable: true,
415
422
  get: function () {
@@ -919,6 +926,7 @@ Object.keys(_MultiSelect).forEach(function (key) {
919
926
  var _Notifications = _interopRequireWildcard(require("./components/Notifications"));
920
927
  var _NotificationProvider = require("./components/NotificationProvider");
921
928
  var _LoginPageLayout = _interopRequireDefault(require("./components/LoginPageLayout"));
929
+ var _OutputField = _interopRequireDefault(require("./components/OutputField"));
922
930
  var _Pagination = _interopRequireDefault(require("./components/Pagination"));
923
931
  var _Panel = _interopRequireDefault(require("./components/Panel"));
924
932
  var _PasswordToggle = _interopRequireDefault(require("./components/PasswordToggle"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": {
@@ -96,7 +96,7 @@
96
96
  "tsc-alias": "1.8.10",
97
97
  "typescript": "5.7.3",
98
98
  "typescript-eslint": "8.24.1",
99
- "vanilla-framework": "4.46.0",
99
+ "vanilla-framework": "4.48.0",
100
100
  "wait-on": "9.0.3",
101
101
  "webpack": "5.105.0"
102
102
  },