@capillarytech/blaze-ui 0.1.6-alpha.29 → 0.1.6-alpha.31

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,51 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React, { useRef, useEffect } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { Input } from 'antd';
5
+ import { WarningOutlined, CheckCircleOutlined } from '@ant-design/icons';
6
+ import styled from 'styled-components';
7
+ import * as styledVars from '../styled/variables';
8
+ const StyledIcon = styled.span.withConfig({
9
+ displayName: "StyledIcon",
10
+ componentId: "sc-1ghbg8a-0"
11
+ })(["color:", ";color:", ";"], props => props.status === "error" && styledVars.CAP_RED, props => props.status === "success" && styledVars.CAP_PRIMARY.base);
12
+ const CapInput = /*#__PURE__*/React.forwardRef((props, ref) => {
13
+ const {
14
+ alwaysShowFocus,
15
+ errorMessage,
16
+ isVerified,
17
+ suffix,
18
+ showSuffix = true,
19
+ ...rest
20
+ } = props;
21
+ const inputRef = useRef(null);
22
+ useEffect(() => {
23
+ if (alwaysShowFocus && inputRef.current) {
24
+ inputRef.current.focus();
25
+ }
26
+ }, [alwaysShowFocus]);
27
+ const inputSuffix = errorMessage && /*#__PURE__*/React.createElement(StyledIcon, {
28
+ status: "error"
29
+ }, /*#__PURE__*/React.createElement(WarningOutlined, null)) || isVerified && /*#__PURE__*/React.createElement(StyledIcon, {
30
+ status: "success"
31
+ }, /*#__PURE__*/React.createElement(CheckCircleOutlined, null)) || suffix || null;
32
+ return /*#__PURE__*/React.createElement(Input, _extends({}, rest, {
33
+ ref: ref || inputRef,
34
+ suffix: showSuffix === false ? null : inputSuffix,
35
+ status: errorMessage ? 'error' : undefined
36
+ }));
37
+ });
38
+ CapInput.displayName = 'CapInput';
39
+ CapInput.propTypes = {
40
+ alwaysShowFocus: PropTypes.bool,
41
+ errorMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
42
+ isVerified: PropTypes.bool,
43
+ size: PropTypes.oneOf(['large', 'middle', 'small']),
44
+ suffix: PropTypes.node,
45
+ showSuffix: PropTypes.bool
46
+ };
47
+ CapInput.defaultProps = {
48
+ size: 'large',
49
+ showSuffix: true
50
+ };
51
+ export default CapInput;
@@ -0,0 +1,33 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { InputNumber } from 'antd';
5
+ const CapInputNumber = /*#__PURE__*/React.forwardRef((props, ref) => {
6
+ const {
7
+ size = 'large',
8
+ ...rest
9
+ } = props;
10
+ return /*#__PURE__*/React.createElement(InputNumber, _extends({}, rest, {
11
+ ref: ref,
12
+ size: size
13
+ }));
14
+ });
15
+ CapInputNumber.displayName = 'CapInputNumber';
16
+ CapInputNumber.propTypes = {
17
+ size: PropTypes.oneOf(['large', 'middle', 'small']),
18
+ min: PropTypes.number,
19
+ max: PropTypes.number,
20
+ step: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
21
+ precision: PropTypes.number,
22
+ decimalSeparator: PropTypes.string,
23
+ formatter: PropTypes.func,
24
+ parser: PropTypes.func,
25
+ controls: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
26
+ keyboard: PropTypes.bool,
27
+ stringMode: PropTypes.bool
28
+ };
29
+ CapInputNumber.defaultProps = {
30
+ size: 'large',
31
+ keyboard: true
32
+ };
33
+ export default CapInputNumber;
@@ -0,0 +1,28 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { Input } from 'antd';
5
+ const {
6
+ Search
7
+ } = Input;
8
+ const CapInputSearch = /*#__PURE__*/React.forwardRef((props, ref) => {
9
+ const {
10
+ size = 'large',
11
+ ...rest
12
+ } = props;
13
+ return /*#__PURE__*/React.createElement(Search, _extends({}, rest, {
14
+ ref: ref,
15
+ size: size
16
+ }));
17
+ });
18
+ CapInputSearch.displayName = 'CapInputSearch';
19
+ CapInputSearch.propTypes = {
20
+ size: PropTypes.oneOf(['large', 'middle', 'small']),
21
+ enterButton: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
22
+ loading: PropTypes.bool,
23
+ onSearch: PropTypes.func
24
+ };
25
+ CapInputSearch.defaultProps = {
26
+ size: 'large'
27
+ };
28
+ export default CapInputSearch;
@@ -0,0 +1,35 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { Input } from 'antd';
5
+ const {
6
+ TextArea
7
+ } = Input;
8
+ const CapInputTextArea = /*#__PURE__*/React.forwardRef((props, ref) => {
9
+ const {
10
+ size = 'large',
11
+ ...rest
12
+ } = props;
13
+ return /*#__PURE__*/React.createElement(TextArea, _extends({}, rest, {
14
+ ref: ref,
15
+ size: size
16
+ }));
17
+ });
18
+ CapInputTextArea.displayName = 'CapInputTextArea';
19
+ CapInputTextArea.propTypes = {
20
+ size: PropTypes.oneOf(['large', 'middle', 'small']),
21
+ autoSize: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
22
+ minRows: PropTypes.number,
23
+ maxRows: PropTypes.number
24
+ })]),
25
+ rows: PropTypes.number,
26
+ maxLength: PropTypes.number,
27
+ showCount: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
28
+ formatter: PropTypes.func
29
+ })])
30
+ };
31
+ CapInputTextArea.defaultProps = {
32
+ size: 'large',
33
+ rows: 4
34
+ };
35
+ export default CapInputTextArea;
@@ -0,0 +1,8 @@
1
+ import CapInput from './CapInput';
2
+ import Number from './Number';
3
+ import Search from './Search';
4
+ import TextArea from './TextArea';
5
+ CapInput.Number = Number;
6
+ CapInput.Search = Search;
7
+ CapInput.TextArea = TextArea;
8
+ export default CapInput;
@@ -0,0 +1,25 @@
1
+ /*
2
+ * CapInput Messages
3
+ *
4
+ * This contains all the text for the CapInput component.
5
+ */
6
+ import { defineMessages } from 'react-intl';
7
+ const scope = 'blaze.components.CapInput';
8
+ export default defineMessages({
9
+ placeholder: {
10
+ id: `${scope}.placeholder`,
11
+ defaultMessage: 'Enter text...'
12
+ },
13
+ searchPlaceholder: {
14
+ id: `${scope}.searchPlaceholder`,
15
+ defaultMessage: 'Search...'
16
+ },
17
+ textAreaPlaceholder: {
18
+ id: `${scope}.textAreaPlaceholder`,
19
+ defaultMessage: 'Enter your text here...'
20
+ },
21
+ numberPlaceholder: {
22
+ id: `${scope}.numberPlaceholder`,
23
+ defaultMessage: 'Enter number...'
24
+ }
25
+ });
@@ -0,0 +1,3 @@
1
+ import { css } from 'styled-components';
2
+ import * as styledVars from '../styled/variables';
3
+ export const inputStyles = css(["&.ant-input,&.ant-input-affix-wrapper,&.ant-input-number,&.ant-input-textarea{font-family:", ";border-radius:", ";transition:", ";&:hover{border-color:", ";}&:focus,&.ant-input-affix-wrapper-focused{border-color:", ";box-shadow:none;}&.ant-input-status-error,&.ant-input-affix-wrapper-status-error,&.ant-input-number-status-error{border-color:", ";&:hover{border-color:", ";}&:focus,&.ant-input-affix-wrapper-focused{border-color:", ";box-shadow:none;}}&.ant-input-disabled,&.ant-input-affix-wrapper-disabled{background-color:", ";cursor:not-allowed;}}&.ant-input-lg,&.ant-input-affix-wrapper-lg{font-size:14px;padding:10px 12px;}&.ant-input-textarea{.ant-input{font-family:", ";}}&.ant-input-number{width:100%;.ant-input-number-handler-wrap{opacity:1;}}&.ant-input-search{.ant-input-search-button{background-color:", ";border-color:", ";&:hover{background-color:", ";border-color:", ";}}}"], styledVars.FONT_FAMILY, styledVars.RADIUS_04, styledVars.TRANSITION_ALL, styledVars.CAP_G11, styledVars.CAP_G01, styledVars.CAP_RED, styledVars.CAP_RED, styledVars.CAP_RED, styledVars.CAP_G08, styledVars.FONT_FAMILY, styledVars.CAP_PRIMARY.base, styledVars.CAP_PRIMARY.base, styledVars.CAP_PRIMARY.hover, styledVars.CAP_PRIMARY.hover);
@@ -0,0 +1,21 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ /**
3
+ * CapSkeleton - Migrated to Ant Design v5
4
+ */
5
+ import React from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import { Skeleton } from 'antd';
8
+ const CapSkeleton = _ref => {
9
+ let {
10
+ className,
11
+ ...rest
12
+ } = _ref;
13
+ const combinedClassName = `cap-skeleton-v2 ${className || ''}`.trim();
14
+ return /*#__PURE__*/React.createElement(Skeleton, _extends({
15
+ className: combinedClassName
16
+ }, rest));
17
+ };
18
+ CapSkeleton.propTypes = {
19
+ className: PropTypes.string
20
+ };
21
+ export default CapSkeleton;
@@ -0,0 +1 @@
1
+ export { default } from './CapSkeleton';
@@ -0,0 +1,27 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ /**
3
+ * CapSpin - Migrated to Ant Design v5
4
+ */
5
+ import React from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import { Spin } from 'antd';
8
+ const CapSpin = _ref => {
9
+ let {
10
+ className,
11
+ ...rest
12
+ } = _ref;
13
+ return /*#__PURE__*/React.createElement(Spin, _extends({
14
+ className: className
15
+ }, rest));
16
+ };
17
+ CapSpin.propTypes = {
18
+ className: PropTypes.string,
19
+ size: PropTypes.oneOf(['small', 'default', 'large']),
20
+ spinning: PropTypes.bool,
21
+ tip: PropTypes.string,
22
+ delay: PropTypes.number,
23
+ indicator: PropTypes.node,
24
+ fullscreen: PropTypes.bool,
25
+ wrapperClassName: PropTypes.string
26
+ };
27
+ export default CapSpin;
@@ -0,0 +1 @@
1
+ export { default } from './CapSpin';
@@ -0,0 +1,124 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ /**
3
+ * CapTable - Migrated to Ant Design v5
4
+ * A table component that supports:
5
+ * - Infinite scrolling with virtualization
6
+ * - Sequential data loading
7
+ * - Optimized scroll performance
8
+ */
9
+ import React, { useEffect, useCallback, useState, useRef } from 'react';
10
+ import PropTypes from 'prop-types';
11
+ import { debounce } from 'lodash';
12
+ import classNames from 'classnames';
13
+ import { StyledTable } from './styles';
14
+ import LocaleHoc from '../LocaleHoc';
15
+ const SCROLL_THRESHOLD = 80; // Percentage of scroll to trigger load
16
+ const DEBOUNCE_DELAY = 250; // ms to wait between scroll events
17
+ const DEFAULT_ROW_HEIGHT = 54;
18
+ const DEFAULT_SCROLL_HEIGHT = 400;
19
+ const CapTable = _ref => {
20
+ let {
21
+ id,
22
+ className,
23
+ children,
24
+ infiniteScroll,
25
+ pagination,
26
+ dataSource,
27
+ offset_limit,
28
+ setPagination,
29
+ scroll,
30
+ showLoader,
31
+ ...rest
32
+ } = _ref;
33
+ const scrollRef = useRef(null);
34
+ const [hasMore, setHasMore] = useState(true);
35
+ const currentOffsetRef = useRef(0);
36
+ const loadMore = useCallback(() => {
37
+ if (!showLoader && hasMore) {
38
+ const nextOffset = currentOffsetRef.current + 1;
39
+ const newOffsetLimit = {
40
+ ...offset_limit,
41
+ offset: nextOffset
42
+ };
43
+ currentOffsetRef.current = nextOffset;
44
+ setPagination(newOffsetLimit);
45
+ }
46
+ }, [showLoader, hasMore, setPagination, offset_limit]);
47
+ const handleScroll = useCallback(debounce(event => {
48
+ const target = event.target;
49
+ if (!target || !infiniteScroll || !hasMore || showLoader) return;
50
+ const scrollTop = Math.ceil(target.scrollTop);
51
+ const visibleHeight = target.clientHeight;
52
+ const totalHeight = target.scrollHeight;
53
+ const scrolledPercentage = (scrollTop + visibleHeight) / totalHeight * 100;
54
+ if (scrolledPercentage >= SCROLL_THRESHOLD) {
55
+ loadMore();
56
+ }
57
+ }, DEBOUNCE_DELAY), [infiniteScroll, showLoader, hasMore, loadMore]);
58
+
59
+ // Setup scroll listener and handle initial load
60
+ useEffect(() => {
61
+ const tableBody = document.querySelector(`#${id} .ant-table-body`);
62
+ if (!tableBody) return;
63
+ scrollRef.current = tableBody;
64
+ tableBody.addEventListener('scroll', handleScroll, {
65
+ passive: true
66
+ });
67
+
68
+ // Check if initial load needed
69
+ const shouldLoadInitially = tableBody.scrollHeight <= tableBody.clientHeight && !showLoader && hasMore;
70
+ if (shouldLoadInitially) {
71
+ currentOffsetRef.current = 0;
72
+ loadMore();
73
+ }
74
+
75
+ // Cleanup
76
+ return () => {
77
+ scrollRef.current?.removeEventListener('scroll', handleScroll);
78
+ handleScroll.cancel();
79
+ };
80
+ }, [id, handleScroll, showLoader, hasMore, loadMore]);
81
+
82
+ // Handle data changes
83
+ useEffect(() => {
84
+ if (!dataSource?.length) {
85
+ currentOffsetRef.current = 0;
86
+ setHasMore(true);
87
+ } else {
88
+ setHasMore(true);
89
+ }
90
+ }, [dataSource]);
91
+ const tableClassName = classNames('cap-table-v2', className, {
92
+ 'show-loader': showLoader,
93
+ 'infinite-scroll': infiniteScroll,
94
+ 'has-more': hasMore
95
+ });
96
+ return /*#__PURE__*/React.createElement(StyledTable, _extends({
97
+ id: id,
98
+ className: tableClassName,
99
+ dataSource: dataSource,
100
+ pagination: false,
101
+ scroll: {
102
+ x: scroll?.x,
103
+ y: scroll?.y || DEFAULT_SCROLL_HEIGHT,
104
+ scrollToFirstRowOnChange: false
105
+ },
106
+ virtual: infiniteScroll,
107
+ rowHeight: DEFAULT_ROW_HEIGHT
108
+ }, rest), children);
109
+ };
110
+ CapTable.propTypes = {
111
+ id: PropTypes.string.isRequired,
112
+ className: PropTypes.string,
113
+ children: PropTypes.node,
114
+ infiniteScroll: PropTypes.bool,
115
+ pagination: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
116
+ dataSource: PropTypes.array,
117
+ offset_limit: PropTypes.object,
118
+ setPagination: PropTypes.func,
119
+ scroll: PropTypes.object,
120
+ showLoader: PropTypes.bool
121
+ };
122
+ export default LocaleHoc(CapTable, {
123
+ key: 'CapTable'
124
+ });
@@ -0,0 +1,2 @@
1
+ import CapTableLoadable from './loadable';
2
+ export default CapTableLoadable;
@@ -0,0 +1,8 @@
1
+ import CapSkeleton from '../CapSkeleton';
2
+ import { loadable } from '@capillarytech/cap-ui-utils';
3
+ import React, { Suspense } from 'react';
4
+ const LoadableComponent = loadable(() => import('./CapTable'));
5
+ const CapTableLoadable = props => /*#__PURE__*/React.createElement(Suspense, {
6
+ fallback: /*#__PURE__*/React.createElement(CapSkeleton, null)
7
+ }, /*#__PURE__*/React.createElement(LoadableComponent, props));
8
+ export default CapTableLoadable;
@@ -0,0 +1,17 @@
1
+ import { Table } from 'antd';
2
+ import styled from 'styled-components';
3
+ import * as styledVars from '../styled/variables';
4
+ const {
5
+ CAP_G09,
6
+ CAP_G01,
7
+ CAP_G06,
8
+ CAP_G07,
9
+ CAP_G10,
10
+ SPACING_16,
11
+ SPACING_24,
12
+ FONT_SIZE_S
13
+ } = styledVars;
14
+ export const StyledTable = styled(Table).withConfig({
15
+ displayName: "StyledTable",
16
+ componentId: "sc-1ldu1k4-0"
17
+ })(["&.cap-table-v2{.ant-table{border:1px solid ", ";}}&.show-loader{.ant-table-body > table > tbody::after{content:'", "';display:flex;justify-content:center;position:absolute;width:100%;align-items:center;height:60px;text-align:center;font-size:16px;color:gray;border-top:1px solid ", ";}}.ant-table{border:1px solid ", ";.ant-table-thead > tr > th{color:", ";font-size:", ";line-height:", ";background-color:", ";text-align:left;}.ant-table-thead > tr > th,.ant-table-tbody > tr > td{padding:", " ", ";}.ant-table-tbody > tr > td{border-bottom:1px solid ", ";}.ant-table-tbody > tr:last-child > td{border-bottom:none;}.ant-table-thead > tr.ant-table-row-hover:not(.ant-table-expanded-row) > td,.ant-table-tbody > tr.ant-table-row-hover:not(.ant-table-expanded-row) > td,.ant-table-thead > tr:hover:not(.ant-table-expanded-row) > td,.ant-table-tbody > tr:hover:not(.ant-table-expanded-row) > td{background-color:", ";}.ant-table-thead > tr > th .ant-table-column-sorter-up,.ant-table-thead > tr > th .ant-table-column-sorter-down{&.active{color:", ";}&:not(.active){color:", ";}}.ant-table-thead{.table-children{padding:6px ", " 16px;position:relative;}.table-parent{padding-bottom:0;padding-left:", ";}.table-children.show-separator:not(:last-child)::after{content:'';height:8px;width:1px;right:0;top:30%;background-color:", ";position:absolute;}}.ant-table-thead > tr > th .ant-table-column-sorter{vertical-align:unset;}.ant-table-body table{table-layout:fixed;width:100%;}}&.no-pagination-loader{.ant-table-body > table > tbody::after{content:'';height:unset;display:none;}}&.hide-hover{.ant-table{.ant-table-thead > tr.ant-table-row-hover:not(.ant-table-expanded-row) > td,.ant-table-tbody > tr.ant-table-row-hover:not(.ant-table-expanded-row) > td,.ant-table-thead > tr:hover:not(.ant-table-expanded-row) > td,.ant-table-tbody > tr:hover:not(.ant-table-expanded-row) > td{background:none;}}}a{color:", ";}"], CAP_G07, props => props.loadMoreData, CAP_G07, CAP_G07, CAP_G01, FONT_SIZE_S, SPACING_16, CAP_G10, SPACING_16, SPACING_24, CAP_G07, CAP_G09, CAP_G01, CAP_G06, SPACING_24, SPACING_24, CAP_G07, CAP_G01);
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Select } from 'antd';
4
+
5
+ /**
6
+ * Test component to verify Ant Design v5 Select integration
7
+ * This is a simple wrapper for testing purposes only
8
+ */
9
+ const CapTestSelect = props => {
10
+ return /*#__PURE__*/React.createElement(Select, props);
11
+ };
12
+ CapTestSelect.propTypes = {
13
+ // Common Select props from antd
14
+ allowClear: PropTypes.bool,
15
+ defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))]),
16
+ disabled: PropTypes.bool,
17
+ loading: PropTypes.bool,
18
+ mode: PropTypes.oneOf(['multiple', 'tags']),
19
+ placeholder: PropTypes.string,
20
+ showSearch: PropTypes.bool,
21
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))]),
22
+ options: PropTypes.arrayOf(PropTypes.shape({
23
+ label: PropTypes.node,
24
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
25
+ disabled: PropTypes.bool
26
+ }))
27
+ };
28
+ CapTestSelect.defaultProps = {
29
+ allowClear: false,
30
+ disabled: false,
31
+ loading: false,
32
+ showSearch: false
33
+ };
34
+ export default CapTestSelect;
@@ -0,0 +1 @@
1
+ export { default } from './CapTestSelect';