@event-calendar/core
Advanced tools
Comparing version 3.6.2 to 3.7.0
{ | ||
"name": "@event-calendar/core", | ||
"version": "3.6.2", | ||
"version": "3.7.0", | ||
"title": "Event Calendar Core package", | ||
@@ -5,0 +5,0 @@ "description": "Full-sized drag & drop event calendar with resource & timeline views", |
@@ -8,2 +8,3 @@ export * from './lib/a11y.js'; | ||
export * from './lib/options.js'; | ||
export * from './lib/payload.js'; | ||
export * from './lib/resources.js'; | ||
@@ -10,0 +11,0 @@ export * from './lib/stores.js'; |
@@ -1,2 +0,2 @@ | ||
import {symbol} from './utils.js'; | ||
import {hasPayload} from './payload.js'; | ||
@@ -38,15 +38,2 @@ export function createElement(tag, className, content, attrs = []) { | ||
let payloadProp = symbol(); | ||
export function setPayload(el, payload) { | ||
el[payloadProp] = payload; | ||
} | ||
export function hasPayload(el) { | ||
return !!el?.[payloadProp]; | ||
} | ||
export function getPayload(el) { | ||
return el[payloadProp]; | ||
} | ||
export function getElementWithPayload(x, y, root = document) { | ||
@@ -53,0 +40,0 @@ for (let el of root.elementsFromPoint(x, y)) { |
@@ -0,11 +1,39 @@ | ||
import {setPayload} from './payload.js'; | ||
export function createResources(input) { | ||
return input.map(resource => ({ | ||
id: String(resource.id), | ||
title: resource.title || '', | ||
eventBackgroundColor: resource.eventBackgroundColor, | ||
eventTextColor: resource.eventTextColor, | ||
extendedProps: resource.extendedProps ?? {} | ||
})); | ||
let result = []; | ||
_createResources(input, 0, result); | ||
return result; | ||
} | ||
function _createResources(input, level, flat) { | ||
let result = []; | ||
for (let item of input) { | ||
let resource = createResource(item); | ||
result.push(resource); | ||
flat.push(resource); | ||
let payload = { | ||
level, | ||
children: [], | ||
expanded: true, | ||
hidden: false | ||
}; | ||
setPayload(resource, payload); | ||
if (item.children) { | ||
payload.children = _createResources(item.children, level + 1, flat); | ||
} | ||
} | ||
return result; | ||
} | ||
export function createResource(input) { | ||
return { | ||
id: String(input.id), | ||
title: input.title || '', | ||
eventBackgroundColor: input.eventBackgroundColor, | ||
eventTextColor: input.eventTextColor, | ||
extendedProps: input.extendedProps ?? {} | ||
}; | ||
} | ||
export function resourceBackgroundColor(event, resources) { | ||
@@ -12,0 +40,0 @@ return findResource(event, resources)?.eventBackgroundColor; |
@@ -5,2 +5,3 @@ import {derived} from 'svelte/store'; | ||
import {createResources} from './resources.js'; | ||
import {getPayload} from './payload.js'; | ||
@@ -71,3 +72,3 @@ export function intl(locale, format) { | ||
([$resources, $filterResourcesWithEvents, $_events, $_activeRange]) => { | ||
let result = $resources; | ||
let result = $resources.filter(resource => !getPayload(resource).hidden); | ||
@@ -74,0 +75,0 @@ if ($filterResourcesWithEvents) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
235031
32
4595
2993