@jamesrock/rockjs 1.26.0 → 1.28.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.
- package/index.js +15 -15
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -19,7 +19,7 @@ export const isTiny = () => !minWidth(450);
|
|
|
19
19
|
export const isDarkMode = () => isColorScheme('dark');
|
|
20
20
|
export const makeEven = (a) => (a % 2 === 1 ? a - 1 : a);
|
|
21
21
|
export const limit = (value, max) => (value > max ? max : value);
|
|
22
|
-
export const
|
|
22
|
+
export const pad = (a) => a < 10 ? `0${a}` : a;
|
|
23
23
|
export const formatNumber = (n) => numberFormatter.format(n);
|
|
24
24
|
export const formatCurrency = (n) => currencyFormatter.format(n);
|
|
25
25
|
export const formatDate = (date, type = 'short') => date.toLocaleDateString('en-GB', { dateStyle: type });
|
|
@@ -34,8 +34,8 @@ export const ceilTo = (number, to = 1) => (Math.ceil(number*to)/to);
|
|
|
34
34
|
export const getXPercentOfY = (x, y) => (y*(x/100));
|
|
35
35
|
export const getXAsPercentOfY = (x, y) => ((x/y)*100);
|
|
36
36
|
// to be removed
|
|
37
|
-
export const formatMinutes = (ms) =>
|
|
38
|
-
export const formatSeconds = (ms) =>
|
|
37
|
+
export const formatMinutes = (ms) => pad(Math.floor((ms % (1000 * 60 * 60)) / (1000 * 60)));
|
|
38
|
+
export const formatSeconds = (ms) => pad(Math.floor((ms % (1000 * 60)) / 1000));
|
|
39
39
|
export const formatTime = (ms) => `${formatMinutes(ms)}:${formatSeconds(ms)}`;
|
|
40
40
|
|
|
41
41
|
const sortingMethods = {
|
|
@@ -167,15 +167,15 @@ export const createLabel = (label = '{label}', id = '{id}', className) => {
|
|
|
167
167
|
return node;
|
|
168
168
|
};
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
const node = createNode('div',
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
170
|
+
const makeToggle = (options, name, defaultValue, className = 'toggle') => {
|
|
171
|
+
const node = createNode('div', className);
|
|
172
|
+
options.forEach(([label, value, optionClassName]) => {
|
|
173
|
+
const optionNode = createNode('div', 'toggle-item');
|
|
174
|
+
const radioNode = createRadio(value, name, `${name}-${value}`, value===defaultValue);
|
|
175
|
+
const labelNode = createLabel(label, radioNode.id, optionClassName);
|
|
176
|
+
optionNode.appendChild(radioNode);
|
|
177
|
+
optionNode.appendChild(labelNode);
|
|
178
|
+
node.appendChild(optionNode);
|
|
179
179
|
});
|
|
180
180
|
return node;
|
|
181
181
|
};
|
|
@@ -653,9 +653,9 @@ export class Time {
|
|
|
653
653
|
getSecondsInMinute(ms) {
|
|
654
654
|
return floorTo(this.getMillisecondsInMinute(ms) / this.second);
|
|
655
655
|
};
|
|
656
|
-
formatSeconds = (ms) =>
|
|
657
|
-
formatMinutes = (ms) =>
|
|
658
|
-
formatHours = (ms) =>
|
|
656
|
+
formatSeconds = (ms) => pad(this.getSecondsInMinute(ms));
|
|
657
|
+
formatMinutes = (ms) => pad(this.getMinutesInHour(ms));
|
|
658
|
+
formatHours = (ms) => pad(this.getHours(ms));
|
|
659
659
|
format = (ms) => `${this.formatMinutes(ms)}:${this.formatSeconds(ms)}`;
|
|
660
660
|
};
|
|
661
661
|
|