@ally-ui/solid
Advanced tools
Comparing version 0.0.19 to 0.0.20
@@ -91,7 +91,3 @@ 'use strict'; | ||
function Slot(slotProps) { | ||
const mergeProps = slotProps.mergeProps ?? ((a, b) => ({ ...a, | ||
...b | ||
})); // `asChild` is never updated dynamically, so an early return here is okay. | ||
// `asChild` is never updated dynamically, so an early return here is okay. | ||
if (slotProps.props.asChild) { | ||
@@ -117,2 +113,36 @@ return web.memo(() => slotProps.props.children(userProps => ({ | ||
function mergeProps(slotProps, childProps) { | ||
// All child props should override. | ||
const overrideProps = { ...childProps | ||
}; | ||
for (const propName in childProps) { | ||
const slotPropValue = slotProps[propName]; | ||
const childPropValue = childProps[propName]; | ||
const isHandler = /^on[A-Z]/.test(propName); // If it's a handler, modify the override by composing the base handler. | ||
if (isHandler) { | ||
overrideProps[propName] = (...args) => { | ||
childPropValue?.(...args); | ||
slotPropValue?.(...args); | ||
}; | ||
} // If it's `style`, we merge them. | ||
else if (propName === 'style') { | ||
overrideProps[propName] = { ...slotPropValue, | ||
...childPropValue | ||
}; | ||
} else if (propName === 'class') { | ||
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' '); | ||
} else if (propName === 'classList') { | ||
overrideProps[propName] = { ...slotPropValue, | ||
...childPropValue | ||
}; | ||
} | ||
} | ||
return { ...slotProps, | ||
...overrideProps | ||
}; | ||
} | ||
exports.Slot = Slot; | ||
@@ -119,0 +149,0 @@ exports.combinedRef = combinedRef; |
@@ -87,7 +87,3 @@ import { onCleanup, createEffect, untrack, splitProps } from 'solid-js'; | ||
function Slot(slotProps) { | ||
const mergeProps = slotProps.mergeProps ?? ((a, b) => ({ ...a, | ||
...b | ||
})); // `asChild` is never updated dynamically, so an early return here is okay. | ||
// `asChild` is never updated dynamically, so an early return here is okay. | ||
if (slotProps.props.asChild) { | ||
@@ -113,3 +109,37 @@ return memo(() => slotProps.props.children(userProps => ({ | ||
function mergeProps(slotProps, childProps) { | ||
// All child props should override. | ||
const overrideProps = { ...childProps | ||
}; | ||
for (const propName in childProps) { | ||
const slotPropValue = slotProps[propName]; | ||
const childPropValue = childProps[propName]; | ||
const isHandler = /^on[A-Z]/.test(propName); // If it's a handler, modify the override by composing the base handler. | ||
if (isHandler) { | ||
overrideProps[propName] = (...args) => { | ||
childPropValue?.(...args); | ||
slotPropValue?.(...args); | ||
}; | ||
} // If it's `style`, we merge them. | ||
else if (propName === 'style') { | ||
overrideProps[propName] = { ...slotPropValue, | ||
...childPropValue | ||
}; | ||
} else if (propName === 'class') { | ||
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' '); | ||
} else if (propName === 'classList') { | ||
overrideProps[propName] = { ...slotPropValue, | ||
...childPropValue | ||
}; | ||
} | ||
} | ||
return { ...slotProps, | ||
...overrideProps | ||
}; | ||
} | ||
export { Slot, combinedRef, createBindRef, createDelayedBindRef, createSyncedOption, forwardEvent }; | ||
//# sourceMappingURL=main.js.map |
@@ -6,3 +6,2 @@ import { splitProps } from 'solid-js'; | ||
export function Slot(slotProps) { | ||
const mergeProps = slotProps.mergeProps ?? ((a, b) => ({ ...a, ...b })); | ||
// `asChild` is never updated dynamically, so an early return here is okay. | ||
@@ -29,1 +28,30 @@ if (slotProps.props.asChild) { | ||
} | ||
function mergeProps(slotProps, childProps) { | ||
// All child props should override. | ||
const overrideProps = { ...childProps }; | ||
for (const propName in childProps) { | ||
const slotPropValue = slotProps[propName]; | ||
const childPropValue = childProps[propName]; | ||
const isHandler = /^on[A-Z]/.test(propName); | ||
// If it's a handler, modify the override by composing the base handler. | ||
if (isHandler) { | ||
overrideProps[propName] = (...args) => { | ||
childPropValue?.(...args); | ||
slotPropValue?.(...args); | ||
}; | ||
} | ||
// If it's `style`, we merge them. | ||
else if (propName === 'style') { | ||
overrideProps[propName] = { ...slotPropValue, ...childPropValue }; | ||
} | ||
else if (propName === 'class') { | ||
overrideProps[propName] = [slotPropValue, childPropValue] | ||
.filter(Boolean) | ||
.join(' '); | ||
} | ||
else if (propName === 'classList') { | ||
overrideProps[propName] = { ...slotPropValue, ...childPropValue }; | ||
} | ||
} | ||
return { ...slotProps, ...overrideProps }; | ||
} |
@@ -47,8 +47,2 @@ import { Accessor, JSX, ParentProps } from 'solid-js'; | ||
children: (props: RegularRenderProp<TAttributes>) => JSX.Element; | ||
/** | ||
* How attributes should be merged with user props. | ||
* | ||
* Defaults to merging user props **over** attributes. | ||
*/ | ||
mergeProps?: (attributes: TAttributes, userProps: TRegularProps) => TRegularProps; | ||
} | ||
@@ -55,0 +49,0 @@ /** |
{ | ||
"name": "@ally-ui/solid", | ||
"version": "0.0.19", | ||
"version": "0.0.20", | ||
"scripts": { | ||
@@ -29,3 +29,3 @@ "example": "vite", | ||
".": { | ||
"solid": "./dist/source/main.js", | ||
"solid": "./dist/source/main.jsx", | ||
"import": "./dist/esm/main.js", | ||
@@ -40,3 +40,3 @@ "require": "./dist/cjs/main.js" | ||
}, | ||
"gitHead": "e054ec991dade6ac231147744ff4a6a8b214175b" | ||
"gitHead": "7333c399ccb0f74f93baad914ccec56adcfa68f0" | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
42254
491
0