@pingux/astro 2.115.0 → 2.115.1-alpha.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.
@@ -41,6 +41,8 @@ var PromptInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
41
41
  var attachmentProps = props.attachmentProps,
42
42
  isFullScreen = props.isFullScreen,
43
43
  isLoading = props.isLoading,
44
+ _props$isUploadButton = props.isUploadButtonHidden,
45
+ isUploadButtonHidden = _props$isUploadButton === void 0 ? false : _props$isUploadButton,
44
46
  fileInputButtonProps = props.fileInputButtonProps,
45
47
  valueProp = props.value,
46
48
  defaultValueProp = props.defaultValue,
@@ -188,7 +190,7 @@ var PromptInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
188
190
  }, fieldControlInputProps, {
189
191
  onKeyUp: onKeyUp,
190
192
  onKeyDown: onKeyDown
191
- })), (0, _react2.jsx)(_index.Box, {
193
+ })), !isUploadButtonHidden && (0, _react2.jsx)(_index.Box, {
192
194
  sx: {
193
195
  mx: '.75rem',
194
196
  mb: 'auto'
@@ -2,8 +2,17 @@ import React from 'react';
2
2
  declare const _default: {
3
3
  title: string;
4
4
  component: React.ForwardRefExoticComponent<import("../../../types/promptInput").PromptInputProps & React.RefAttributes<HTMLInputElement>>;
5
+ parameters: {
6
+ docs: {
7
+ page: () => React.JSX.Element;
8
+ source: {
9
+ type: string;
10
+ };
11
+ };
12
+ };
5
13
  argTypes: {
6
14
  isLoading: any;
15
+ isUploadButtonHidden: any;
7
16
  };
8
17
  };
9
18
  export default _default;
@@ -19,9 +19,11 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
19
19
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
20
20
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
21
21
  var _react = _interopRequireWildcard(require("react"));
22
+ var _storybookDocsLayout = _interopRequireDefault(require("../../../../.storybook/storybookDocsLayout"));
22
23
  var _ = require("../../..");
23
24
  var _docArgTypes = require("../../../utils/docUtils/docArgTypes");
24
25
  var _PromptInput = _interopRequireDefault(require("./PromptInput"));
26
+ var _PromptInputReadMe = _interopRequireDefault(require("./PromptInputReadMe.mdx"));
25
27
  var _react2 = require("@emotion/react");
26
28
  function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
29
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -30,8 +32,19 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
30
32
  var _default = {
31
33
  title: 'Ai Components/Prompt Input',
32
34
  component: _PromptInput["default"],
35
+ parameters: {
36
+ docs: {
37
+ page: function page() {
38
+ return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_PromptInputReadMe["default"], null), (0, _react2.jsx)(_storybookDocsLayout["default"], null));
39
+ },
40
+ source: {
41
+ type: 'code'
42
+ }
43
+ }
44
+ },
33
45
  argTypes: {
34
- isLoading: _objectSpread({}, _docArgTypes.booleanArg)
46
+ isLoading: _objectSpread({}, _docArgTypes.booleanArg),
47
+ isUploadButtonHidden: _objectSpread({}, _docArgTypes.booleanArg)
35
48
  }
36
49
  };
37
50
  exports["default"] = _default;
@@ -134,6 +134,15 @@ test('onSubmit prop works correctly', /*#__PURE__*/(0, _asyncToGenerator2["defau
134
134
  }
135
135
  }, _callee2);
136
136
  })));
