Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(base-ui): input,input number component (#282)

Dushusir32b3f0dcf92a
diff --git a/packages/base-ui/package.json b/packages/base-ui/package.json
index fd1ec70f46..ef20122da5 100644
--- a/packages/base-ui/package.json
+++ b/packages/base-ui/package.json
@@ -47,7 +47,7 @@
"@rc-component/trigger": "^1.17.0",
"@univerjs/base-render": "workspace:^0.0.1",
"@univerjs/core": "workspace:^0.0.1",
- "@univerjs/icons": "^0.0.5",
+ "@univerjs/icons": "^0.0.6",
"@wendellhu/redi": "^0.12.8",
"localforage": "^1.10.0",
"rc-dropdown": "^4.1.0",
diff --git a/packages/base-ui/src/Components/Icon/Text/index.tsx b/packages/base-ui/src/Components/Icon/Text/index.tsx
index 4e7e3838e6..6bd5506217 100644
--- a/packages/base-ui/src/Components/Icon/Text/index.tsx
+++ b/packages/base-ui/src/Components/Icon/Text/index.tsx
@@ -1,18 +1,18 @@
import {
Autowrap24,
- LeftRotation45Degrees24,
- LeftRotation90Degrees24,
+ LeftRotationFortyFiveDegrees24,
+ LeftRotationNinetyDegrees24,
Overflow24,
- RightRotation45Degrees24,
- RightRotation90Degrees24,
+ RightRotationFortyFiveDegrees24,
+ RightRotationNinetyDegrees24,
TextDown24,
- TextHorizontallyCenter24,
+ TextHorizontallyCentered24,
TextLeft24,
TextRight24,
TextRotation24,
TextUp24,
TextVertical24,
- TextVerticallyCenter24,
+ TextVerticallyCentered24,
Truncation24,
} from '@univerjs/icons';
@@ -20,22 +20,22 @@ import { BaseIconProps } from '../AddIcon';
export const LeftAlignIcon = (props: BaseIconProps) => <TextLeft24 />;
-export const CenterAlignIcon = (props: BaseIconProps) => <TextHorizontallyCenter24 />;
+export const CenterAlignIcon = (props: BaseIconProps) => <TextHorizontallyCentered24 />;
export const RightAlignIcon = (props: BaseIconProps) => <TextRight24 />;
export const TopVerticalIcon = (props: BaseIconProps) => <TextUp24 />;
-export const CenterVerticalIcon = (props: BaseIconProps) => <TextVerticallyCenter24 />;
+export const CenterVerticalIcon = (props: BaseIconProps) => <TextVerticallyCentered24 />;
export const BottomVerticalIcon = (props: BaseIconProps) => <TextDown24 />;
export const TextRotateIcon = (props: BaseIconProps) => <TextRotation24 />;
-export const TextRotateAngleUpIcon = (props: BaseIconProps) => <LeftRotation45Degrees24 />;
-export const TextRotateAngleDownIcon = (props: BaseIconProps) => <RightRotation45Degrees24 />;
+export const TextRotateAngleUpIcon = (props: BaseIconProps) => <LeftRotationFortyFiveDegrees24 />;
+export const TextRotateAngleDownIcon = (props: BaseIconProps) => <RightRotationFortyFiveDegrees24 />;
export const TextRotateVerticalIcon = (props: BaseIconProps) => <TextVertical24 />;
-export const TextRotateRotationUpIcon = (props: BaseIconProps) => <LeftRotation90Degrees24 />;
-export const TextRotateRotationDownIcon = (props: BaseIconProps) => <RightRotation90Degrees24 />;
+export const TextRotateRotationUpIcon = (props: BaseIconProps) => <LeftRotationNinetyDegrees24 />;
+export const TextRotateRotationDownIcon = (props: BaseIconProps) => <RightRotationNinetyDegrees24 />;
export const BrIcon = (props: BaseIconProps) => <Autowrap24 />;
diff --git a/packages/base-ui/src/Components/Input/Style/mixin.less b/packages/base-ui/src/Components/Input/Style/mixin.less
index 3567b414ff..ab86f268cb 100644
--- a/packages/base-ui/src/Components/Input/Style/mixin.less
+++ b/packages/base-ui/src/Components/Input/Style/mixin.less
@@ -1,26 +1,24 @@
@import '../../../Basics/CSS/Skin/default.module.less';
.active() {
- // border-right-width: @border-width-base !important;
outline: 0;
- box-shadow: @box-shadow-base;
+ box-shadow: var(--box-shadow-base);
}
.hover(@color: var(--primary-color-hover)) {
border-color: @color;
- // border-right-width: @border-width-base !important;
}
.disabled() {
- color: var(--disabled-color);
- background-color: var(--disabled-bg);
- border-color: var(--border-color-base);
+ color: var(--grey-200);
+ background-color: var(--bg-color-secondary);
+ border-color: var(--grey-200);
box-shadow: none;
cursor: not-allowed;
opacity: 1;
&:hover {
- .hover(var(--border-color-base));
+ .hover(var(--grey-200));
}
}
@@ -28,16 +26,14 @@
position: relative;
display: inline-block;
width: 100%;
- min-width: 0;
+ height: 100%;
box-sizing: border-box;
- padding: 2px 7px;
+ padding: 10px 20px;
color: var(--text-color);
- font-size: @font-size-base;
- line-height: @line-height-base;
- background-color: @bg-color-secondary;
- background-image: none;
- border: @border-width-base @border-style-base var(--border-color-base);
- border-radius: @border-radius-base;
+ font-size: var(--font-size-base);
+ background-color: var(--bg-color-secondary);
+ border: 1px solid var(--grey-200);
+ border-radius: var(--border-radius-base);
transition: all 0.3s;
&:hover {
@@ -58,16 +54,16 @@
}
&-borderless {
- border: @border-width-base @border-style-base transparent;
+ border: 1px solid transparent;
box-shadow: none;
&:hover {
- border: @border-width-base @border-style-base transparent;
+ border-color: transparent;
}
&:focus,
&-focused {
- border: @border-width-base @border-style-base var(--primary-color-hover);
+ border-color: var(--primary-color-hover);
.active();
}
}
diff --git a/packages/base-ui/src/Components/InputNumber/InputNumber.tsx b/packages/base-ui/src/Components/InputNumber/InputNumber.tsx
index 3a5a6090b7..bf82bf43e1 100644
--- a/packages/base-ui/src/Components/InputNumber/InputNumber.tsx
+++ b/packages/base-ui/src/Components/InputNumber/InputNumber.tsx
@@ -1,3 +1,4 @@
+import { DropdownPromptSmall8 } from '@univerjs/icons';
import React, { useRef, useState } from 'react';
import { BaseComponentProps } from '../../BaseComponent';
@@ -5,6 +6,14 @@ import { joinClassNames } from '../../Utils/util';
import styles from './Style/index.module.less';
export interface BaseInputNumberProps extends BaseComponentProps {
+ /**
+ * Input's class name
+ */
+ className?: string;
+
+ /** Semantic DOM style */
+ style?: React.CSSProperties;
+
/**
* The input content value
*/
@@ -67,6 +76,8 @@ export const InputNumber: React.FC<BaseInputNumberProps> = ({
readonly = false,
disabled = false,
bordered = true,
+ className = '',
+ style = {},
}) => {
const [inputValue, setInputValue] = useState(value);
const ref = useRef<HTMLInputElement>(null);
@@ -130,7 +141,7 @@ export const InputNumber: React.FC<BaseInputNumberProps> = ({
});
return (
- <div className={styles.inputNumber}>
+ <div className={`${styles.inputNumber} ${className}`} style={style}>
<div className={styles.inputWrap}>
<input
ref={ref}
@@ -147,10 +158,14 @@ export const InputNumber: React.FC<BaseInputNumberProps> = ({
<div className={styles.inputButtons} style={{ display: disabled ? 'none' : 'flex' }}>
<button onClick={handleIncrement} className={styles.inputButton}>
- <span>+</span>
+ <span>
+ <DropdownPromptSmall8 style={{ transform: 'rotateZ(180deg)' }} />
+ </span>
</button>
<button onClick={handleDecrement} className={styles.inputButton}>
- <span>-</span>
+ <span>
+ <DropdownPromptSmall8 />
+ </span>
</button>
</div>
</div>
diff --git a/packages/base-ui/src/Components/InputNumber/Style/index.module.less b/packages/base-ui/src/Components/InputNumber/Style/index.module.less
index 40a405b6a2..11afb3b01b 100644
--- a/packages/base-ui/src/Components/InputNumber/Style/index.module.less
+++ b/packages/base-ui/src/Components/InputNumber/Style/index.module.less
@@ -10,41 +10,51 @@
position: relative;
display: flex;
align-items: center;
- width: 150px;
- height: 30px;
+ width: 60px;
+ height: 26px;
&:hover {
.input-buttons {
- opacity: 1;
+ // opacity: 1;
}
}
+ .input{
+ background-color: var(--bg-color-secondary);
+ border: 2px solid var(--primary-color);
+ border-radius: var(--border-radius-base);
+
+ // Center
+ text-align: center;
+ padding-right: 21px;
+ padding: 0 26px 0 4px;
+ }
}
.input-wrap {
position: absolute;
right: 0;
+ height: 100%;
}
.input-buttons {
position: absolute;
right: 1px;
display: flex;
- opacity: 0;
+ // opacity: 0;
flex-direction: column;
transition: opacity 0.1s linear;
.input-button {
- background-color: var(--bg);
+ background-color: transparent;
border-style: solid;
- border-color: var(--border-color-base);
+ border-color: var(--primary-color);
color: var(--text-color);
cursor: pointer;
- height: 13px;
span {
display: block;
- font-size: 7px;
+ font-size: 9px;
text-align: center;
line-height: 0;
}
@@ -52,10 +62,25 @@
}
.input-button:first-child {
- border-width: 0px 0px 1px 1px;
+ border-width: 0px 0px 2px 2px;
+ // padding-top: 1px;
+ height: 13px;
+
+ &:hover{
+ background-color: fade(@primary-color,10%);
+ border-radius: 0px var(--border-radius-base) 0px 0px;
+
+ }
}
.input-button:last-child {
- border-width: 0px 0px 0px 1px;
+ border-width: 0px 0px 0px 2px;
+ // padding-bottom: 1px;
+ height: 11px;
+
+ &:hover{
+ background-color: fade(@primary-color,10%);
+ border-radius: 0px 0px var(--border-radius-base) 0px;
+ }
}
}
\ No newline at end of file
diff --git a/packages/base-ui/src/views/app.module.less b/packages/base-ui/src/views/app.module.less
index cd0e159bcb..6abdb50cbc 100644
--- a/packages/base-ui/src/views/app.module.less
+++ b/packages/base-ui/src/views/app.module.less
@@ -76,4 +76,8 @@
width: 100%;
}
}
+
+ ::selection {
+ background-color: var(--primary-color);
+ }
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b4de2e6d14..fc234370eb 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -143,7 +143,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
examples/univer-sheet-ts:
dependencies:
@@ -228,7 +228,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
examples/univer-slide-ts:
dependencies:
@@ -292,7 +292,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages/base-docs:
dependencies:
@@ -344,7 +344,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages/base-formula-engine:
dependencies:
@@ -384,7 +384,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages/base-numfmt-engine:
dependencies:
@@ -421,7 +421,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages/base-render:
dependencies:
@@ -467,7 +467,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages/base-sheets:
dependencies:
@@ -562,7 +562,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages/base-ui:
dependencies:
@@ -576,8 +576,8 @@ importers:
specifier: workspace:^0.0.1
version: link:../core
'@univerjs/icons':
- specifier: ^0.0.5
+ specifier: ^0.0.6
'@wendellhu/redi':
specifier: ^0.12.8
version: 0.12.8
@@ -687,7 +687,7 @@ importers:
version: 0.19.3
vitest:
specifier: ^0.34.5
packages/core:
dependencies:
@@ -788,7 +788,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages/sheets-plugin-formula:
dependencies:
@@ -843,7 +843,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages/sheets-plugin-image:
dependencies:
@@ -898,7 +898,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages/sheets-plugin-import-xlsx:
dependencies:
@@ -956,7 +956,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages/sheets-plugin-numfmt:
dependencies:
@@ -1011,7 +1011,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages/ui-plugin-docs:
dependencies:
@@ -1057,7 +1057,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages/ui-plugin-sheets:
dependencies:
@@ -1161,7 +1161,7 @@ importers:
version: 10.9.1(@types/[email protected])([email protected])
vitest:
specifier: ^0.34.5
packages:
@@ -5865,8 +5865,8 @@ packages:
eslint-visitor-keys: 3.4.3
dev: true
- resolution: {integrity: sha512-/wJ8p8/ZNwXrlvDRz6rp0RvMlgMLSvL4MWTeuE/7dpE/zLtqsjY96huAwoIDMZkZcGOQn0VqBtUMyZskRlb5GQ==}
+ resolution: {integrity: sha512-gF8QMDk9QVP9Rg4zDEsDGtG00jhTk2v3VStH9C922+3AazZaeSIE4FD34V9hUEWJXz62Nvg8K0657g458yJwTQ==}
peerDependencies:
react: '*'
react-dom: '*'
@@ -5923,7 +5923,7 @@ packages:
std-env: 3.4.3
test-exclude: 6.0.0
v8-to-istanbul: 9.1.0
transitivePeerDependencies:
- supports-color
dev: true