@doubao-apps/template 0.0.34 → 0.0.35-rc.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,3 @@
1
+ export { PriceText, type PriceTextProps } from './price-text/index.js';
2
+ export { Tag, type TagProps } from './tag/index.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { PriceText } from "./price-text/index.js";
2
+ export { Tag } from "./tag/index.js";
@@ -0,0 +1,19 @@
1
+ import type { CSSProperties } from '@lynx-js/types';
2
+ import type { ReactElement, ReactNode } from 'react';
3
+ import './styles.scss';
4
+ export interface PriceTextProps {
5
+ /** 价格前缀,例如「均」。 */
6
+ prefix?: ReactNode;
7
+ /** 主价格,例如「¥1636.92」。 */
8
+ price?: ReactNode;
9
+ /** 价格后缀,例如「价格后缀」。 */
10
+ suffix?: ReactNode;
11
+ /** 辅助标签,例如「销量」。 */
12
+ label?: ReactNode;
13
+ /** 根节点自定义类名。 */
14
+ className?: string;
15
+ /** 根节点自定义样式。 */
16
+ style?: CSSProperties;
17
+ }
18
+ export declare function PriceText(props: PriceTextProps): ReactElement | null;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { clsx } from "clsx";
2
+ import "./styles.css";
3
+ function isPriceTextNodeEmpty(content) {
4
+ return null == content || 'boolean' == typeof content || '' === content;
5
+ }
6
+ function renderPriceTextPart(content, className) {
7
+ if (isPriceTextNodeEmpty(content)) return null;
8
+ if ('string' == typeof content || 'number' == typeof content) return <text className={className} text-maxline="1">
9
+ {content}
10
+ </text>;
11
+ return <view className={clsx(className, `${className}--custom`)}>{content}</view>;
12
+ }
13
+ function PriceText(props) {
14
+ const { prefix, price, suffix, label, className, style } = props;
15
+ const hasContent = [
16
+ prefix,
17
+ price,
18
+ suffix,
19
+ label
20
+ ].some((item)=>!isPriceTextNodeEmpty(item));
21
+ if (!hasContent) return null;
22
+ return <view className={clsx('doubao-price-text', className)} style={style}>
23
+ {renderPriceTextPart(prefix, 'doubao-price-text__prefix')}
24
+ {renderPriceTextPart(price, 'doubao-price-text__price')}
25
+ {renderPriceTextPart(suffix, 'doubao-price-text__suffix')}
26
+ {renderPriceTextPart(label, 'doubao-price-text__label')}
27
+ </view>;
28
+ }
29
+ export { PriceText };
@@ -0,0 +1,74 @@
1
+ .doubao-price-text {
2
+ --doubao-price-text-main-text: var(--neutral-100);
3
+ --doubao-price-text-label-text: var(--neutral-50);
4
+ --doubao-price-text-prefix-font-size: 40px;
5
+ --doubao-price-text-prefix-line-height: 52px;
6
+ --doubao-price-text-prefix-font-weight: 500;
7
+ --doubao-price-text-price-font-size: 56px;
8
+ --doubao-price-text-price-line-height: 68px;
9
+ --doubao-price-text-price-font-weight: 600;
10
+ --doubao-price-text-suffix-font-size: 40px;
11
+ --doubao-price-text-suffix-line-height: 52px;
12
+ --doubao-price-text-suffix-font-weight: 500;
13
+ --doubao-price-text-label-font-size: 40px;
14
+ --doubao-price-text-label-line-height: 52px;
15
+ --doubao-price-text-label-font-weight: 400;
16
+ --doubao-price-text-suffix-margin-left: 12px;
17
+ --doubao-price-text-label-margin-left: 16px;
18
+ width: 100%;
19
+ min-width: 0;
20
+ color: var(--doubao-price-text-main-text);
21
+ white-space: nowrap;
22
+ flex-direction: row;
23
+ align-items: flex-end;
24
+ font-family: PingFang SC, sans-serif;
25
+ font-style: normal;
26
+ display: flex;
27
+ overflow: hidden;
28
+ }
29
+
30
+ .doubao-price-text__prefix, .doubao-price-text__price, .doubao-price-text__suffix, .doubao-price-text__label {
31
+ text-overflow: ellipsis;
32
+ white-space: nowrap;
33
+ min-width: 0;
34
+ font-family: PingFang SC, sans-serif;
35
+ font-style: normal;
36
+ overflow: hidden;
37
+ }
38
+
39
+ .doubao-price-text__prefix {
40
+ color: var(--doubao-price-text-main-text);
41
+ font-size: var(--doubao-price-text-prefix-font-size);
42
+ font-weight: var(--doubao-price-text-prefix-font-weight);
43
+ line-height: var(--doubao-price-text-prefix-line-height);
44
+ }
45
+
46
+ .doubao-price-text__price {
47
+ color: var(--doubao-price-text-main-text);
48
+ font-size: var(--doubao-price-text-price-font-size);
49
+ font-weight: var(--doubao-price-text-price-font-weight);
50
+ line-height: var(--doubao-price-text-price-line-height);
51
+ }
52
+
53
+ .doubao-price-text__suffix {
54
+ margin-left: var(--doubao-price-text-suffix-margin-left);
55
+ color: var(--doubao-price-text-main-text);
56
+ font-size: var(--doubao-price-text-suffix-font-size);
57
+ font-weight: var(--doubao-price-text-suffix-font-weight);
58
+ line-height: var(--doubao-price-text-suffix-line-height);
59
+ }
60
+
61
+ .doubao-price-text__label {
62
+ margin-left: var(--doubao-price-text-label-margin-left);
63
+ color: var(--doubao-price-text-label-text);
64
+ font-size: var(--doubao-price-text-label-font-size);
65
+ font-weight: var(--doubao-price-text-label-font-weight);
66
+ line-height: var(--doubao-price-text-label-line-height);
67
+ }
68
+
69
+ .doubao-price-text__prefix--custom, .doubao-price-text__price--custom, .doubao-price-text__suffix--custom, .doubao-price-text__label--custom {
70
+ flex-direction: row;
71
+ align-items: flex-end;
72
+ display: flex;
73
+ }
74
+
@@ -0,0 +1,20 @@
1
+ import type { CSSProperties } from '@lynx-js/types';
2
+ import type { ReactElement, ReactNode } from 'react';
3
+ import type { TemplateText } from '../../types.js';
4
+ import './styles.scss';
5
+ export interface TagProps {
6
+ /** 标签文案;只需要传入文字时使用。 */
7
+ text?: TemplateText;
8
+ /** 标签自定义内容;优先级高于 text。 */
9
+ children?: ReactNode;
10
+ /** 标签文字颜色。 */
11
+ color?: string;
12
+ /** 标签背景色。 */
13
+ background?: string;
14
+ /** 根节点自定义类名。 */
15
+ className?: string;
16
+ /** 根节点自定义样式。 */
17
+ style?: CSSProperties;
18
+ }
19
+ export declare function Tag(props: TagProps): ReactElement | null;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,34 @@
1
+ import { clsx } from "clsx";
2
+ import "./styles.css";
3
+ function isTagNodeEmpty(content) {
4
+ return null == content || 'boolean' == typeof content || '' === content;
5
+ }
6
+ function getTagStyle(color, background, style) {
7
+ const hasColor = null != color && '' !== color;
8
+ const hasBackground = null != background && '' !== background;
9
+ if (!hasColor && !hasBackground) return style;
10
+ const tagStyle = {};
11
+ if (hasColor) tagStyle['--doubao-tag-text'] = color;
12
+ if (hasBackground) tagStyle.backgroundColor = background;
13
+ if (null == style) return tagStyle;
14
+ return {
15
+ ...tagStyle,
16
+ ...style
17
+ };
18
+ }
19
+ function renderTagContent(content) {
20
+ if (isTagNodeEmpty(content)) return null;
21
+ if ('string' == typeof content || 'number' == typeof content) return <text className="doubao-tag__text" text-maxline="1">
22
+ {content}
23
+ </text>;
24
+ return <view className="doubao-tag__custom">{content}</view>;
25
+ }
26
+ function Tag(props) {
27
+ const { text: text1, children, color, background, className, style } = props;
28
+ const content = isTagNodeEmpty(children) ? text1 : children;
29
+ if (isTagNodeEmpty(content)) return null;
30
+ return <view className={clsx('doubao-tag', className)} style={getTagStyle(color, background, style)}>
31
+ {renderTagContent(content)}
32
+ </view>;
33
+ }
34
+ export { Tag };
@@ -0,0 +1,39 @@
1
+ .doubao-tag {
2
+ --doubao-tag-text: var(--primary-50);
3
+ --doubao-tag-radius: 4px;
4
+ --doubao-tag-font-size: 12px;
5
+ --doubao-tag-font-weight: 400;
6
+ --doubao-tag-line-height: 16px;
7
+ box-sizing: border-box;
8
+ max-width: 100%;
9
+ color: var(--doubao-tag-text);
10
+ border-radius: var(--doubao-tag-radius);
11
+ flex-direction: row;
12
+ justify-content: center;
13
+ align-items: center;
14
+ padding: 3px;
15
+ font-family: PingFang SC, sans-serif;
16
+ font-style: normal;
17
+ display: flex;
18
+ overflow: hidden;
19
+ }
20
+
21
+ .doubao-tag__text, .doubao-tag__custom {
22
+ min-width: 0;
23
+ color: var(--doubao-tag-text);
24
+ font-family: PingFang SC, sans-serif;
25
+ font-size: var(--doubao-tag-font-size);
26
+ font-style: normal;
27
+ font-weight: var(--doubao-tag-font-weight);
28
+ line-height: var(--doubao-tag-line-height);
29
+ text-overflow: ellipsis;
30
+ white-space: nowrap;
31
+ overflow: hidden;
32
+ }
33
+
34
+ .doubao-tag__custom {
35
+ flex-direction: row;
36
+ align-items: center;
37
+ display: flex;
38
+ }
39
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doubao-apps/template",
3
- "version": "0.0.34",
3
+ "version": "0.0.35-rc.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -8,6 +8,11 @@
8
8
  "import": "./dist/index.js",
9
9
  "require": "./dist/index.js"
10
10
  },
11
+ "./ui": {
12
+ "types": "./dist/ui/index.d.ts",
13
+ "import": "./dist/ui/index.js",
14
+ "require": "./dist/ui/index.js"
15
+ },
11
16
  "./package.json": "./package.json"
12
17
  },
13
18
  "types": "./dist/index.d.ts",