137
+ test('', function () {
138
+ getComponent({
139
+ isUploadButtonHidden: true,
140
+ uploadButtonProps: {
141
+ 'data-testid': buttonTestId
142
+ }
143
+ });
144
+ expect(_testWrapper.screen.queryByText(buttonTestId)).not.toBeInTheDocument();
145
+ });
137
146
  test('onCancel prop works correctly', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
138
147
  var control;
139
148
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
@@ -0,0 +1,71 @@
1
+ import { Meta } from '@storybook/addon-docs';
2
+
3
+ <Meta title="Components/PromptInput" />
4
+
5
+ # PromptInput
6
+
7
+ The `PromptInput` component is used to capture user input in a conversational UI. It supports text input, file attachments, and customizable actions like submission or cancellation.
8
+
9
+ ### Recommended Use
10
+
11
+ - Use the `PromptInput` component to collect user input in chat-like interfaces.
12
+ - Attach files or documents to the input using the file attachment feature.
13
+
14
+ ### Features
15
+
16
+ - **Text Input**: Allows users to type text with dynamic height adjustment based on content.
17
+ - **File Attachments**: Supports adding and removing file attachments.
18
+ - **Customizable Actions**: Includes `onSubmit`, `onCancel`, `onKeyDown`, and `onKeyUp` handlers for custom behavior.
19
+
20
+ ### Props
21
+
22
+ | Prop | Type | Description |
23
+ | --------------------- | -------------------- | --------------------------------------------------------------------------- |
24
+ | `value` | `string` | The controlled value of the input. |
25
+ | `defaultValue` | `string` | The default value of the input. |
26
+ | `onSubmit` | `function` | Callback triggered when the input is submitted. |
27
+ | `onCancel` | `function` | Callback triggered when the input is canceled. |
28
+ | `onKeyDown` | `function` | Callback triggered on key down events. |
29
+ | `onKeyUp` | `function` | Callback triggered on key up events. |
30
+ | `onFileChange` | `function` | Callback triggered when files are added or removed. |
31
+ | `attachmentProps` | `object` | Props passed to the `Attachment` component for file attachments. |
32
+ | `fileInputButtonProps`| `object` | Props passed to the file input button. |
33
+ | `uploadButtonProps` | `object` | Props passed to the upload button. |
34
+ | `isLoading` | `boolean` | Indicates whether the input is in a loading state. |
35
+
36
+ ### Accessibility
37
+
38
+ This component adheres to accessibility guidelines to ensure a better user experience for all users.
39
+
40
+ #### Keyboard Navigation
41
+
42
+ | Keys | Function |
43
+ | ------------ | ----------------------------------------------------------------------- |
44
+ | Tab | Focuses on the next focusable element within the input. |
45
+ | Shift + Tab | Moves focus to the previous focusable element. |
46
+ | Enter | Submits the input when `onSubmit` is defined. |
47
+ | Shift + Enter| Adds a new line to the input. |
48
+ | Escape | Cancels the input when `onCancel` is defined. |
49
+
50
+ #### Screen Readers
51
+
52
+ - **`aria-label`**: Describes the purpose of the input field.
53
+ - **`aria-disabled`**: Indicates when the input is disabled.
54
+ - **`aria-live`**: Announces changes to the input dynamically.
55
+
56
+ ### Example Usage
57
+
58
+ ```jsx
59
+ <PromptInput
60
+ value=""
61
+ onSubmit={(e, value) => console.log('Submitted:', value)}
62
+ onCancel={(e) => console.log('Canceled')}
63
+ onFileChange={(files) => console.log('Files:', files)}
64
+ attachmentProps={{
65
+ icon: GlobeIcon,
66
+ }}
67
+ uploadButtonProps={{
68
+ 'aria-label': 'Upload',
69
+ }}
70
+ isLoading={false}
71
+ />
@@ -18,6 +18,7 @@ export interface PromptProps {
18
18
  export interface PromptInputProps extends TextFieldProps, PromptProps {
19
19
  onKeyUp?: (e: React.KeyboardEvent, value?: string) => void;
20
20
  onKeyDown?: (e: React.KeyboardEvent, value?: string) => void;
21
+ isUploadButtonHidden?: boolean;
21
22
  }
22
23
  export interface AttachmentProps {
23
24
  title: string;
@@ -29,6 +29,8 @@ var PromptInput = /*#__PURE__*/forwardRef(function (props, ref) {
29
29
  var attachmentProps = props.attachmentProps,
30
30
  isFullScreen = props.isFullScreen,
31
31
  isLoading = props.isLoading,
32
+ _props$isUploadButton = props.isUploadButtonHidden,
33
+ isUploadButtonHidden = _props$isUploadButton === void 0 ? false : _props$isUploadButton,
32
34
  fileInputButtonProps = props.fileInputButtonProps,
33
35
  valueProp = props.value,
34
36
  defaultValueProp = props.defaultValue,
@@ -176,7 +178,7 @@ var PromptInput = /*#__PURE__*/forwardRef(function (props, ref) {
176
178
  }, fieldControlInputProps, {
177
179
  onKeyUp: onKeyUp,
178
180
  onKeyDown: onKeyDown
179
- })), ___EmotionJSX(Box, {
181
+ })), !isUploadButtonHidden && ___EmotionJSX(Box, {
180
182
  sx: {
181
183
  mx: '.75rem',
182
184
  mb: 'auto'
@@ -12,15 +12,28 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
12
12
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
13
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
14
14
  import React, { useState } from 'react';
15
+ import DocsLayout from '../../../../.storybook/storybookDocsLayout';
15
16
  import { AstroProvider, Box, NextGenTheme } from '../../..';
16
17
  import { booleanArg } from '../../../utils/docUtils/docArgTypes';
17
18
  import PromptInput from './PromptInput';
19
+ import PromptInputReadMe from './PromptInputReadMe.mdx';
18
20
  import { jsx as ___EmotionJSX } from "@emotion/react";
19
21
  export default {
20
22
  title: 'Ai Components/Prompt Input',
21
23
  component: PromptInput,
24
+ parameters: {
25
+ docs: {
26
+ page: function page() {
27
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(PromptInputReadMe, null), ___EmotionJSX(DocsLayout, null));
28
+ },
29
+ source: {
30
+ type: 'code'
31
+ }
32
+ }
33
+ },
22
34
  argTypes: {
23
- isLoading: _objectSpread({}, booleanArg)
35
+ isLoading: _objectSpread({}, booleanArg),
36
+ isUploadButtonHidden: _objectSpread({}, booleanArg)
24
37
  }
25
38
  };
26
39
  export var Default = function Default(args) {
@@ -131,6 +131,15 @@ test('onSubmit prop works correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE_
131
131
  }
132
132
  }, _callee2);
133
133
  })));
134
+ test('', function () {
135
+ getComponent({
136
+ isUploadButtonHidden: true,
137
+ uploadButtonProps: {
138
+ 'data-testid': buttonTestId
139
+ }
140
+ });
141
+ expect(screen.queryByText(buttonTestId)).not.toBeInTheDocument();
142
+ });
134
143
  test('onCancel prop works correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
135
144
  var control;
136
145
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
@@ -0,0 +1,71 @@
1
+ import { Meta } from '@storybook/addon-docs';
2
+
3
+ <Meta title="Components/PromptInput" />
4
+
5
+ # PromptInput
6
+
7
+ The `PromptInput` component is used to capture user input in a conversational UI. It supports text input, file attachments, and customizable actions like submission or cancellation.
8
+
9
+ ### Recommended Use
10
+
11
+ - Use the `PromptInput` component to collect user input in chat-like interfaces.
12
+ - Attach files or documents to the input using the file attachment feature.
13
+
14
+ ### Features
15
+
16
+ - **Text Input**: Allows users to type text with dynamic height adjustment based on content.
17
+ - **File Attachments**: Supports adding and removing file attachments.
18
+ - **Customizable Actions**: Includes `onSubmit`, `onCancel`, `onKeyDown`, and `onKeyUp` handlers for custom behavior.
19
+
20
+ ### Props
21
+
22
+ | Prop | Type | Description |
23
+ | --------------------- | -------------------- | --------------------------------------------------------------------------- |
24
+ | `value` | `string` | The controlled value of the input. |
25
+ | `defaultValue` | `string` | The default value of the input. |
26
+ | `onSubmit` | `function` | Callback triggered when the input is submitted. |
27
+ | `onCancel` | `function` | Callback triggered when the input is canceled. |
28
+ | `onKeyDown` | `function` | Callback triggered on key down events. |
29
+ | `onKeyUp` | `function` | Callback triggered on key up events. |
30
+ | `onFileChange` | `function` | Callback triggered when files are added or removed. |
31
+ | `attachmentProps` | `object` | Props passed to the `Attachment` component for file attachments. |
32
+ | `fileInputButtonProps`| `object` | Props passed to the file input button. |
33
+ | `uploadButtonProps` | `object` | Props passed to the upload button. |
34
+ | `isLoading` | `boolean` | Indicates whether the input is in a loading state. |
35
+
36
+ ### Accessibility
37
+
38
+ This component adheres to accessibility guidelines to ensure a better user experience for all users.
39
+
40
+ #### Keyboard Navigation
41
+
42
+ | Keys | Function |
43
+ | ------------ | ----------------------------------------------------------------------- |
44
+ | Tab | Focuses on the next focusable element within the input. |
45
+ | Shift + Tab | Moves focus to the previous focusable element. |
46
+ | Enter | Submits the input when `onSubmit` is defined. |
47
+ | Shift + Enter| Adds a new line to the input. |
48
+ | Escape | Cancels the input when `onCancel` is defined. |
49
+
50
+ #### Screen Readers
51
+
52
+ - **`aria-label`**: Describes the purpose of the input field.
53
+ - **`aria-disabled`**: Indicates when the input is disabled.
54
+ - **`aria-live`**: Announces changes to the input dynamically.
55
+
56
+ ### Example Usage
57
+
58
+ ```jsx
59
+ <PromptInput
60
+ value=""
61
+ onSubmit={(e, value) => console.log('Submitted:', value)}
62
+ onCancel={(e) => console.log('Canceled')}
63
+ onFileChange={(files) => console.log('Files:', files)}
64
+ attachmentProps={{
65
+ icon: GlobeIcon,
66
+ }}
67
+ uploadButtonProps={{
68
+ 'aria-label': 'Upload',
69
+ }}
70
+ isLoading={false}
71
+ />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.115.0",
3
+ "version": "2.115.1-alpha.0",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",