@onerjs/shared-ui-components 8.25.1 → 8.25.3
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.
- package/constToOptionsMaps.js +2 -2
- package/constToOptionsMaps.js.map +1 -1
- package/fluent/hoc/propertyLines/inputPropertyLine.d.ts +7 -3
- package/fluent/hoc/propertyLines/inputPropertyLine.js +6 -2
- package/fluent/hoc/propertyLines/inputPropertyLine.js.map +1 -1
- package/fluent/hoc/propertyLines/vectorPropertyLine.d.ts +4 -0
- package/fluent/hoc/propertyLines/vectorPropertyLine.js +3 -3
- package/fluent/hoc/propertyLines/vectorPropertyLine.js.map +1 -1
- package/fluent/primitives/accordion.js +27 -3
- package/fluent/primitives/accordion.js.map +1 -1
- package/fluent/primitives/collapse.d.ts +1 -0
- package/fluent/primitives/collapse.js +2 -1
- package/fluent/primitives/collapse.js.map +1 -1
- package/fluent/primitives/colorPicker.d.ts +2 -6
- package/fluent/primitives/colorPicker.js +41 -48
- package/fluent/primitives/colorPicker.js.map +1 -1
- package/fluent/primitives/infoLabel.d.ts +13 -0
- package/fluent/primitives/infoLabel.js +11 -0
- package/fluent/primitives/infoLabel.js.map +1 -0
- package/fluent/primitives/primitive.d.ts +5 -0
- package/fluent/primitives/primitive.js.map +1 -1
- package/fluent/primitives/spinButton.d.ts +9 -3
- package/fluent/primitives/spinButton.js +100 -16
- package/fluent/primitives/spinButton.js.map +1 -1
- package/fluent/primitives/switch.js +1 -1
- package/fluent/primitives/switch.js.map +1 -1
- package/fluent/primitives/syncedSlider.d.ts +2 -0
- package/fluent/primitives/syncedSlider.js +6 -10
- package/fluent/primitives/syncedSlider.js.map +1 -1
- package/fluent/primitives/textInput.d.ts +6 -0
- package/fluent/primitives/textInput.js +48 -0
- package/fluent/primitives/textInput.js.map +1 -0
- package/fluent/primitives/toggleButton.d.ts +1 -0
- package/fluent/primitives/toggleButton.js +2 -2
- package/fluent/primitives/toggleButton.js.map +1 -1
- package/lines/textInputLineComponent.js +3 -4
- package/lines/textInputLineComponent.js.map +1 -1
- package/package.json +1 -1
- package/fluent/primitives/input.d.ts +0 -10
- package/fluent/primitives/input.js +0 -41
- package/fluent/primitives/input.js.map +0 -1
|
@@ -2,9 +2,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Component } from "react";
|
|
3
3
|
import { conflictingValuesPlaceholder } from "./targetsProxy.js";
|
|
4
4
|
import { InputArrowsComponent } from "./inputArrowsComponent.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { TextInput, NumberInput } from "../fluent/primitives/input.js";
|
|
5
|
+
import { TextInputPropertyLine, NumberInputPropertyLine } from "../fluent/hoc/propertyLines/inputPropertyLine.js";
|
|
6
|
+
import { TextAreaPropertyLine } from "../fluent/hoc/propertyLines/textAreaPropertyLine.js";
|
|
8
7
|
import { ToolContext } from "../fluent/hoc/fluentToolWrapper.js";
|
|
9
8
|
let ThrottleTimerId = -1;
|
|
10
9
|
export class TextInputLineComponent extends Component {
|
|
@@ -141,7 +140,7 @@ export class TextInputLineComponent extends Component {
|
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
renderFluent(value, placeholder, step) {
|
|
144
|
-
return (_jsx(
|
|
143
|
+
return this.props.multilines ? (_jsx(TextAreaPropertyLine, { label: this.props.label || "", value: this.state.value, onChange: (val) => this.updateValue(val), disabled: this.props.disabled })) : this.props.numeric ? (_jsx(NumberInputPropertyLine, { label: this.props.label || "", value: this.getCurrentNumericValue(value), onChange: (val) => this.updateValue(val.toString()), step: step, disabled: this.props.disabled })) : (_jsx(TextInputPropertyLine, { label: this.props.label || "", value: value, onChange: (val) => this.updateValue(val.toString()), disabled: this.props.disabled }));
|
|
145
144
|
}
|
|
146
145
|
renderOriginal(value, placeholder, step) {
|
|
147
146
|
const className = this.props.multilines ? "textInputArea" : this.props.unit !== undefined ? "textInputLine withUnits" : "textInputLine";
|
|
@@ -1 +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IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC;QACpI,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACpE,OAAO,CACH,KAAC,WAAW,CAAC,QAAQ,cAChB,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,GAC1G,CAC1B,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type { ReactNode, KeyboardEvent } from \"react\";\r\nimport { Component } from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport { InputArrowsComponent } from \"./inputArrowsComponent\";\r\nimport { PropertyLine } from \"../fluent/hoc/propertyLines/propertyLine\";\r\nimport { Textarea } from \"../fluent/primitives/textarea\";\r\nimport { TextInput, NumberInput } from \"../fluent/primitives/input\";\r\nimport { ToolContext } from \"../fluent/hoc/fluentToolWrapper\";\r\n\r\nexport interface ITextInputLineComponentProps {\r\n label?: string;\r\n lockObject?: LockObject;\r\n target?: any;\r\n propertyName?: string;\r\n value?: string;\r\n onChange?: (value: string) => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n icon?: string;\r\n iconLabel?: string;\r\n noUnderline?: boolean;\r\n numbersOnly?: boolean;\r\n delayInput?: boolean;\r\n arrows?: boolean;\r\n arrowsIncrement?: (amount: number) => void;\r\n step?: number;\r\n numeric?: boolean;\r\n roundValues?: boolean;\r\n min?: number;\r\n max?: number;\r\n placeholder?: string;\r\n unit?: ReactNode;\r\n validator?: (value: string) => boolean;\r\n multilines?: boolean;\r\n throttlePropertyChangedNotification?: boolean;\r\n throttlePropertyChangedNotificationDelay?: number;\r\n disabled?: boolean;\r\n}\r\n\r\nlet ThrottleTimerId = -1;\r\n\r\nexport class TextInputLineComponent extends Component<ITextInputLineComponentProps, { value: string; dragging: boolean }> {\r\n private _localChange = false;\r\n\r\n constructor(props: ITextInputLineComponentProps) {\r\n super(props);\r\n\r\n const emptyValue = this.props.numeric ? \"0\" : \"\";\r\n\r\n this.state = {\r\n value: (this.props.value !== undefined ? this.props.value : this.props.target[this.props.propertyName!]) || emptyValue,\r\n dragging: false,\r\n };\r\n }\r\n\r\n override componentWillUnmount() {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: ITextInputLineComponentProps, nextState: { value: string; dragging: boolean }) {\r\n if (this._localChange) {\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n const newValue = nextProps.value !== undefined ? nextProps.value : nextProps.target[nextProps.propertyName!];\r\n if (newValue !== nextState.value) {\r\n nextState.value = newValue || \"\";\r\n return true;\r\n }\r\n\r\n if (nextState.dragging != this.state.dragging || nextProps.unit !== this.props.unit) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n raiseOnPropertyChanged(newValue: string, previousValue: string) {\r\n if (this.props.onChange) {\r\n this.props.onChange(newValue);\r\n return;\r\n }\r\n\r\n if (!this.props.onPropertyChangedObservable) {\r\n return;\r\n }\r\n\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName!,\r\n value: newValue,\r\n initialValue: previousValue,\r\n });\r\n }\r\n\r\n getCurrentNumericValue(value: string) {\r\n const numeric = parseFloat(value);\r\n if (!isNaN(numeric)) {\r\n return numeric;\r\n }\r\n if (this.props.placeholder !== undefined) {\r\n const placeholderNumeric = parseFloat(this.props.placeholder);\r\n if (!isNaN(placeholderNumeric)) {\r\n return placeholderNumeric;\r\n }\r\n }\r\n return 0;\r\n }\r\n\r\n updateValue(value: string, valueToValidate?: string) {\r\n if (this.props.disabled) {\r\n return;\r\n }\r\n if (this.props.numbersOnly) {\r\n if (/[^0-9.px%-]/g.test(value)) {\r\n return;\r\n }\r\n if (!value) {\r\n value = \"0\";\r\n }\r\n\r\n //Removing starting zero if there is a number of a minus after it.\r\n if (value.search(/0+[0-9-]/g) === 0) {\r\n value = value.substring(1);\r\n }\r\n }\r\n\r\n if (this.props.numeric) {\r\n let numericValue = this.getCurrentNumericValue(value);\r\n if (this.props.roundValues) {\r\n numericValue = Math.round(numericValue);\r\n }\r\n if (this.props.min !== undefined) {\r\n numericValue = Math.max(this.props.min, numericValue);\r\n }\r\n if (this.props.max !== undefined) {\r\n numericValue = Math.min(this.props.max, numericValue);\r\n }\r\n value = numericValue.toString();\r\n }\r\n\r\n this._localChange = true;\r\n const store = this.props.value !== undefined ? this.props.value : this.props.target[this.props.propertyName!];\r\n\r\n if (this.props.validator && valueToValidate) {\r\n if (this.props.validator(valueToValidate) == false) {\r\n value = store;\r\n }\r\n }\r\n\r\n this.setState({ value: value });\r\n\r\n if (this.props.propertyName && !this.props.delayInput) {\r\n this.props.target[this.props.propertyName] = value;\r\n }\r\n\r\n if (this.props.throttlePropertyChangedNotification) {\r\n if (ThrottleTimerId >= 0) {\r\n window.clearTimeout(ThrottleTimerId);\r\n }\r\n ThrottleTimerId = window.setTimeout(() => {\r\n this.raiseOnPropertyChanged(value, store);\r\n }, this.props.throttlePropertyChangedNotificationDelay ?? 200);\r\n } else {\r\n this.raiseOnPropertyChanged(value, store);\r\n }\r\n }\r\n\r\n incrementValue(amount: number) {\r\n if (this.props.step) {\r\n amount *= this.props.step;\r\n }\r\n if (this.props.arrowsIncrement) {\r\n this.props.arrowsIncrement(amount);\r\n return;\r\n }\r\n const currentValue = this.getCurrentNumericValue(this.state.value);\r\n this.updateValue((currentValue + amount).toFixed(2));\r\n }\r\n\r\n onKeyDown(event: KeyboardEvent) {\r\n if (!this.props.disabled && this.props.arrows) {\r\n if (event.key === \"ArrowUp\") {\r\n this.incrementValue(1);\r\n event.preventDefault();\r\n }\r\n if (event.key === \"ArrowDown\") {\r\n this.incrementValue(-1);\r\n event.preventDefault();\r\n }\r\n }\r\n }\r\n\r\n renderFluent(value: string, placeholder: string, step: number) {\r\n return (\r\n <PropertyLine label={this.props.label || \"\"}>\r\n {this.props.multilines ? (\r\n <Textarea value={this.state.value} onChange={(val) => this.updateValue(val)} disabled={this.props.disabled} />\r\n ) : this.props.numeric ? (\r\n <NumberInput value={this.getCurrentNumericValue(value)} onChange={(val) => this.updateValue(val.toString())} step={step} disabled={this.props.disabled} />\r\n ) : (\r\n <TextInput value={value} onChange={(val) => this.updateValue(val.toString())} step={step} disabled={this.props.disabled} />\r\n )}\r\n </PropertyLine>\r\n );\r\n }\r\n\r\n renderOriginal(value: string, placeholder: string, step: number) {\r\n const className = this.props.multilines ? \"textInputArea\" : this.props.unit !== undefined ? \"textInputLine withUnits\" : \"textInputLine\";\r\n return (\r\n <div className={className}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} color=\"black\" className=\"icon\" />}\r\n {this.props.label !== undefined && (\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n {this.props.multilines && (\r\n <>\r\n <textarea\r\n className={this.props.disabled ? \"disabled\" : \"\"}\r\n value={this.state.value}\r\n onFocus={() => {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = true;\r\n }\r\n }}\r\n onChange={(evt) => this.updateValue(evt.target.value)}\r\n onKeyDown={(evt) => {\r\n if (evt.keyCode !== 13) {\r\n return;\r\n }\r\n this.updateValue(this.state.value);\r\n }}\r\n onBlur={(evt) => {\r\n this.updateValue(evt.target.value, evt.target.value);\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n }}\r\n disabled={this.props.disabled}\r\n />\r\n </>\r\n )}\r\n {!this.props.multilines && (\r\n <div\r\n className={`value${this.props.noUnderline === true ? \" noUnderline\" : \"\"}${this.props.arrows ? \" hasArrows\" : \"\"}${this.state.dragging ? \" dragging\" : \"\"}`}\r\n >\r\n <input\r\n className={this.props.disabled ? \"disabled\" : \"\"}\r\n value={value}\r\n onBlur={(evt) => {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n this.updateValue((this.props.value !== undefined ? this.props.value : this.props.target[this.props.propertyName!]) || \"\", evt.target.value);\r\n }}\r\n onFocus={() => {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = true;\r\n }\r\n }}\r\n onChange={(evt) => this.updateValue(evt.target.value)}\r\n onKeyDown={(evt) => this.onKeyDown(evt)}\r\n placeholder={placeholder}\r\n type={this.props.numeric ? \"number\" : \"text\"}\r\n step={step}\r\n disabled={this.props.disabled}\r\n />\r\n {this.props.arrows && (\r\n <InputArrowsComponent incrementValue={(amount) => this.incrementValue(amount)} setDragging={(dragging) => this.setState({ dragging })} />\r\n )}\r\n </div>\r\n )}\r\n {this.props.unit}\r\n </div>\r\n );\r\n }\r\n override render() {\r\n const value = this.state.value === conflictingValuesPlaceholder ? \"\" : this.state.value;\r\n const placeholder = this.state.value === conflictingValuesPlaceholder ? conflictingValuesPlaceholder : this.props.placeholder || \"\";\r\n const step = this.props.step || (this.props.roundValues ? 1 : 0.01);\r\n return (\r\n <ToolContext.Consumer>\r\n {({ useFluent }) => (useFluent ? this.renderFluent(value, placeholder, step) : this.renderOriginal(value, placeholder, step))}\r\n </ToolContext.Consumer>\r\n );\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"textInputLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/textInputLineComponent.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,OAAO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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACpE,OAAO,CACH,KAAC,WAAW,CAAC,QAAQ,cAChB,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,GAC1G,CAC1B,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type { ReactNode, KeyboardEvent } from \"react\";\r\nimport { Component } from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport { InputArrowsComponent } from \"./inputArrowsComponent\";\r\nimport { TextInputPropertyLine, NumberInputPropertyLine } from \"../fluent/hoc/propertyLines/inputPropertyLine\";\r\nimport { TextAreaPropertyLine } from \"../fluent/hoc/propertyLines/textAreaPropertyLine\";\r\nimport { ToolContext } from \"../fluent/hoc/fluentToolWrapper\";\r\n\r\nexport interface ITextInputLineComponentProps {\r\n label?: string;\r\n lockObject?: LockObject;\r\n target?: any;\r\n propertyName?: string;\r\n value?: string;\r\n onChange?: (value: string) => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n icon?: string;\r\n iconLabel?: string;\r\n noUnderline?: boolean;\r\n numbersOnly?: boolean;\r\n delayInput?: boolean;\r\n arrows?: boolean;\r\n arrowsIncrement?: (amount: number) => void;\r\n step?: number;\r\n numeric?: boolean;\r\n roundValues?: boolean;\r\n min?: number;\r\n max?: number;\r\n placeholder?: string;\r\n unit?: ReactNode;\r\n validator?: (value: string) => boolean;\r\n multilines?: boolean;\r\n throttlePropertyChangedNotification?: boolean;\r\n throttlePropertyChangedNotificationDelay?: number;\r\n disabled?: boolean;\r\n}\r\n\r\nlet ThrottleTimerId = -1;\r\n\r\nexport class TextInputLineComponent extends Component<ITextInputLineComponentProps, { value: string; dragging: boolean }> {\r\n private _localChange = false;\r\n\r\n constructor(props: ITextInputLineComponentProps) {\r\n super(props);\r\n\r\n const emptyValue = this.props.numeric ? \"0\" : \"\";\r\n\r\n this.state = {\r\n value: (this.props.value !== undefined ? this.props.value : this.props.target[this.props.propertyName!]) || emptyValue,\r\n dragging: false,\r\n };\r\n }\r\n\r\n override componentWillUnmount() {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: ITextInputLineComponentProps, nextState: { value: string; dragging: boolean }) {\r\n if (this._localChange) {\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n const newValue = nextProps.value !== undefined ? nextProps.value : nextProps.target[nextProps.propertyName!];\r\n if (newValue !== nextState.value) {\r\n nextState.value = newValue || \"\";\r\n return true;\r\n }\r\n\r\n if (nextState.dragging != this.state.dragging || nextProps.unit !== this.props.unit) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n raiseOnPropertyChanged(newValue: string, previousValue: string) {\r\n if (this.props.onChange) {\r\n this.props.onChange(newValue);\r\n return;\r\n }\r\n\r\n if (!this.props.onPropertyChangedObservable) {\r\n return;\r\n }\r\n\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName!,\r\n value: newValue,\r\n initialValue: previousValue,\r\n });\r\n }\r\n\r\n getCurrentNumericValue(value: string) {\r\n const numeric = parseFloat(value);\r\n if (!isNaN(numeric)) {\r\n return numeric;\r\n }\r\n if (this.props.placeholder !== undefined) {\r\n const placeholderNumeric = parseFloat(this.props.placeholder);\r\n if (!isNaN(placeholderNumeric)) {\r\n return placeholderNumeric;\r\n }\r\n }\r\n return 0;\r\n }\r\n\r\n updateValue(value: string, valueToValidate?: string) {\r\n if (this.props.disabled) {\r\n return;\r\n }\r\n if (this.props.numbersOnly) {\r\n if (/[^0-9.px%-]/g.test(value)) {\r\n return;\r\n }\r\n if (!value) {\r\n value = \"0\";\r\n }\r\n\r\n //Removing starting zero if there is a number of a minus after it.\r\n if (value.search(/0+[0-9-]/g) === 0) {\r\n value = value.substring(1);\r\n }\r\n }\r\n\r\n if (this.props.numeric) {\r\n let numericValue = this.getCurrentNumericValue(value);\r\n if (this.props.roundValues) {\r\n numericValue = Math.round(numericValue);\r\n }\r\n if (this.props.min !== undefined) {\r\n numericValue = Math.max(this.props.min, numericValue);\r\n }\r\n if (this.props.max !== undefined) {\r\n numericValue = Math.min(this.props.max, numericValue);\r\n }\r\n value = numericValue.toString();\r\n }\r\n\r\n this._localChange = true;\r\n const store = this.props.value !== undefined ? this.props.value : this.props.target[this.props.propertyName!];\r\n\r\n if (this.props.validator && valueToValidate) {\r\n if (this.props.validator(valueToValidate) == false) {\r\n value = store;\r\n }\r\n }\r\n\r\n this.setState({ value: value });\r\n\r\n if (this.props.propertyName && !this.props.delayInput) {\r\n this.props.target[this.props.propertyName] = value;\r\n }\r\n\r\n if (this.props.throttlePropertyChangedNotification) {\r\n if (ThrottleTimerId >= 0) {\r\n window.clearTimeout(ThrottleTimerId);\r\n }\r\n ThrottleTimerId = window.setTimeout(() => {\r\n this.raiseOnPropertyChanged(value, store);\r\n }, this.props.throttlePropertyChangedNotificationDelay ?? 200);\r\n } else {\r\n this.raiseOnPropertyChanged(value, store);\r\n }\r\n }\r\n\r\n incrementValue(amount: number) {\r\n if (this.props.step) {\r\n amount *= this.props.step;\r\n }\r\n if (this.props.arrowsIncrement) {\r\n this.props.arrowsIncrement(amount);\r\n return;\r\n }\r\n const currentValue = this.getCurrentNumericValue(this.state.value);\r\n this.updateValue((currentValue + amount).toFixed(2));\r\n }\r\n\r\n onKeyDown(event: KeyboardEvent) {\r\n if (!this.props.disabled && this.props.arrows) {\r\n if (event.key === \"ArrowUp\") {\r\n this.incrementValue(1);\r\n event.preventDefault();\r\n }\r\n if (event.key === \"ArrowDown\") {\r\n this.incrementValue(-1);\r\n event.preventDefault();\r\n }\r\n }\r\n }\r\n\r\n renderFluent(value: string, placeholder: string, step: number) {\r\n return this.props.multilines ? (\r\n <TextAreaPropertyLine label={this.props.label || \"\"} value={this.state.value} onChange={(val) => this.updateValue(val)} disabled={this.props.disabled} />\r\n ) : this.props.numeric ? (\r\n <NumberInputPropertyLine\r\n label={this.props.label || \"\"}\r\n value={this.getCurrentNumericValue(value)}\r\n onChange={(val) => this.updateValue(val.toString())}\r\n step={step}\r\n disabled={this.props.disabled}\r\n />\r\n ) : (\r\n <TextInputPropertyLine label={this.props.label || \"\"} value={value} onChange={(val) => this.updateValue(val.toString())} disabled={this.props.disabled} />\r\n );\r\n }\r\n\r\n renderOriginal(value: string, placeholder: string, step: number) {\r\n const className = this.props.multilines ? \"textInputArea\" : this.props.unit !== undefined ? \"textInputLine withUnits\" : \"textInputLine\";\r\n return (\r\n <div className={className}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} color=\"black\" className=\"icon\" />}\r\n {this.props.label !== undefined && (\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n {this.props.multilines && (\r\n <>\r\n <textarea\r\n className={this.props.disabled ? \"disabled\" : \"\"}\r\n value={this.state.value}\r\n onFocus={() => {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = true;\r\n }\r\n }}\r\n onChange={(evt) => this.updateValue(evt.target.value)}\r\n onKeyDown={(evt) => {\r\n if (evt.keyCode !== 13) {\r\n return;\r\n }\r\n this.updateValue(this.state.value);\r\n }}\r\n onBlur={(evt) => {\r\n this.updateValue(evt.target.value, evt.target.value);\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n }}\r\n disabled={this.props.disabled}\r\n />\r\n </>\r\n )}\r\n {!this.props.multilines && (\r\n <div\r\n className={`value${this.props.noUnderline === true ? \" noUnderline\" : \"\"}${this.props.arrows ? \" hasArrows\" : \"\"}${this.state.dragging ? \" dragging\" : \"\"}`}\r\n >\r\n <input\r\n className={this.props.disabled ? \"disabled\" : \"\"}\r\n value={value}\r\n onBlur={(evt) => {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n this.updateValue((this.props.value !== undefined ? this.props.value : this.props.target[this.props.propertyName!]) || \"\", evt.target.value);\r\n }}\r\n onFocus={() => {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = true;\r\n }\r\n }}\r\n onChange={(evt) => this.updateValue(evt.target.value)}\r\n onKeyDown={(evt) => this.onKeyDown(evt)}\r\n placeholder={placeholder}\r\n type={this.props.numeric ? \"number\" : \"text\"}\r\n step={step}\r\n disabled={this.props.disabled}\r\n />\r\n {this.props.arrows && (\r\n <InputArrowsComponent incrementValue={(amount) => this.incrementValue(amount)} setDragging={(dragging) => this.setState({ dragging })} />\r\n )}\r\n </div>\r\n )}\r\n {this.props.unit}\r\n </div>\r\n );\r\n }\r\n override render() {\r\n const value = this.state.value === conflictingValuesPlaceholder ? \"\" : this.state.value;\r\n const placeholder = this.state.value === conflictingValuesPlaceholder ? conflictingValuesPlaceholder : this.props.placeholder || \"\";\r\n const step = this.props.step || (this.props.roundValues ? 1 : 0.01);\r\n return (\r\n <ToolContext.Consumer>\r\n {({ useFluent }) => (useFluent ? this.renderFluent(value, placeholder, step) : this.renderOriginal(value, placeholder, step))}\r\n </ToolContext.Consumer>\r\n );\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { FunctionComponent } from "react";
|
|
2
|
-
import type { PrimitiveProps } from "./primitive.js";
|
|
3
|
-
export type InputProps<T extends string | number> = PrimitiveProps<T> & {
|
|
4
|
-
step?: number;
|
|
5
|
-
placeholder?: string;
|
|
6
|
-
min?: number;
|
|
7
|
-
max?: number;
|
|
8
|
-
};
|
|
9
|
-
export declare const NumberInput: FunctionComponent<InputProps<number>>;
|
|
10
|
-
export declare const TextInput: FunctionComponent<InputProps<string>>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { Input as FluentInput, makeStyles } from "@fluentui/react-components";
|
|
4
|
-
const useInputStyles = makeStyles({
|
|
5
|
-
text: {
|
|
6
|
-
height: "auto",
|
|
7
|
-
textAlign: "right",
|
|
8
|
-
minWidth: "100px", // Min width for text input
|
|
9
|
-
},
|
|
10
|
-
number: {
|
|
11
|
-
height: "auto",
|
|
12
|
-
minWidth: "40px", // Min width for number input
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
/**
|
|
16
|
-
* This is an input text box that stops propagation of change events and sets its width based on the type of input (text or number)
|
|
17
|
-
* @param props
|
|
18
|
-
* @returns
|
|
19
|
-
*/
|
|
20
|
-
const Input = (props) => {
|
|
21
|
-
const classes = useInputStyles();
|
|
22
|
-
const [value, setValue] = useState(props.value ?? "");
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
setValue(props.value ?? ""); // Update local state when props.value changes
|
|
25
|
-
}, [props.value]);
|
|
26
|
-
const handleChange = (event, _) => {
|
|
27
|
-
event.stopPropagation(); // Prevent event propagation
|
|
28
|
-
const value = props.type === "number" ? Number(event.target.value) : String(event.target.value);
|
|
29
|
-
props.onChange(value); // Call the original onChange handler passed as prop
|
|
30
|
-
setValue(value); // Update local state with the new value
|
|
31
|
-
};
|
|
32
|
-
const handleKeyDown = (event) => {
|
|
33
|
-
event.stopPropagation(); // Prevent event propagation
|
|
34
|
-
};
|
|
35
|
-
return (_jsx(FluentInput, { ...props, size: "small", value: value.toString(), className: props.type === "number" ? classes.number : classes.text, onChange: handleChange, onKeyDown: handleKeyDown }));
|
|
36
|
-
};
|
|
37
|
-
const NumberInputCast = Input;
|
|
38
|
-
const TextInputCast = Input;
|
|
39
|
-
export const NumberInput = (props) => _jsx(NumberInputCast, { ...props, type: "number" });
|
|
40
|
-
export const TextInput = (props) => _jsx(TextInputCast, { ...props, type: "text" });
|
|
41
|
-
//# sourceMappingURL=input.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/primitives/input.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAG9E,MAAM,cAAc,GAAG,UAAU,CAAC;IAC9B,IAAI,EAAE;QACF,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,OAAO,EAAE,2BAA2B;KACjD;IACD,MAAM,EAAE;QACJ,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,MAAM,EAAE,6BAA6B;KAClD;CACJ,CAAC,CAAC;AAQH;;;;GAIG;AACH,MAAM,KAAK,GAAiF,CAAC,KAAK,EAAE,EAAE;IAClG,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAEtD,SAAS,CAAC,GAAG,EAAE;QACX,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,8CAA8C;IAC/E,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAElB,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAE,CAAU,EAAE,EAAE;QACtE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,4BAA4B;QACrD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,oDAAoD;QAC3E,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,wCAAwC;IAC7D,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,KAAsC,EAAE,EAAE;QAC7D,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,4BAA4B;IACzD,CAAC,CAAC;IAEF,OAAO,CACH,KAAC,WAAW,OACJ,KAAK,EACT,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,EACvB,SAAS,EAAE,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAClE,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,aAAa,GAC1B,CACL,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,KAAmE,CAAC;AAC5F,MAAM,aAAa,GAAG,KAAiE,CAAC;AAExF,MAAM,CAAC,MAAM,WAAW,GAA0C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAC,eAAe,OAAK,KAAK,EAAE,IAAI,EAAC,QAAQ,GAAG,CAAC;AAC1H,MAAM,CAAC,MAAM,SAAS,GAA0C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAC,aAAa,OAAK,KAAK,EAAE,IAAI,EAAC,MAAM,GAAG,CAAC","sourcesContent":["import type { FunctionComponent, KeyboardEvent, ChangeEvent } from \"react\";\r\nimport { useEffect, useState } from \"react\";\r\n\r\nimport { Input as FluentInput, makeStyles } from \"@fluentui/react-components\";\r\nimport type { PrimitiveProps } from \"./primitive\";\r\n\r\nconst useInputStyles = makeStyles({\r\n text: {\r\n height: \"auto\",\r\n textAlign: \"right\",\r\n minWidth: \"100px\", // Min width for text input\r\n },\r\n number: {\r\n height: \"auto\",\r\n minWidth: \"40px\", // Min width for number input\r\n },\r\n});\r\n\r\nexport type InputProps<T extends string | number> = PrimitiveProps<T> & {\r\n step?: number;\r\n placeholder?: string;\r\n min?: number;\r\n max?: number;\r\n};\r\n/**\r\n * This is an input text box that stops propagation of change events and sets its width based on the type of input (text or number)\r\n * @param props\r\n * @returns\r\n */\r\nconst Input: FunctionComponent<InputProps<string | number> & { type: \"text\" | \"number\" }> = (props) => {\r\n const classes = useInputStyles();\r\n const [value, setValue] = useState(props.value ?? \"\");\r\n\r\n useEffect(() => {\r\n setValue(props.value ?? \"\"); // Update local state when props.value changes\r\n }, [props.value]);\r\n\r\n const handleChange = (event: ChangeEvent<HTMLInputElement>, _: unknown) => {\r\n event.stopPropagation(); // Prevent event propagation\r\n const value = props.type === \"number\" ? Number(event.target.value) : String(event.target.value);\r\n props.onChange(value); // Call the original onChange handler passed as prop\r\n setValue(value); // Update local state with the new value\r\n };\r\n\r\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\r\n event.stopPropagation(); // Prevent event propagation\r\n };\r\n\r\n return (\r\n <FluentInput\r\n {...props}\r\n size=\"small\"\r\n value={value.toString()}\r\n className={props.type === \"number\" ? classes.number : classes.text}\r\n onChange={handleChange}\r\n onKeyDown={handleKeyDown}\r\n />\r\n );\r\n};\r\n\r\nconst NumberInputCast = Input as FunctionComponent<InputProps<number> & { type: \"number\" }>;\r\nconst TextInputCast = Input as FunctionComponent<InputProps<string> & { type: \"text\" }>;\r\n\r\nexport const NumberInput: FunctionComponent<InputProps<number>> = (props) => <NumberInputCast {...props} type=\"number\" />;\r\nexport const TextInput: FunctionComponent<InputProps<string>> = (props) => <TextInputCast {...props} type=\"text\" />;\r\n"]}
|