@imposium-hub/components 1.60.9 → 1.60.11
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/dist/cjs/Util.d.ts +1 -0
- package/dist/cjs/Util.js +41 -1
- package/dist/cjs/Util.js.map +1 -1
- package/dist/cjs/components/assets/AssetsTableTagsPivot.js +1 -1
- package/dist/cjs/components/assets/AssetsTableTagsPivot.js.map +1 -1
- package/dist/cjs/components/controlled-list/ControlledList.stories.js +1 -1
- package/dist/cjs/components/data-table/DataTable.js +2 -2
- package/dist/cjs/components/data-table/DataTable.js.map +1 -1
- package/dist/cjs/components/smpte-field/SMPTEField.d.ts +4 -3
- package/dist/cjs/components/smpte-field/SMPTEField.js +25 -57
- package/dist/cjs/components/smpte-field/SMPTEField.js.map +1 -1
- package/dist/cjs/components/story-previewer/StoryPreviewer.js +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/Util.d.ts +1 -0
- package/dist/esm/Util.js +39 -0
- package/dist/esm/Util.js.map +1 -1
- package/dist/esm/components/assets/AssetsTableTagsPivot.js +1 -1
- package/dist/esm/components/assets/AssetsTableTagsPivot.js.map +1 -1
- package/dist/esm/components/controlled-list/ControlledList.stories.js +1 -1
- package/dist/esm/components/data-table/DataTable.js +2 -2
- package/dist/esm/components/data-table/DataTable.js.map +1 -1
- package/dist/esm/components/smpte-field/SMPTEField.d.ts +4 -3
- package/dist/esm/components/smpte-field/SMPTEField.js +26 -58
- package/dist/esm/components/smpte-field/SMPTEField.js.map +1 -1
- package/dist/esm/components/story-previewer/StoryPreviewer.js +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/styles.css +2 -0
- package/dist/styles.less +2 -0
- package/less/components/determinate-loader.less +1 -0
- package/less/components/story-previewer.less +1 -0
- package/package.json +2 -2
- package/src/Util.ts +52 -0
- package/src/components/assets/AssetsTableTagsPivot.tsx +1 -1
- package/src/components/controlled-list/ControlledList.stories.tsx +1 -1
- package/src/components/data-table/DataTable.tsx +2 -2
- package/src/components/smpte-field/SMPTEField.tsx +30 -68
- package/src/components/story-previewer/StoryPreviewer.tsx +1 -1
- package/src/index.ts +3 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import FieldWrapper from '../field-wrapper/FieldWrapper';
|
|
3
3
|
import { IToolTipConfig } from '../Tooltip';
|
|
4
|
-
import Timecode from 'smpte-timecode';
|
|
5
4
|
import { TIMECODE } from '../../constants/timecode';
|
|
6
|
-
import {
|
|
5
|
+
import { getSMPTE } from '../../Util';
|
|
7
6
|
|
|
8
7
|
interface ISMPTEFieldProps {
|
|
9
8
|
label?: string;
|
|
@@ -12,6 +11,7 @@ interface ISMPTEFieldProps {
|
|
|
12
11
|
tooltip?: IToolTipConfig | string;
|
|
13
12
|
width?: string | number;
|
|
14
13
|
onChange?(e): void;
|
|
14
|
+
onBlur?(e): void;
|
|
15
15
|
info?: string;
|
|
16
16
|
labelPosition?: string;
|
|
17
17
|
labelWidth?: string | number;
|
|
@@ -73,88 +73,49 @@ class SMPTEField extends React.PureComponent<ISMPTEFieldProps, ISMPTEFieldState>
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
private
|
|
76
|
+
private onBlur(e?) {
|
|
77
77
|
const val = e ? e.target.value : this.inputRef.current.value;
|
|
78
|
-
|
|
79
|
-
const isValidSMPTETimeCode = new RegExp(this.regex);
|
|
80
|
-
const error = isValidSMPTETimeCode.test(val);
|
|
78
|
+
const isValid = this.smptValidator(val);
|
|
81
79
|
|
|
82
80
|
if (e && e.key === 'Enter') {
|
|
83
|
-
this.setDuration(
|
|
81
|
+
this.setDuration(isValid, val);
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
if (e === undefined) {
|
|
87
|
-
this.setDuration(
|
|
85
|
+
this.setDuration(isValid, val);
|
|
88
86
|
}
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
private
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
this.setState({
|
|
100
|
-
error: !error,
|
|
101
|
-
errorMsg: TIMECODE.ERROR
|
|
102
|
-
});
|
|
89
|
+
private onChange() {
|
|
90
|
+
const val = this.inputRef.current.value;
|
|
91
|
+
const isValid = this.smptValidator(val);
|
|
92
|
+
|
|
93
|
+
if (isValid) {
|
|
94
|
+
this.props.onChange(val);
|
|
103
95
|
}
|
|
104
96
|
}
|
|
105
97
|
|
|
106
|
-
private
|
|
98
|
+
private setDuration(isValid, val) {
|
|
107
99
|
const { frameRate } = this.props;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
: val.split(':').map(Number);
|
|
114
|
-
|
|
115
|
-
const toFrames = this.toFrames(valArray, rates);
|
|
116
|
-
|
|
117
|
-
let duration: string = new Timecode(toFrames, rates).toString();
|
|
118
|
-
|
|
119
|
-
if (parseFloat(toFixed(frameRate, 3)) === 29.97) {
|
|
120
|
-
duration = duration.replace(/:(?=[^:]*$)/, ';');
|
|
100
|
+
if (isValid) {
|
|
101
|
+
const smpte = getSMPTE(frameRate, val);
|
|
102
|
+
if (smpte) {
|
|
103
|
+
this.props.onBlur(smpte);
|
|
104
|
+
}
|
|
121
105
|
}
|
|
122
|
-
|
|
123
|
-
this.inputRef.current.value = duration;
|
|
124
|
-
return duration;
|
|
125
106
|
}
|
|
126
107
|
|
|
127
|
-
private
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
let mins = 0;
|
|
132
|
-
let secs = 0;
|
|
133
|
-
let frames = 0;
|
|
134
|
-
|
|
135
|
-
if (length === 1) {
|
|
136
|
-
frames = array[0];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (length === 2) {
|
|
140
|
-
secs = array[0] * rates;
|
|
141
|
-
frames = array[1];
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (length === 3) {
|
|
145
|
-
mins = array[0] * 60 * rates;
|
|
146
|
-
secs = array[1] * rates;
|
|
147
|
-
frames = array[2];
|
|
148
|
-
}
|
|
108
|
+
private smptValidator(val) {
|
|
109
|
+
const isValidSMPTETimeCode = new RegExp(this.regex);
|
|
110
|
+
const isValid = isValidSMPTETimeCode.test(val);
|
|
111
|
+
const errorMsg = isValid ? null : TIMECODE.ERROR;
|
|
149
112
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
frames = array[3];
|
|
155
|
-
}
|
|
113
|
+
this.setState({
|
|
114
|
+
error: !isValid,
|
|
115
|
+
errorMsg
|
|
116
|
+
});
|
|
156
117
|
|
|
157
|
-
return
|
|
118
|
+
return isValid;
|
|
158
119
|
}
|
|
159
120
|
|
|
160
121
|
public render() {
|
|
@@ -175,8 +136,9 @@ class SMPTEField extends React.PureComponent<ISMPTEFieldProps, ISMPTEFieldState>
|
|
|
175
136
|
pattern={this.regex}
|
|
176
137
|
defaultValue={value}
|
|
177
138
|
placeholder={placeholder}
|
|
178
|
-
onBlur={() => this.
|
|
179
|
-
onKeyDown={(e) => this.
|
|
139
|
+
onBlur={() => this.onBlur()}
|
|
140
|
+
onKeyDown={(e) => this.onBlur(e)}
|
|
141
|
+
onChange={(e) => this.onChange()}
|
|
180
142
|
/>
|
|
181
143
|
</FieldWrapper>
|
|
182
144
|
);
|
package/src/index.ts
CHANGED
|
@@ -137,7 +137,8 @@ import {
|
|
|
137
137
|
validateAssetMimetype,
|
|
138
138
|
formatDateDefault,
|
|
139
139
|
validateAccessLevel,
|
|
140
|
-
formattedTime
|
|
140
|
+
formattedTime,
|
|
141
|
+
getSMPTE
|
|
141
142
|
} from './Util';
|
|
142
143
|
import PublishStatusIndicator from './components/publish-wizard/publish/PublishStatusIndicator';
|
|
143
144
|
import { getMediaPreviewStyle } from './utils/assets';
|
|
@@ -264,6 +265,7 @@ export {
|
|
|
264
265
|
mimetypeConformsToOverlay,
|
|
265
266
|
validateAssetMimetype,
|
|
266
267
|
toFixed,
|
|
268
|
+
getSMPTE,
|
|
267
269
|
padStart,
|
|
268
270
|
formatDateDefault,
|
|
269
271
|
ASSET_TYPES,
|