Read | Write | Execute |
---|
+ {PERM_MAP[(value / 0o100) & 0o7]}
+ {PERM_MAP[(value / 0o010) & 0o7]}
+ {PERM_MAP[(value / 0o001) & 0o7]}
+
+
+ >;
+ }
+ public getError() {
+ const { newValue } = this.state;
+ const { validator, optional } = this.props;
+ if (newValue === undefined) {
+ if (optional) return null;
+ return 'No value given';
+ } else if (Number.isNaN(Number(newValue))) {
+ return 'Not a number';
+ }
+ return validator ? validator(newValue!) : null;
+ }
+ public getValue(): number | undefined {
+ const { newValue, oldValue } = this.state;
+ if (newValue === undefined) {
+ return this.props.optional ? newValue : Number(oldValue);
+ }
+ return typeof newValue === 'number' ? newValue : (Number(newValue) || undefined);
+ }
+ public setPart(part: number, checked: boolean): void {
+ this.setState(({ newValue }) => ({
+ newValue: checked ? (newValue || 0) | part : (newValue || 0) & ~part
+ }), () => this.props.onChange(this.getValue()));
+ }
+}
\ No newline at end of file