@rokkit/core 1.0.0-next.106 → 1.0.0-next.107

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/index.d.ts CHANGED
@@ -8,5 +8,6 @@ export { FieldMapper } from "./field-mapper.js";
8
8
  export { createEmitter } from "./events.js";
9
9
  export { getLineTypes } from "./connector.js";
10
10
  export { generateTicks } from "./ticks.js";
11
+ export { getValue } from "./mapping.js";
11
12
  export { getItemAtIndex, getIndexForItem } from "./mapped-items.js";
12
13
  export { weekdays, getCalendarDays } from "./calendar.js";
package/dist/utils.d.ts CHANGED
@@ -59,3 +59,10 @@ export function getKeyFromPath(path: string[]): string;
59
59
  * @returns {string[]}
60
60
  */
61
61
  export function getPathFromKey(key: string): string[];
62
+ /**
63
+ * Get snippet function from an object
64
+ * @param {Object} obj
65
+ * @param {string} key
66
+ * @returns {Function|undefined}
67
+ */
68
+ export function getSnippet(obj: Object, key: string): Function | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/core",
3
- "version": "1.0.0-next.106",
3
+ "version": "1.0.0-next.107",
4
4
  "description": "Contains core utility functions and classes that can be used in various components.",
5
5
  "author": "Jerry Thomas <me@jerrythomas.name>",
6
6
  "license": "MIT",
@@ -5,6 +5,7 @@ import { isObject } from './utils.js'
5
5
  export class FieldMapper {
6
6
  #fields = { ...defaultFields }
7
7
  #componentMap = {}
8
+ #childMapper = null
8
9
 
9
10
  constructor(fields = defaultFields, componentMap = {}) {
10
11
  this.#updateFields(fields)
package/src/index.js CHANGED
@@ -16,3 +16,4 @@ export { createEmitter } from './events.js'
16
16
  export { getLineTypes } from './connector.js'
17
17
  export { weekdays, getCalendarDays } from './calendar.js'
18
18
  export { generateTicks } from './ticks.js'
19
+ export { getValue } from './mapping.js'
package/src/utils.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { has } from 'ramda'
2
+
1
3
  /**
2
4
  * Finds the closest ancestor of the given element that has the given attribute.
3
5
  *
@@ -101,3 +103,16 @@ export function getKeyFromPath(path) {
101
103
  export function getPathFromKey(key) {
102
104
  return key.split('-').map(Number)
103
105
  }
106
+
107
+ /**
108
+ * Get snippet function from an object
109
+ * @param {Object} obj
110
+ * @param {string} key
111
+ * @returns {Function|undefined}
112
+ */
113
+ export function getSnippet(obj, key) {
114
+ if (has(key, obj) && typeof obj[key] === 'function') {
115
+ return obj[key]
116
+ }
117
+ return undefined
118
+ }