Comparing version 0.5.21 to 0.5.22
@@ -1,778 +0,16 @@ | ||
import { initDirectivesForSSR, ssrUtils, warn, Fragment, Static, Comment, Text, mergeProps, ssrContextKey, ref, useSlots, computed, onMounted, watch, unref } from 'vue'; | ||
import { ref, useSlots, computed, onMounted, watch, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, withDirectives, createElementVNode, vModelCheckbox, renderSlot, Fragment, createTextVNode, toDisplayString, createCommentVNode, pushScopeId, popScopeId } from 'vue'; | ||
/** | ||
* Make a map and return a function for checking if a key | ||
* is in that map. | ||
* IMPORTANT: all calls of this function must be prefixed with | ||
* \/\*#\_\_PURE\_\_\*\/ | ||
* So that rollup can tree-shake them if necessary. | ||
*/ | ||
function makeMap(str, expectsLowerCase) { | ||
const map = Object.create(null); | ||
const list = str.split(','); | ||
for (let i = 0; i < list.length; i++) { | ||
map[list[i]] = true; | ||
} | ||
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]; | ||
} | ||
function normalizeStyle(value) { | ||
if (isArray(value)) { | ||
const res = {}; | ||
for (let i = 0; i < value.length; i++) { | ||
const item = value[i]; | ||
const normalized = isString(item) | ||
? parseStringStyle(item) | ||
: normalizeStyle(item); | ||
if (normalized) { | ||
for (const key in normalized) { | ||
res[key] = normalized[key]; | ||
} | ||
} | ||
} | ||
return res; | ||
} | ||
else if (isString(value)) { | ||
return value; | ||
} | ||
else if (isObject(value)) { | ||
return value; | ||
} | ||
} | ||
const listDelimiterRE = /;(?![^(]*\))/g; | ||
const propertyDelimiterRE = /:([^]+)/; | ||
const styleCommentRE = /\/\*.*?\*\//gs; | ||
function parseStringStyle(cssText) { | ||
const ret = {}; | ||
cssText | ||
.replace(styleCommentRE, '') | ||
.split(listDelimiterRE) | ||
.forEach(item => { | ||
if (item) { | ||
const tmp = item.split(propertyDelimiterRE); | ||
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim()); | ||
} | ||
}); | ||
return ret; | ||
} | ||
function stringifyStyle(styles) { | ||
let ret = ''; | ||
if (!styles || isString(styles)) { | ||
return ret; | ||
} | ||
for (const key in styles) { | ||
const value = styles[key]; | ||
const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key); | ||
if (isString(value) || typeof value === 'number') { | ||
// only render valid values | ||
ret += `${normalizedKey}:${value};`; | ||
} | ||
} | ||
return ret; | ||
} | ||
function normalizeClass(value) { | ||
let res = ''; | ||
if (isString(value)) { | ||
res = value; | ||
} | ||
else if (isArray(value)) { | ||
for (let i = 0; i < value.length; i++) { | ||
const normalized = normalizeClass(value[i]); | ||
if (normalized) { | ||
res += normalized + ' '; | ||
} | ||
} | ||
} | ||
else if (isObject(value)) { | ||
for (const name in value) { | ||
if (value[name]) { | ||
res += name + ' '; | ||
} | ||
} | ||
} | ||
return res.trim(); | ||
} | ||
// https://developer.mozilla.org/en-US/docs/Web/SVG/Element | ||
const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' + | ||
'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' + | ||
'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' + | ||
'feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' + | ||
'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' + | ||
'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' + | ||
'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' + | ||
'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' + | ||
'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' + | ||
'text,textPath,title,tspan,unknown,use,view'; | ||
const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr'; | ||
/** | ||
* Compiler only. | ||
* Do NOT use in runtime code paths unless behind `(process.env.NODE_ENV !== 'production')` flag. | ||
*/ | ||
const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS); | ||
/** | ||
* Compiler only. | ||
* Do NOT use in runtime code paths unless behind `(process.env.NODE_ENV !== 'production')` flag. | ||
*/ | ||
const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS); | ||
/** | ||
* On the client we only need to offer special cases for boolean attributes that | ||
* have different names from their corresponding dom properties: | ||
* - itemscope -> N/A | ||
* - allowfullscreen -> allowFullscreen | ||
* - formnovalidate -> formNoValidate | ||
* - ismap -> isMap | ||
* - nomodule -> noModule | ||
* - novalidate -> noValidate | ||
* - readonly -> readOnly | ||
*/ | ||
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; | ||
/** | ||
* The full list is needed during SSR to produce the correct initial markup. | ||
*/ | ||
const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs + | ||
`,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` + | ||
`loop,open,required,reversed,scoped,seamless,` + | ||
`checked,muted,multiple,selected`); | ||
/** | ||
* Boolean attributes should be included if the value is truthy or ''. | ||
* e.g. `<select multiple>` compiles to `{ multiple: '' }` | ||
*/ | ||
function includeBooleanAttr(value) { | ||
return !!value || value === ''; | ||
} | ||
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/; | ||
const attrValidationCache = {}; | ||
function isSSRSafeAttrName(name) { | ||
if (attrValidationCache.hasOwnProperty(name)) { | ||
return attrValidationCache[name]; | ||
} | ||
const isUnsafe = unsafeAttrCharRE.test(name); | ||
if (isUnsafe) { | ||
console.error(`unsafe attribute name: ${name}`); | ||
} | ||
return (attrValidationCache[name] = !isUnsafe); | ||
} | ||
const propsToAttrMap = { | ||
acceptCharset: 'accept-charset', | ||
className: 'class', | ||
htmlFor: 'for', | ||
httpEquiv: 'http-equiv' | ||
var _withScopeId = function _withScopeId(n) { | ||
return pushScopeId("data-v-38625b18"), n = n(), popScopeId(), n; | ||
}; | ||
const escapeRE = /["'&<>]/; | ||
function escapeHtml(string) { | ||
const str = '' + string; | ||
const match = escapeRE.exec(str); | ||
if (!match) { | ||
return str; | ||
} | ||
let html = ''; | ||
let escaped; | ||
let index; | ||
let lastIndex = 0; | ||
for (index = match.index; index < str.length; index++) { | ||
switch (str.charCodeAt(index)) { | ||
case 34: // " | ||
escaped = '"'; | ||
break; | ||
case 38: // & | ||
escaped = '&'; | ||
break; | ||
case 39: // ' | ||
escaped = '''; | ||
break; | ||
case 60: // < | ||
escaped = '<'; | ||
break; | ||
case 62: // > | ||
escaped = '>'; | ||
break; | ||
default: | ||
continue; | ||
} | ||
if (lastIndex !== index) { | ||
html += str.slice(lastIndex, index); | ||
} | ||
lastIndex = index + 1; | ||
html += escaped; | ||
} | ||
return lastIndex !== index ? html + str.slice(lastIndex, index) : html; | ||
} | ||
// https://www.w3.org/TR/html52/syntax.html#comments | ||
const commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g; | ||
function escapeHtmlComment(src) { | ||
return src.replace(commentStripRE, ''); | ||
} | ||
function looseCompareArrays(a, b) { | ||
if (a.length !== b.length) | ||
return false; | ||
let equal = true; | ||
for (let i = 0; equal && i < a.length; i++) { | ||
equal = looseEqual(a[i], b[i]); | ||
} | ||
return equal; | ||
} | ||
function looseEqual(a, b) { | ||
if (a === b) | ||
return true; | ||
let aValidType = isDate(a); | ||
let bValidType = isDate(b); | ||
if (aValidType || bValidType) { | ||
return aValidType && bValidType ? a.getTime() === b.getTime() : false; | ||
} | ||
aValidType = isSymbol(a); | ||
bValidType = isSymbol(b); | ||
if (aValidType || bValidType) { | ||
return a === b; | ||
} | ||
aValidType = isArray(a); | ||
bValidType = isArray(b); | ||
if (aValidType || bValidType) { | ||
return aValidType && bValidType ? looseCompareArrays(a, b) : false; | ||
} | ||
aValidType = isObject(a); | ||
bValidType = isObject(b); | ||
if (aValidType || bValidType) { | ||
/* istanbul ignore if: this if will probably never be called */ | ||
if (!aValidType || !bValidType) { | ||
return false; | ||
} | ||
const aKeysCount = Object.keys(a).length; | ||
const bKeysCount = Object.keys(b).length; | ||
if (aKeysCount !== bKeysCount) { | ||
return false; | ||
} | ||
for (const key in a) { | ||
const aHasKey = a.hasOwnProperty(key); | ||
const bHasKey = b.hasOwnProperty(key); | ||
if ((aHasKey && !bHasKey) || | ||
(!aHasKey && bHasKey) || | ||
!looseEqual(a[key], b[key])) { | ||
return false; | ||
} | ||
} | ||
} | ||
return String(a) === String(b); | ||
} | ||
function looseIndexOf(arr, val) { | ||
return arr.findIndex(item => looseEqual(item, val)); | ||
} | ||
/** | ||
* For converting {{ interpolation }} values to displayed strings. | ||
* @private | ||
*/ | ||
const toDisplayString = (val) => { | ||
return isString(val) | ||
? val | ||
: val == null | ||
? '' | ||
: isArray(val) || | ||
(isObject(val) && | ||
(val.toString === objectToString || !isFunction(val.toString))) | ||
? JSON.stringify(val, replacer, 2) | ||
: String(val); | ||
var _hoisted_1$1 = /*#__PURE__*/_withScopeId(function () { | ||
return /*#__PURE__*/createElementVNode("div", { | ||
"class": "hb-checkbox__mark" | ||
}, null, -1 /* HOISTED */); | ||
}); | ||
var _hoisted_2 = { | ||
"class": "hb-checkbox__text" | ||
}; | ||
const replacer = (_key, val) => { | ||
// can't use isRef here since @vue/shared has no deps | ||
if (val && val.__v_isRef) { | ||
return replacer(_key, val.value); | ||
} | ||
else if (isMap(val)) { | ||
return { | ||
[`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => { | ||
entries[`${key} =>`] = val; | ||
return entries; | ||
}, {}) | ||
}; | ||
} | ||
else if (isSet(val)) { | ||
return { | ||
[`Set(${val.size})`]: [...val.values()] | ||
}; | ||
} | ||
else if (isObject(val) && !isArray(val) && !isPlainObject(val)) { | ||
return String(val); | ||
} | ||
return val; | ||
}; | ||
(process.env.NODE_ENV !== 'production') | ||
? Object.freeze({}) | ||
: {}; | ||
(process.env.NODE_ENV !== 'production') ? Object.freeze([]) : []; | ||
const NOOP = () => { }; | ||
const onRE = /^on[^a-z]/; | ||
const isOn = (key) => onRE.test(key); | ||
const isArray = Array.isArray; | ||
const isMap = (val) => toTypeString(val) === '[object Map]'; | ||
const isSet = (val) => toTypeString(val) === '[object Set]'; | ||
const isDate = (val) => toTypeString(val) === '[object Date]'; | ||
const isFunction = (val) => typeof val === 'function'; | ||
const isString = (val) => typeof val === 'string'; | ||
const isSymbol = (val) => typeof val === 'symbol'; | ||
const isObject = (val) => val !== null && typeof val === 'object'; | ||
const isPromise = (val) => { | ||
return isObject(val) && isFunction(val.then) && isFunction(val.catch); | ||
}; | ||
const objectToString = Object.prototype.toString; | ||
const toTypeString = (value) => objectToString.call(value); | ||
const isPlainObject = (val) => toTypeString(val) === '[object Object]'; | ||
const cacheStringFunction = (fn) => { | ||
const cache = Object.create(null); | ||
return ((str) => { | ||
const hit = cache[str]; | ||
return hit || (cache[str] = fn(str)); | ||
}); | ||
}; | ||
const hyphenateRE = /\B([A-Z])/g; | ||
/** | ||
* @private | ||
*/ | ||
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase()); | ||
// leading comma for empty string "" | ||
const shouldIgnoreProp = makeMap(`,key,ref,innerHTML,textContent,ref_key,ref_for`); | ||
function ssrRenderAttrs(props, tag) { | ||
let ret = ''; | ||
for (const key in props) { | ||
if (shouldIgnoreProp(key) || | ||
isOn(key) || | ||
(tag === 'textarea' && key === 'value')) { | ||
continue; | ||
} | ||
const value = props[key]; | ||
if (key === 'class') { | ||
ret += ` class="${ssrRenderClass(value)}"`; | ||
} | ||
else if (key === 'style') { | ||
ret += ` style="${ssrRenderStyle(value)}"`; | ||
} | ||
else { | ||
ret += ssrRenderDynamicAttr(key, value, tag); | ||
} | ||
} | ||
return ret; | ||
} | ||
// render an attr with dynamic (unknown) key. | ||
function ssrRenderDynamicAttr(key, value, tag) { | ||
if (!isRenderableValue(value)) { | ||
return ``; | ||
} | ||
const attrKey = tag && (tag.indexOf('-') > 0 || isSVGTag(tag)) | ||
? key // preserve raw name on custom elements and svg | ||
: propsToAttrMap[key] || key.toLowerCase(); | ||
if (isBooleanAttr(attrKey)) { | ||
return includeBooleanAttr(value) ? ` ${attrKey}` : ``; | ||
} | ||
else if (isSSRSafeAttrName(attrKey)) { | ||
return value === '' ? ` ${attrKey}` : ` ${attrKey}="${escapeHtml(value)}"`; | ||
} | ||
else { | ||
console.warn(`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`); | ||
return ``; | ||
} | ||
} | ||
// Render a v-bind attr with static key. The key is pre-processed at compile | ||
// time and we only need to check and escape value. | ||
function ssrRenderAttr(key, value) { | ||
if (!isRenderableValue(value)) { | ||
return ``; | ||
} | ||
return ` ${key}="${escapeHtml(value)}"`; | ||
} | ||
function isRenderableValue(value) { | ||
if (value == null) { | ||
return false; | ||
} | ||
const type = typeof value; | ||
return type === 'string' || type === 'number' || type === 'boolean'; | ||
} | ||
function ssrRenderClass(raw) { | ||
return escapeHtml(normalizeClass(raw)); | ||
} | ||
function ssrRenderStyle(raw) { | ||
if (!raw) { | ||
return ''; | ||
} | ||
if (isString(raw)) { | ||
return escapeHtml(raw); | ||
} | ||
const styles = normalizeStyle(raw); | ||
return escapeHtml(stringifyStyle(styles)); | ||
} | ||
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) { | ||
// template-compiled slots are always rendered as fragments | ||
push(`<!--[-->`); | ||
ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId); | ||
push(`<!--]-->`); | ||
} | ||
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) { | ||
const slotFn = slots[slotName]; | ||
if (slotFn) { | ||
const slotBuffer = []; | ||
const bufferedPush = (item) => { | ||
slotBuffer.push(item); | ||
}; | ||
const ret = slotFn(slotProps, bufferedPush, parentComponent, slotScopeId ? ' ' + slotScopeId : ''); | ||
if (isArray(ret)) { | ||
// normal slot | ||
renderVNodeChildren(push, ret, parentComponent, slotScopeId); | ||
} | ||
else { | ||
// ssr slot. | ||
// check if the slot renders all comments, in which case use the fallback | ||
let isEmptySlot = true; | ||
if (transition) { | ||
isEmptySlot = false; | ||
} | ||
else { | ||
for (let i = 0; i < slotBuffer.length; i++) { | ||
if (!isComment(slotBuffer[i])) { | ||
isEmptySlot = false; | ||
break; | ||
} | ||
} | ||
} | ||
if (isEmptySlot) { | ||
if (fallbackRenderFn) { | ||
fallbackRenderFn(); | ||
} | ||
} | ||
else { | ||
for (let i = 0; i < slotBuffer.length; i++) { | ||
push(slotBuffer[i]); | ||
} | ||
} | ||
} | ||
} | ||
else if (fallbackRenderFn) { | ||
fallbackRenderFn(); | ||
} | ||
} | ||
const commentTestRE = /^<!--.*-->$/s; | ||
const commentRE = /<!--[^]*?-->/gm; | ||
function isComment(item) { | ||
if (typeof item !== 'string' || !commentTestRE.test(item)) | ||
return false; | ||
// if item is '<!---->' or '<!--[-->' or '<!--]-->', return true directly | ||
if (item.length <= 8) | ||
return true; | ||
return !item.replace(commentRE, '').trim(); | ||
} | ||
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) { | ||
parentPush('<!--teleport start-->'); | ||
const context = parentComponent.appContext.provides[ssrContextKey]; | ||
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {}); | ||
const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []); | ||
// record current index of the target buffer to handle nested teleports | ||
// since the parent needs to be rendered before the child | ||
const bufferIndex = targetBuffer.length; | ||
let teleportContent; | ||
if (disabled) { | ||
contentRenderFn(parentPush); | ||
teleportContent = `<!--teleport anchor-->`; | ||
} | ||
else { | ||
const { getBuffer, push } = createBuffer(); | ||
contentRenderFn(push); | ||
push(`<!--teleport anchor-->`); | ||
teleportContent = getBuffer(); | ||
} | ||
targetBuffer.splice(bufferIndex, 0, teleportContent); | ||
parentPush('<!--teleport end-->'); | ||
} | ||
function ssrInterpolate(value) { | ||
return escapeHtml(toDisplayString(value)); | ||
} | ||
Symbol((process.env.NODE_ENV !== 'production') ? 'iterate' : ''); | ||
Symbol((process.env.NODE_ENV !== 'production') ? 'Map key iterate' : ''); | ||
function ssrLooseContain(arr, value) { | ||
return looseIndexOf(arr, value) > -1; | ||
} | ||
function ssrCompile(template, instance) { | ||
// TODO: this branch should now work in ESM builds, enable it in a minor | ||
{ | ||
throw new Error(`On-the-fly template compilation is not supported in the ESM build of ` + | ||
`@vue/server-renderer. All templates must be pre-compiled into ` + | ||
`render functions.`); | ||
} | ||
} | ||
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode } = ssrUtils; | ||
// Each component has a buffer array. | ||
// A buffer array can contain one of the following: | ||
// - plain string | ||
// - A resolved buffer (recursive arrays of strings that can be unrolled | ||
// synchronously) | ||
// - An async buffer (a Promise that resolves to a resolved buffer) | ||
function createBuffer() { | ||
let appendable = false; | ||
const buffer = []; | ||
return { | ||
getBuffer() { | ||
// Return static buffer and await on items during unroll stage | ||
return buffer; | ||
}, | ||
push(item) { | ||
const isStringItem = isString(item); | ||
if (appendable && isStringItem) { | ||
buffer[buffer.length - 1] += item; | ||
} | ||
else { | ||
buffer.push(item); | ||
} | ||
appendable = isStringItem; | ||
if (isPromise(item) || (isArray(item) && item.hasAsync)) { | ||
// promise, or child buffer with async, mark as async. | ||
// this allows skipping unnecessary await ticks during unroll stage | ||
buffer.hasAsync = true; | ||
} | ||
} | ||
}; | ||
} | ||
function renderComponentVNode(vnode, parentComponent = null, slotScopeId) { | ||
const instance = createComponentInstance(vnode, parentComponent, null); | ||
const res = setupComponent(instance, true /* isSSR */); | ||
const hasAsyncSetup = isPromise(res); | ||
const prefetches = instance.sp; /* LifecycleHooks.SERVER_PREFETCH */ | ||
if (hasAsyncSetup || prefetches) { | ||
let p = hasAsyncSetup | ||
? res | ||
: Promise.resolve(); | ||
if (prefetches) { | ||
p = p | ||
.then(() => Promise.all(prefetches.map(prefetch => prefetch.call(instance.proxy)))) | ||
// Note: error display is already done by the wrapped lifecycle hook function. | ||
.catch(() => { }); | ||
} | ||
return p.then(() => renderComponentSubTree(instance, slotScopeId)); | ||
} | ||
else { | ||
return renderComponentSubTree(instance, slotScopeId); | ||
} | ||
} | ||
function renderComponentSubTree(instance, slotScopeId) { | ||
const comp = instance.type; | ||
const { getBuffer, push } = createBuffer(); | ||
if (isFunction(comp)) { | ||
let root = renderComponentRoot(instance); | ||
// #5817 scope ID attrs not falling through if functional component doesn't | ||
// have props | ||
if (!comp.props) { | ||
for (const key in instance.attrs) { | ||
if (key.startsWith(`data-v-`)) { | ||
(root.props || (root.props = {}))[key] = ``; | ||
} | ||
} | ||
} | ||
renderVNode(push, (instance.subTree = root), instance, slotScopeId); | ||
} | ||
else { | ||
if ((!instance.render || instance.render === NOOP) && | ||
!instance.ssrRender && | ||
!comp.ssrRender && | ||
isString(comp.template)) { | ||
comp.ssrRender = ssrCompile(comp.template); | ||
} | ||
// perf: enable caching of computed getters during render | ||
// since there cannot be state mutations during render. | ||
for (const e of instance.scope.effects) { | ||
if (e.computed) | ||
e.computed._cacheable = true; | ||
} | ||
const ssrRender = instance.ssrRender || comp.ssrRender; | ||
if (ssrRender) { | ||
// optimized | ||
// resolve fallthrough attrs | ||
let attrs = instance.inheritAttrs !== false ? instance.attrs : undefined; | ||
let hasCloned = false; | ||
let cur = instance; | ||
while (true) { | ||
const scopeId = cur.vnode.scopeId; | ||
if (scopeId) { | ||
if (!hasCloned) { | ||
attrs = { ...attrs }; | ||
hasCloned = true; | ||
} | ||
attrs[scopeId] = ''; | ||
} | ||
const parent = cur.parent; | ||
if (parent && parent.subTree && parent.subTree === cur.vnode) { | ||
// parent is a non-SSR compiled component and is rendering this | ||
// component as root. inherit its scopeId if present. | ||
cur = parent; | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
if (slotScopeId) { | ||
if (!hasCloned) | ||
attrs = { ...attrs }; | ||
attrs[slotScopeId.trim()] = ''; | ||
} | ||
// set current rendering instance for asset resolution | ||
const prev = setCurrentRenderingInstance(instance); | ||
try { | ||
ssrRender(instance.proxy, push, instance, attrs, | ||
// compiler-optimized bindings | ||
instance.props, instance.setupState, instance.data, instance.ctx); | ||
} | ||
finally { | ||
setCurrentRenderingInstance(prev); | ||
} | ||
} | ||
else if (instance.render && instance.render !== NOOP) { | ||
renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance, slotScopeId); | ||
} | ||
else { | ||
const componentName = comp.name || comp.__file || `<Anonymous>`; | ||
warn(`Component ${componentName} is missing template or render function.`); | ||
push(`<!---->`); | ||
} | ||
} | ||
return getBuffer(); | ||
} | ||
function renderVNode(push, vnode, parentComponent, slotScopeId) { | ||
const { type, shapeFlag, children } = vnode; | ||
switch (type) { | ||
case Text: | ||
push(escapeHtml(children)); | ||
break; | ||
case Comment: | ||
push(children ? `<!--${escapeHtmlComment(children)}-->` : `<!---->`); | ||
break; | ||
case Static: | ||
push(children); | ||
break; | ||
case Fragment: | ||
if (vnode.slotScopeIds) { | ||
slotScopeId = | ||
(slotScopeId ? slotScopeId + ' ' : '') + vnode.slotScopeIds.join(' '); | ||
} | ||
push(`<!--[-->`); // open | ||
renderVNodeChildren(push, children, parentComponent, slotScopeId); | ||
push(`<!--]-->`); // close | ||
break; | ||
default: | ||
if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) { | ||
renderElementVNode(push, vnode, parentComponent, slotScopeId); | ||
} | ||
else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) { | ||
push(renderComponentVNode(vnode, parentComponent, slotScopeId)); | ||
} | ||
else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) { | ||
renderTeleportVNode(push, vnode, parentComponent, slotScopeId); | ||
} | ||
else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) { | ||
renderVNode(push, vnode.ssContent, parentComponent, slotScopeId); | ||
} | ||
else { | ||
warn('[@vue/server-renderer] Invalid VNode type:', type, `(${typeof type})`); | ||
} | ||
} | ||
} | ||
function renderVNodeChildren(push, children, parentComponent, slotScopeId) { | ||
for (let i = 0; i < children.length; i++) { | ||
renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId); | ||
} | ||
} | ||
function renderElementVNode(push, vnode, parentComponent, slotScopeId) { | ||
const tag = vnode.type; | ||
let { props, children, shapeFlag, scopeId, dirs } = vnode; | ||
let openTag = `<${tag}`; | ||
if (dirs) { | ||
props = applySSRDirectives(vnode, props, dirs); | ||
} | ||
if (props) { | ||
openTag += ssrRenderAttrs(props, tag); | ||
} | ||
if (scopeId) { | ||
openTag += ` ${scopeId}`; | ||
} | ||
// inherit parent chain scope id if this is the root node | ||
let curParent = parentComponent; | ||
let curVnode = vnode; | ||
while (curParent && curVnode === curParent.subTree) { | ||
curVnode = curParent.vnode; | ||
if (curVnode.scopeId) { | ||
openTag += ` ${curVnode.scopeId}`; | ||
} | ||
curParent = curParent.parent; | ||
} | ||
if (slotScopeId) { | ||
openTag += ` ${slotScopeId}`; | ||
} | ||
push(openTag + `>`); | ||
if (!isVoidTag(tag)) { | ||
let hasChildrenOverride = false; | ||
if (props) { | ||
if (props.innerHTML) { | ||
hasChildrenOverride = true; | ||
push(props.innerHTML); | ||
} | ||
else if (props.textContent) { | ||
hasChildrenOverride = true; | ||
push(escapeHtml(props.textContent)); | ||
} | ||
else if (tag === 'textarea' && props.value) { | ||
hasChildrenOverride = true; | ||
push(escapeHtml(props.value)); | ||
} | ||
} | ||
if (!hasChildrenOverride) { | ||
if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) { | ||
push(escapeHtml(children)); | ||
} | ||
else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) { | ||
renderVNodeChildren(push, children, parentComponent, slotScopeId); | ||
} | ||
} | ||
push(`</${tag}>`); | ||
} | ||
} | ||
function applySSRDirectives(vnode, rawProps, dirs) { | ||
const toMerge = []; | ||
for (let i = 0; i < dirs.length; i++) { | ||
const binding = dirs[i]; | ||
const { dir: { getSSRProps } } = binding; | ||
if (getSSRProps) { | ||
const props = getSSRProps(binding, vnode); | ||
if (props) | ||
toMerge.push(props); | ||
} | ||
} | ||
return mergeProps(rawProps || {}, ...toMerge); | ||
} | ||
function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) { | ||
const target = vnode.props && vnode.props.to; | ||
const disabled = vnode.props && vnode.props.disabled; | ||
if (!target) { | ||
if (!disabled) { | ||
warn(`[@vue/server-renderer] Teleport is missing target prop.`); | ||
} | ||
return []; | ||
} | ||
if (!isString(target)) { | ||
warn(`[@vue/server-renderer] Teleport target must be a query selector string.`); | ||
return []; | ||
} | ||
ssrRenderTeleport(push, push => { | ||
renderVNodeChildren(push, vnode.children, parentComponent, slotScopeId); | ||
}, target, disabled || disabled === '', parentComponent); | ||
} | ||
initDirectivesForSSR(); | ||
var script$2 = { | ||
__name: 'index', | ||
__ssrInlineRender: true, | ||
props: { | ||
@@ -814,3 +52,3 @@ modelValue: { | ||
setup: function setup(__props, _ref) { | ||
_ref.emit; | ||
var emit = _ref.emit; | ||
var props = __props; | ||
@@ -833,2 +71,9 @@ var selfModel = ref(false); | ||
}); | ||
var handleChange = function handleChange(evt) { | ||
emit('change', selfModel.value, evt); | ||
emit('update:modelValue', selfModel.value); | ||
}; | ||
var handleClickBracket = function handleClickBracket(evt) { | ||
emit('clickBracket', evt); | ||
}; | ||
onMounted(function () { | ||
@@ -842,19 +87,27 @@ selfModel.value = props.modelValue; | ||
}); | ||
return function (_ctx, _push, _parent, _attrs) { | ||
_push("<div".concat(ssrRenderAttrs(mergeProps({ | ||
"class": unref(className), | ||
style: unref(checkboxStyle) | ||
}, _attrs)), " data-v-38625b18><input type=\"checkbox\"").concat(ssrRenderAttr("id", id)).concat(ssrRenderAttr("name", id), " class=\"hb-checkbox__input\"").concat(includeBooleanAttr(Array.isArray(selfModel.value) ? ssrLooseContain(selfModel.value, null) : selfModel.value) ? " checked" : "", " data-v-38625b18><label class=\"hb-checkbox__label\"").concat(ssrRenderAttr("for", id), " data-v-38625b18><div class=\"hb-checkbox__mark\" data-v-38625b18></div><div class=\"hb-checkbox__text\" data-v-38625b18>")); | ||
if (hasSlot) { | ||
ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent, "data-v-38625b18-s"); | ||
} else { | ||
_push("<!--[-->".concat(ssrInterpolate(props.label), "<!--]-->")); | ||
} | ||
_push("</div></label>"); | ||
if (props.useBracket) { | ||
_push("<i class=\"hb-checkbox__bracket fa-regular fa-chevron-right\" data-v-38625b18></i>"); | ||
} else { | ||
_push("<!---->"); | ||
} | ||
_push("</div>"); | ||
return function (_ctx, _cache) { | ||
return openBlock(), createElementBlock("div", { | ||
"class": normalizeClass(unref(className)), | ||
style: normalizeStyle(unref(checkboxStyle)) | ||
}, [withDirectives(createElementVNode("input", { | ||
type: "checkbox", | ||
id: id, | ||
name: id, | ||
"class": "hb-checkbox__input", | ||
onChange: handleChange, | ||
"onUpdate:modelValue": _cache[0] || (_cache[0] = function ($event) { | ||
return selfModel.value = $event; | ||
}) | ||
}, null, 544 /* HYDRATE_EVENTS, NEED_PATCH */), [[vModelCheckbox, selfModel.value]]), createElementVNode("label", { | ||
"class": "hb-checkbox__label", | ||
"for": id | ||
}, [_hoisted_1$1, createElementVNode("div", _hoisted_2, [hasSlot ? renderSlot(_ctx.$slots, "default", { | ||
key: 0 | ||
}) : (openBlock(), createElementBlock(Fragment, { | ||
key: 1 | ||
}, [createTextVNode(toDisplayString(props.label), 1 /* TEXT */)], 64 /* STABLE_FRAGMENT */))])]), props.useBracket ? (openBlock(), createElementBlock("i", { | ||
key: 0, | ||
"class": "hb-checkbox__bracket fa-regular fa-chevron-right", | ||
onClick: handleClickBracket | ||
})) : createCommentVNode("v-if", true)], 6 /* CLASS, STYLE */); | ||
}; | ||
@@ -971,28 +224,26 @@ } | ||
function ssrRender$1(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) { | ||
_push("<button".concat(ssrRenderAttrs(mergeProps({ | ||
var _hoisted_1 = ["disabled"]; | ||
function render$1(_ctx, _cache, $props, $setup, $data, $options) { | ||
return openBlock(), createElementBlock("button", { | ||
type: "button", | ||
"class": $options.className, | ||
style: $options.buttonStyle, | ||
disabled: $props.disabled | ||
}, _attrs)), " data-v-6210de47>")); | ||
if ($props.icon && $options.computedIconPosition === 'left') { | ||
_push("<i class=\"".concat(ssrRenderClass([$props.icon, "hb-button__icon--left"]), "\" data-v-6210de47></i>")); | ||
} else { | ||
_push("<!---->"); | ||
} | ||
_push("<span class=\"".concat(ssrRenderClass({ | ||
'hb-button__text': $data.hasSlot | ||
}), "\" data-v-6210de47>")); | ||
ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent, "data-v-6210de47-s"); | ||
_push("</span>"); | ||
if ($options.computedIcon && $options.computedIconPosition === 'right') { | ||
_push("<i class=\"".concat(ssrRenderClass([$options.computedIcon, "hb-button__icon--right"]), "\" data-v-6210de47></i>")); | ||
} else { | ||
_push("<!---->"); | ||
} | ||
_push("</button>"); | ||
"class": normalizeClass($options.className), | ||
style: normalizeStyle($options.buttonStyle), | ||
disabled: $props.disabled, | ||
onClick: _cache[0] || (_cache[0] = function () { | ||
return $options.handleClick && $options.handleClick.apply($options, arguments); | ||
}) | ||
}, [$props.icon && $options.computedIconPosition === 'left' ? (openBlock(), createElementBlock("i", { | ||
key: 0, | ||
"class": normalizeClass([$props.icon, "hb-button__icon--left"]) | ||
}, null, 2 /* CLASS */)) : createCommentVNode("v-if", true), createElementVNode("span", { | ||
"class": normalizeClass({ | ||
'hb-button__text': $data.hasSlot | ||
}) | ||
}, [renderSlot(_ctx.$slots, "default")], 2 /* CLASS */), $options.computedIcon && $options.computedIconPosition === 'right' ? (openBlock(), createElementBlock("i", { | ||
key: 1, | ||
"class": normalizeClass([$options.computedIcon, "hb-button__icon--right"]) | ||
}, null, 2 /* CLASS */)) : createCommentVNode("v-if", true)], 14 /* CLASS, STYLE, PROPS */, _hoisted_1); | ||
} | ||
script$1.ssrRender = ssrRender$1; | ||
script$1.render = render$1; | ||
script$1.__scopeId = "data-v-6210de47"; | ||
@@ -1034,12 +285,10 @@ script$1.__file = "docs/.vitepress/components/hb-button/index.vue"; | ||
function ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) { | ||
_push("<div".concat(ssrRenderAttrs(mergeProps({ | ||
"class": $options.className, | ||
style: $options.buttonWrapStyle | ||
}, _attrs)), " data-v-2b59b4a6>")); | ||
ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent, "data-v-2b59b4a6-s"); | ||
_push("</div>"); | ||
function render(_ctx, _cache, $props, $setup, $data, $options) { | ||
return openBlock(), createElementBlock("div", { | ||
"class": normalizeClass($options.className), | ||
style: normalizeStyle($options.buttonWrapStyle) | ||
}, [renderSlot(_ctx.$slots, "default")], 6 /* CLASS, STYLE */); | ||
} | ||
script.ssrRender = ssrRender; | ||
script.render = render; | ||
script.__scopeId = "data-v-2b59b4a6"; | ||
@@ -1046,0 +295,0 @@ script.__file = "docs/.vitepress/components/hb-button-wrap/index.vue"; |
1317
dist/index.js
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.habitUi = {}, global.Vue)); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.habitUi = {}, global.Vue)); | ||
})(this, (function (exports, vue) { 'use strict'; | ||
/** | ||
* Make a map and return a function for checking if a key | ||
* is in that map. | ||
* IMPORTANT: all calls of this function must be prefixed with | ||
* \/\*#\_\_PURE\_\_\*\/ | ||
* So that rollup can tree-shake them if necessary. | ||
*/ | ||
function makeMap(str, expectsLowerCase) { | ||
const map = Object.create(null); | ||
const list = str.split(','); | ||
for (let i = 0; i < list.length; i++) { | ||
map[list[i]] = true; | ||
var _withScopeId = function _withScopeId(n) { | ||
return vue.pushScopeId("data-v-38625b18"), n = n(), vue.popScopeId(), n; | ||
}; | ||
var _hoisted_1$1 = /*#__PURE__*/_withScopeId(function () { | ||
return /*#__PURE__*/vue.createElementVNode("div", { | ||
"class": "hb-checkbox__mark" | ||
}, null, -1 /* HOISTED */); | ||
}); | ||
var _hoisted_2 = { | ||
"class": "hb-checkbox__text" | ||
}; | ||
var script$2 = { | ||
__name: 'index', | ||
props: { | ||
modelValue: { | ||
type: Boolean | ||
}, | ||
label: { | ||
type: String | ||
}, | ||
checked: { | ||
type: Boolean, | ||
"default": false | ||
}, | ||
shape: { | ||
type: String, | ||
"default": 'box', | ||
validator: function validator(value) { | ||
return ['box', 'line'].indexOf(value) !== -1; | ||
} | ||
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]; | ||
} | ||
function normalizeStyle(value) { | ||
if (isArray(value)) { | ||
const res = {}; | ||
for (let i = 0; i < value.length; i++) { | ||
const item = value[i]; | ||
const normalized = isString(item) | ||
? parseStringStyle(item) | ||
: normalizeStyle(item); | ||
if (normalized) { | ||
for (const key in normalized) { | ||
res[key] = normalized[key]; | ||
} | ||
} | ||
} | ||
return res; | ||
}, | ||
size: { | ||
type: String, | ||
"default": 'h4', | ||
validator: function validator(value) { | ||
return ['h2', 'h3', 'h4'].indexOf(value) !== -1; | ||
} | ||
else if (isString(value)) { | ||
return value; | ||
} | ||
else if (isObject(value)) { | ||
return value; | ||
} | ||
}, | ||
useBracket: { | ||
type: Boolean, | ||
"default": false | ||
}, | ||
animation: { | ||
type: Boolean, | ||
"default": false | ||
} | ||
}, | ||
emits: ['update:modelValue', 'change', 'clickBracket'], | ||
setup: function setup(__props, _ref) { | ||
var emit = _ref.emit; | ||
var props = __props; | ||
var selfModel = vue.ref(false); | ||
var slots = vue.useSlots(); | ||
var hasSlot = !!slots['default']; | ||
var id = 'id-' + Math.random().toString(36).substring(2); | ||
var className = vue.computed(function () { | ||
var className = 'hb-checkbox'; | ||
if (props.shape) className += " hb-checkbox--".concat(props.shape); | ||
if (props.size) className += " hb-checkbox--".concat(props.size); | ||
if (props.useBracket) className += " hb-checkbox--bracket"; | ||
if (props.animation) className += " hb-checkbox--animation"; | ||
return className; | ||
}); | ||
var checkboxStyle = vue.computed(function () { | ||
var checkboxStyle = {}; | ||
return checkboxStyle; | ||
}); | ||
var handleChange = function handleChange(evt) { | ||
emit('change', selfModel.value, evt); | ||
emit('update:modelValue', selfModel.value); | ||
}; | ||
var handleClickBracket = function handleClickBracket(evt) { | ||
emit('clickBracket', evt); | ||
}; | ||
vue.onMounted(function () { | ||
selfModel.value = props.modelValue; | ||
}); | ||
vue.watch(function () { | ||
return props.modelValue; | ||
}, function (val) { | ||
selfModel.value = val; | ||
}); | ||
return function (_ctx, _cache) { | ||
return vue.openBlock(), vue.createElementBlock("div", { | ||
"class": vue.normalizeClass(vue.unref(className)), | ||
style: vue.normalizeStyle(vue.unref(checkboxStyle)) | ||
}, [vue.withDirectives(vue.createElementVNode("input", { | ||
type: "checkbox", | ||
id: id, | ||
name: id, | ||
"class": "hb-checkbox__input", | ||
onChange: handleChange, | ||
"onUpdate:modelValue": _cache[0] || (_cache[0] = function ($event) { | ||
return selfModel.value = $event; | ||
}) | ||
}, null, 544 /* HYDRATE_EVENTS, NEED_PATCH */), [[vue.vModelCheckbox, selfModel.value]]), vue.createElementVNode("label", { | ||
"class": "hb-checkbox__label", | ||
"for": id | ||
}, [_hoisted_1$1, vue.createElementVNode("div", _hoisted_2, [hasSlot ? vue.renderSlot(_ctx.$slots, "default", { | ||
key: 0 | ||
}) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { | ||
key: 1 | ||
}, [vue.createTextVNode(vue.toDisplayString(props.label), 1 /* TEXT */)], 64 /* STABLE_FRAGMENT */))])]), props.useBracket ? (vue.openBlock(), vue.createElementBlock("i", { | ||
key: 0, | ||
"class": "hb-checkbox__bracket fa-regular fa-chevron-right", | ||
onClick: handleClickBracket | ||
})) : vue.createCommentVNode("v-if", true)], 6 /* CLASS, STYLE */); | ||
}; | ||
} | ||
const listDelimiterRE = /;(?![^(]*\))/g; | ||
const propertyDelimiterRE = /:([^]+)/; | ||
const styleCommentRE = /\/\*.*?\*\//gs; | ||
function parseStringStyle(cssText) { | ||
const ret = {}; | ||
cssText | ||
.replace(styleCommentRE, '') | ||
.split(listDelimiterRE) | ||
.forEach(item => { | ||
if (item) { | ||
const tmp = item.split(propertyDelimiterRE); | ||
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim()); | ||
} | ||
}); | ||
return ret; | ||
} | ||
function stringifyStyle(styles) { | ||
let ret = ''; | ||
if (!styles || isString(styles)) { | ||
return ret; | ||
} | ||
for (const key in styles) { | ||
const value = styles[key]; | ||
const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key); | ||
if (isString(value) || typeof value === 'number') { | ||
// only render valid values | ||
ret += `${normalizedKey}:${value};`; | ||
} | ||
} | ||
return ret; | ||
} | ||
function normalizeClass(value) { | ||
let res = ''; | ||
if (isString(value)) { | ||
res = value; | ||
} | ||
else if (isArray(value)) { | ||
for (let i = 0; i < value.length; i++) { | ||
const normalized = normalizeClass(value[i]); | ||
if (normalized) { | ||
res += normalized + ' '; | ||
} | ||
} | ||
} | ||
else if (isObject(value)) { | ||
for (const name in value) { | ||
if (value[name]) { | ||
res += name + ' '; | ||
} | ||
} | ||
} | ||
return res.trim(); | ||
} | ||
// https://developer.mozilla.org/en-US/docs/Web/SVG/Element | ||
const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' + | ||
'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' + | ||
'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' + | ||
'feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' + | ||
'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' + | ||
'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' + | ||
'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' + | ||
'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' + | ||
'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' + | ||
'text,textPath,title,tspan,unknown,use,view'; | ||
const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr'; | ||
/** | ||
* Compiler only. | ||
* Do NOT use in runtime code paths unless behind `(process.env.NODE_ENV !== 'production')` flag. | ||
*/ | ||
const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS); | ||
/** | ||
* Compiler only. | ||
* Do NOT use in runtime code paths unless behind `(process.env.NODE_ENV !== 'production')` flag. | ||
*/ | ||
const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS); | ||
}; | ||
/** | ||
* On the client we only need to offer special cases for boolean attributes that | ||
* have different names from their corresponding dom properties: | ||
* - itemscope -> N/A | ||
* - allowfullscreen -> allowFullscreen | ||
* - formnovalidate -> formNoValidate | ||
* - ismap -> isMap | ||
* - nomodule -> noModule | ||
* - novalidate -> noValidate | ||
* - readonly -> readOnly | ||
*/ | ||
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; | ||
/** | ||
* The full list is needed during SSR to produce the correct initial markup. | ||
*/ | ||
const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs + | ||
`,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` + | ||
`loop,open,required,reversed,scoped,seamless,` + | ||
`checked,muted,multiple,selected`); | ||
/** | ||
* Boolean attributes should be included if the value is truthy or ''. | ||
* e.g. `<select multiple>` compiles to `{ multiple: '' }` | ||
*/ | ||
function includeBooleanAttr(value) { | ||
return !!value || value === ''; | ||
} | ||
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/; | ||
const attrValidationCache = {}; | ||
function isSSRSafeAttrName(name) { | ||
if (attrValidationCache.hasOwnProperty(name)) { | ||
return attrValidationCache[name]; | ||
} | ||
const isUnsafe = unsafeAttrCharRE.test(name); | ||
if (isUnsafe) { | ||
console.error(`unsafe attribute name: ${name}`); | ||
} | ||
return (attrValidationCache[name] = !isUnsafe); | ||
} | ||
const propsToAttrMap = { | ||
acceptCharset: 'accept-charset', | ||
className: 'class', | ||
htmlFor: 'for', | ||
httpEquiv: 'http-equiv' | ||
}; | ||
script$2.__scopeId = "data-v-38625b18"; | ||
script$2.__file = "docs/.vitepress/components/hb-checkbox/index.vue"; | ||
const escapeRE = /["'&<>]/; | ||
function escapeHtml(string) { | ||
const str = '' + string; | ||
const match = escapeRE.exec(str); | ||
if (!match) { | ||
return str; | ||
var script$1 = { | ||
name: 'hb-button', | ||
props: { | ||
disabled: { | ||
type: Boolean, | ||
"default": false | ||
}, | ||
color: { | ||
type: String, | ||
"default": 'primary', | ||
validator: function validator(value) { | ||
return ['primary', 'kakao', 'gray'].indexOf(value) !== -1; | ||
} | ||
let html = ''; | ||
let escaped; | ||
let index; | ||
let lastIndex = 0; | ||
for (index = match.index; index < str.length; index++) { | ||
switch (str.charCodeAt(index)) { | ||
case 34: // " | ||
escaped = '"'; | ||
break; | ||
case 38: // & | ||
escaped = '&'; | ||
break; | ||
case 39: // ' | ||
escaped = '''; | ||
break; | ||
case 60: // < | ||
escaped = '<'; | ||
break; | ||
case 62: // > | ||
escaped = '>'; | ||
break; | ||
default: | ||
continue; | ||
} | ||
if (lastIndex !== index) { | ||
html += str.slice(lastIndex, index); | ||
} | ||
lastIndex = index + 1; | ||
html += escaped; | ||
}, | ||
height: { | ||
type: String, | ||
"default": 'xl', | ||
validator: function validator(value) { | ||
return ['xs', 'sm', 'md', 'lg', 'xl'].indexOf(value) !== -1; | ||
} | ||
return lastIndex !== index ? html + str.slice(lastIndex, index) : html; | ||
} | ||
// https://www.w3.org/TR/html52/syntax.html#comments | ||
const commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g; | ||
function escapeHtmlComment(src) { | ||
return src.replace(commentStripRE, ''); | ||
} | ||
function looseCompareArrays(a, b) { | ||
if (a.length !== b.length) | ||
return false; | ||
let equal = true; | ||
for (let i = 0; equal && i < a.length; i++) { | ||
equal = looseEqual(a[i], b[i]); | ||
}, | ||
isFull: { | ||
type: Boolean, | ||
"default": false | ||
}, | ||
icon: { | ||
type: String, | ||
"default": '' | ||
}, | ||
iconPosition: { | ||
type: String, | ||
"default": 'right', | ||
validator: function validator(value) { | ||
return ['left', 'right'].indexOf(value) !== -1; | ||
} | ||
return equal; | ||
} | ||
function looseEqual(a, b) { | ||
if (a === b) | ||
return true; | ||
let aValidType = isDate(a); | ||
let bValidType = isDate(b); | ||
if (aValidType || bValidType) { | ||
return aValidType && bValidType ? a.getTime() === b.getTime() : false; | ||
}, | ||
shape: { | ||
type: String, | ||
"default": 'fill', | ||
validator: function validator(value) { | ||
return ['fill', 'line', 'text'].indexOf(value) !== -1; | ||
} | ||
aValidType = isSymbol(a); | ||
bValidType = isSymbol(b); | ||
if (aValidType || bValidType) { | ||
return a === b; | ||
} | ||
aValidType = isArray(a); | ||
bValidType = isArray(b); | ||
if (aValidType || bValidType) { | ||
return aValidType && bValidType ? looseCompareArrays(a, b) : false; | ||
} | ||
aValidType = isObject(a); | ||
bValidType = isObject(b); | ||
if (aValidType || bValidType) { | ||
/* istanbul ignore if: this if will probably never be called */ | ||
if (!aValidType || !bValidType) { | ||
return false; | ||
} | ||
const aKeysCount = Object.keys(a).length; | ||
const bKeysCount = Object.keys(b).length; | ||
if (aKeysCount !== bKeysCount) { | ||
return false; | ||
} | ||
for (const key in a) { | ||
const aHasKey = a.hasOwnProperty(key); | ||
const bHasKey = b.hasOwnProperty(key); | ||
if ((aHasKey && !bHasKey) || | ||
(!aHasKey && bHasKey) || | ||
!looseEqual(a[key], b[key])) { | ||
return false; | ||
} | ||
} | ||
} | ||
return String(a) === String(b); | ||
} | ||
function looseIndexOf(arr, val) { | ||
return arr.findIndex(item => looseEqual(item, val)); | ||
} | ||
/** | ||
* For converting {{ interpolation }} values to displayed strings. | ||
* @private | ||
*/ | ||
const toDisplayString = (val) => { | ||
return isString(val) | ||
? val | ||
: val == null | ||
? '' | ||
: isArray(val) || | ||
(isObject(val) && | ||
(val.toString === objectToString || !isFunction(val.toString))) | ||
? JSON.stringify(val, replacer, 2) | ||
: String(val); | ||
}; | ||
const replacer = (_key, val) => { | ||
// can't use isRef here since @vue/shared has no deps | ||
if (val && val.__v_isRef) { | ||
return replacer(_key, val.value); | ||
} | ||
else if (isMap(val)) { | ||
return { | ||
[`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => { | ||
entries[`${key} =>`] = val; | ||
return entries; | ||
}, {}) | ||
}; | ||
} | ||
else if (isSet(val)) { | ||
return { | ||
[`Set(${val.size})`]: [...val.values()] | ||
}; | ||
} | ||
else if (isObject(val) && !isArray(val) && !isPlainObject(val)) { | ||
return String(val); | ||
} | ||
return val; | ||
}; | ||
(process.env.NODE_ENV !== 'production') | ||
? Object.freeze({}) | ||
: {}; | ||
(process.env.NODE_ENV !== 'production') ? Object.freeze([]) : []; | ||
const NOOP = () => { }; | ||
const onRE = /^on[^a-z]/; | ||
const isOn = (key) => onRE.test(key); | ||
const isArray = Array.isArray; | ||
const isMap = (val) => toTypeString(val) === '[object Map]'; | ||
const isSet = (val) => toTypeString(val) === '[object Set]'; | ||
const isDate = (val) => toTypeString(val) === '[object Date]'; | ||
const isFunction = (val) => typeof val === 'function'; | ||
const isString = (val) => typeof val === 'string'; | ||
const isSymbol = (val) => typeof val === 'symbol'; | ||
const isObject = (val) => val !== null && typeof val === 'object'; | ||
const isPromise = (val) => { | ||
return isObject(val) && isFunction(val.then) && isFunction(val.catch); | ||
}; | ||
const objectToString = Object.prototype.toString; | ||
const toTypeString = (value) => objectToString.call(value); | ||
const isPlainObject = (val) => toTypeString(val) === '[object Object]'; | ||
const cacheStringFunction = (fn) => { | ||
const cache = Object.create(null); | ||
return ((str) => { | ||
const hit = cache[str]; | ||
return hit || (cache[str] = fn(str)); | ||
}); | ||
}; | ||
const hyphenateRE = /\B([A-Z])/g; | ||
/** | ||
* @private | ||
*/ | ||
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase()); | ||
// leading comma for empty string "" | ||
const shouldIgnoreProp = makeMap(`,key,ref,innerHTML,textContent,ref_key,ref_for`); | ||
function ssrRenderAttrs(props, tag) { | ||
let ret = ''; | ||
for (const key in props) { | ||
if (shouldIgnoreProp(key) || | ||
isOn(key) || | ||
(tag === 'textarea' && key === 'value')) { | ||
continue; | ||
} | ||
const value = props[key]; | ||
if (key === 'class') { | ||
ret += ` class="${ssrRenderClass(value)}"`; | ||
} | ||
else if (key === 'style') { | ||
ret += ` style="${ssrRenderStyle(value)}"`; | ||
} | ||
else { | ||
ret += ssrRenderDynamicAttr(key, value, tag); | ||
} | ||
} | ||
return ret; | ||
} | ||
// render an attr with dynamic (unknown) key. | ||
function ssrRenderDynamicAttr(key, value, tag) { | ||
if (!isRenderableValue(value)) { | ||
return ``; | ||
} | ||
const attrKey = tag && (tag.indexOf('-') > 0 || isSVGTag(tag)) | ||
? key // preserve raw name on custom elements and svg | ||
: propsToAttrMap[key] || key.toLowerCase(); | ||
if (isBooleanAttr(attrKey)) { | ||
return includeBooleanAttr(value) ? ` ${attrKey}` : ``; | ||
} | ||
else if (isSSRSafeAttrName(attrKey)) { | ||
return value === '' ? ` ${attrKey}` : ` ${attrKey}="${escapeHtml(value)}"`; | ||
} | ||
else { | ||
console.warn(`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`); | ||
return ``; | ||
} | ||
} | ||
// Render a v-bind attr with static key. The key is pre-processed at compile | ||
// time and we only need to check and escape value. | ||
function ssrRenderAttr(key, value) { | ||
if (!isRenderableValue(value)) { | ||
return ``; | ||
} | ||
return ` ${key}="${escapeHtml(value)}"`; | ||
} | ||
function isRenderableValue(value) { | ||
if (value == null) { | ||
return false; | ||
} | ||
const type = typeof value; | ||
return type === 'string' || type === 'number' || type === 'boolean'; | ||
} | ||
function ssrRenderClass(raw) { | ||
return escapeHtml(normalizeClass(raw)); | ||
} | ||
function ssrRenderStyle(raw) { | ||
if (!raw) { | ||
return ''; | ||
} | ||
if (isString(raw)) { | ||
return escapeHtml(raw); | ||
} | ||
const styles = normalizeStyle(raw); | ||
return escapeHtml(stringifyStyle(styles)); | ||
} | ||
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) { | ||
// template-compiled slots are always rendered as fragments | ||
push(`<!--[-->`); | ||
ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId); | ||
push(`<!--]-->`); | ||
} | ||
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) { | ||
const slotFn = slots[slotName]; | ||
if (slotFn) { | ||
const slotBuffer = []; | ||
const bufferedPush = (item) => { | ||
slotBuffer.push(item); | ||
}; | ||
const ret = slotFn(slotProps, bufferedPush, parentComponent, slotScopeId ? ' ' + slotScopeId : ''); | ||
if (isArray(ret)) { | ||
// normal slot | ||
renderVNodeChildren(push, ret, parentComponent, slotScopeId); | ||
} | ||
else { | ||
// ssr slot. | ||
// check if the slot renders all comments, in which case use the fallback | ||
let isEmptySlot = true; | ||
if (transition) { | ||
isEmptySlot = false; | ||
} | ||
else { | ||
for (let i = 0; i < slotBuffer.length; i++) { | ||
if (!isComment(slotBuffer[i])) { | ||
isEmptySlot = false; | ||
break; | ||
} | ||
} | ||
} | ||
if (isEmptySlot) { | ||
if (fallbackRenderFn) { | ||
fallbackRenderFn(); | ||
} | ||
} | ||
else { | ||
for (let i = 0; i < slotBuffer.length; i++) { | ||
push(slotBuffer[i]); | ||
} | ||
} | ||
} | ||
} | ||
else if (fallbackRenderFn) { | ||
fallbackRenderFn(); | ||
} | ||
} | ||
const commentTestRE = /^<!--.*-->$/s; | ||
const commentRE = /<!--[^]*?-->/gm; | ||
function isComment(item) { | ||
if (typeof item !== 'string' || !commentTestRE.test(item)) | ||
return false; | ||
// if item is '<!---->' or '<!--[-->' or '<!--]-->', return true directly | ||
if (item.length <= 8) | ||
return true; | ||
return !item.replace(commentRE, '').trim(); | ||
} | ||
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) { | ||
parentPush('<!--teleport start-->'); | ||
const context = parentComponent.appContext.provides[vue.ssrContextKey]; | ||
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {}); | ||
const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []); | ||
// record current index of the target buffer to handle nested teleports | ||
// since the parent needs to be rendered before the child | ||
const bufferIndex = targetBuffer.length; | ||
let teleportContent; | ||
if (disabled) { | ||
contentRenderFn(parentPush); | ||
teleportContent = `<!--teleport anchor-->`; | ||
} | ||
else { | ||
const { getBuffer, push } = createBuffer(); | ||
contentRenderFn(push); | ||
push(`<!--teleport anchor-->`); | ||
teleportContent = getBuffer(); | ||
} | ||
targetBuffer.splice(bufferIndex, 0, teleportContent); | ||
parentPush('<!--teleport end-->'); | ||
} | ||
function ssrInterpolate(value) { | ||
return escapeHtml(toDisplayString(value)); | ||
} | ||
Symbol((process.env.NODE_ENV !== 'production') ? 'iterate' : ''); | ||
Symbol((process.env.NODE_ENV !== 'production') ? 'Map key iterate' : ''); | ||
function ssrLooseContain(arr, value) { | ||
return looseIndexOf(arr, value) > -1; | ||
} | ||
function ssrCompile(template, instance) { | ||
// TODO: this branch should now work in ESM builds, enable it in a minor | ||
{ | ||
throw new Error(`On-the-fly template compilation is not supported in the ESM build of ` + | ||
`@vue/server-renderer. All templates must be pre-compiled into ` + | ||
`render functions.`); | ||
} | ||
} | ||
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode } = vue.ssrUtils; | ||
// Each component has a buffer array. | ||
// A buffer array can contain one of the following: | ||
// - plain string | ||
// - A resolved buffer (recursive arrays of strings that can be unrolled | ||
// synchronously) | ||
// - An async buffer (a Promise that resolves to a resolved buffer) | ||
function createBuffer() { | ||
let appendable = false; | ||
const buffer = []; | ||
return { | ||
getBuffer() { | ||
// Return static buffer and await on items during unroll stage | ||
return buffer; | ||
}, | ||
push(item) { | ||
const isStringItem = isString(item); | ||
if (appendable && isStringItem) { | ||
buffer[buffer.length - 1] += item; | ||
} | ||
else { | ||
buffer.push(item); | ||
} | ||
appendable = isStringItem; | ||
if (isPromise(item) || (isArray(item) && item.hasAsync)) { | ||
// promise, or child buffer with async, mark as async. | ||
// this allows skipping unnecessary await ticks during unroll stage | ||
buffer.hasAsync = true; | ||
} | ||
} | ||
}; | ||
} | ||
function renderComponentVNode(vnode, parentComponent = null, slotScopeId) { | ||
const instance = createComponentInstance(vnode, parentComponent, null); | ||
const res = setupComponent(instance, true /* isSSR */); | ||
const hasAsyncSetup = isPromise(res); | ||
const prefetches = instance.sp; /* LifecycleHooks.SERVER_PREFETCH */ | ||
if (hasAsyncSetup || prefetches) { | ||
let p = hasAsyncSetup | ||
? res | ||
: Promise.resolve(); | ||
if (prefetches) { | ||
p = p | ||
.then(() => Promise.all(prefetches.map(prefetch => prefetch.call(instance.proxy)))) | ||
// Note: error display is already done by the wrapped lifecycle hook function. | ||
.catch(() => { }); | ||
} | ||
return p.then(() => renderComponentSubTree(instance, slotScopeId)); | ||
} | ||
else { | ||
return renderComponentSubTree(instance, slotScopeId); | ||
} | ||
} | ||
function renderComponentSubTree(instance, slotScopeId) { | ||
const comp = instance.type; | ||
const { getBuffer, push } = createBuffer(); | ||
if (isFunction(comp)) { | ||
let root = renderComponentRoot(instance); | ||
// #5817 scope ID attrs not falling through if functional component doesn't | ||
// have props | ||
if (!comp.props) { | ||
for (const key in instance.attrs) { | ||
if (key.startsWith(`data-v-`)) { | ||
(root.props || (root.props = {}))[key] = ``; | ||
} | ||
} | ||
} | ||
renderVNode(push, (instance.subTree = root), instance, slotScopeId); | ||
} | ||
else { | ||
if ((!instance.render || instance.render === NOOP) && | ||
!instance.ssrRender && | ||
!comp.ssrRender && | ||
isString(comp.template)) { | ||
comp.ssrRender = ssrCompile(comp.template); | ||
} | ||
// perf: enable caching of computed getters during render | ||
// since there cannot be state mutations during render. | ||
for (const e of instance.scope.effects) { | ||
if (e.computed) | ||
e.computed._cacheable = true; | ||
} | ||
const ssrRender = instance.ssrRender || comp.ssrRender; | ||
if (ssrRender) { | ||
// optimized | ||
// resolve fallthrough attrs | ||
let attrs = instance.inheritAttrs !== false ? instance.attrs : undefined; | ||
let hasCloned = false; | ||
let cur = instance; | ||
while (true) { | ||
const scopeId = cur.vnode.scopeId; | ||
if (scopeId) { | ||
if (!hasCloned) { | ||
attrs = { ...attrs }; | ||
hasCloned = true; | ||
} | ||
attrs[scopeId] = ''; | ||
} | ||
const parent = cur.parent; | ||
if (parent && parent.subTree && parent.subTree === cur.vnode) { | ||
// parent is a non-SSR compiled component and is rendering this | ||
// component as root. inherit its scopeId if present. | ||
cur = parent; | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
if (slotScopeId) { | ||
if (!hasCloned) | ||
attrs = { ...attrs }; | ||
attrs[slotScopeId.trim()] = ''; | ||
} | ||
// set current rendering instance for asset resolution | ||
const prev = setCurrentRenderingInstance(instance); | ||
try { | ||
ssrRender(instance.proxy, push, instance, attrs, | ||
// compiler-optimized bindings | ||
instance.props, instance.setupState, instance.data, instance.ctx); | ||
} | ||
finally { | ||
setCurrentRenderingInstance(prev); | ||
} | ||
} | ||
else if (instance.render && instance.render !== NOOP) { | ||
renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance, slotScopeId); | ||
} | ||
else { | ||
const componentName = comp.name || comp.__file || `<Anonymous>`; | ||
vue.warn(`Component ${componentName} is missing template or render function.`); | ||
push(`<!---->`); | ||
} | ||
} | ||
return getBuffer(); | ||
} | ||
function renderVNode(push, vnode, parentComponent, slotScopeId) { | ||
const { type, shapeFlag, children } = vnode; | ||
switch (type) { | ||
case vue.Text: | ||
push(escapeHtml(children)); | ||
break; | ||
case vue.Comment: | ||
push(children ? `<!--${escapeHtmlComment(children)}-->` : `<!---->`); | ||
break; | ||
case vue.Static: | ||
push(children); | ||
break; | ||
case vue.Fragment: | ||
if (vnode.slotScopeIds) { | ||
slotScopeId = | ||
(slotScopeId ? slotScopeId + ' ' : '') + vnode.slotScopeIds.join(' '); | ||
} | ||
push(`<!--[-->`); // open | ||
renderVNodeChildren(push, children, parentComponent, slotScopeId); | ||
push(`<!--]-->`); // close | ||
break; | ||
default: | ||
if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) { | ||
renderElementVNode(push, vnode, parentComponent, slotScopeId); | ||
} | ||
else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) { | ||
push(renderComponentVNode(vnode, parentComponent, slotScopeId)); | ||
} | ||
else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) { | ||
renderTeleportVNode(push, vnode, parentComponent, slotScopeId); | ||
} | ||
else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) { | ||
renderVNode(push, vnode.ssContent, parentComponent, slotScopeId); | ||
} | ||
else { | ||
vue.warn('[@vue/server-renderer] Invalid VNode type:', type, `(${typeof type})`); | ||
} | ||
} | ||
} | ||
function renderVNodeChildren(push, children, parentComponent, slotScopeId) { | ||
for (let i = 0; i < children.length; i++) { | ||
renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId); | ||
} | ||
} | ||
function renderElementVNode(push, vnode, parentComponent, slotScopeId) { | ||
const tag = vnode.type; | ||
let { props, children, shapeFlag, scopeId, dirs } = vnode; | ||
let openTag = `<${tag}`; | ||
if (dirs) { | ||
props = applySSRDirectives(vnode, props, dirs); | ||
} | ||
if (props) { | ||
openTag += ssrRenderAttrs(props, tag); | ||
} | ||
if (scopeId) { | ||
openTag += ` ${scopeId}`; | ||
} | ||
// inherit parent chain scope id if this is the root node | ||
let curParent = parentComponent; | ||
let curVnode = vnode; | ||
while (curParent && curVnode === curParent.subTree) { | ||
curVnode = curParent.vnode; | ||
if (curVnode.scopeId) { | ||
openTag += ` ${curVnode.scopeId}`; | ||
} | ||
curParent = curParent.parent; | ||
} | ||
if (slotScopeId) { | ||
openTag += ` ${slotScopeId}`; | ||
} | ||
push(openTag + `>`); | ||
if (!isVoidTag(tag)) { | ||
let hasChildrenOverride = false; | ||
if (props) { | ||
if (props.innerHTML) { | ||
hasChildrenOverride = true; | ||
push(props.innerHTML); | ||
} | ||
else if (props.textContent) { | ||
hasChildrenOverride = true; | ||
push(escapeHtml(props.textContent)); | ||
} | ||
else if (tag === 'textarea' && props.value) { | ||
hasChildrenOverride = true; | ||
push(escapeHtml(props.value)); | ||
} | ||
} | ||
if (!hasChildrenOverride) { | ||
if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) { | ||
push(escapeHtml(children)); | ||
} | ||
else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) { | ||
renderVNodeChildren(push, children, parentComponent, slotScopeId); | ||
} | ||
} | ||
push(`</${tag}>`); | ||
} | ||
} | ||
function applySSRDirectives(vnode, rawProps, dirs) { | ||
const toMerge = []; | ||
for (let i = 0; i < dirs.length; i++) { | ||
const binding = dirs[i]; | ||
const { dir: { getSSRProps } } = binding; | ||
if (getSSRProps) { | ||
const props = getSSRProps(binding, vnode); | ||
if (props) | ||
toMerge.push(props); | ||
} | ||
} | ||
return vue.mergeProps(rawProps || {}, ...toMerge); | ||
} | ||
function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) { | ||
const target = vnode.props && vnode.props.to; | ||
const disabled = vnode.props && vnode.props.disabled; | ||
if (!target) { | ||
if (!disabled) { | ||
vue.warn(`[@vue/server-renderer] Teleport is missing target prop.`); | ||
} | ||
return []; | ||
} | ||
if (!isString(target)) { | ||
vue.warn(`[@vue/server-renderer] Teleport target must be a query selector string.`); | ||
return []; | ||
} | ||
ssrRenderTeleport(push, push => { | ||
renderVNodeChildren(push, vnode.children, parentComponent, slotScopeId); | ||
}, target, disabled || disabled === '', parentComponent); | ||
} | ||
vue.initDirectivesForSSR(); | ||
var script$2 = { | ||
__name: 'index', | ||
__ssrInlineRender: true, | ||
props: { | ||
modelValue: { | ||
type: Boolean | ||
}, | ||
label: { | ||
type: String | ||
}, | ||
checked: { | ||
type: Boolean, | ||
"default": false | ||
}, | ||
shape: { | ||
type: String, | ||
"default": 'box', | ||
validator: function validator(value) { | ||
return ['box', 'line'].indexOf(value) !== -1; | ||
} | ||
}, | ||
size: { | ||
type: String, | ||
"default": 'h4', | ||
validator: function validator(value) { | ||
return ['h2', 'h3', 'h4'].indexOf(value) !== -1; | ||
} | ||
}, | ||
useBracket: { | ||
type: Boolean, | ||
"default": false | ||
}, | ||
animation: { | ||
type: Boolean, | ||
"default": false | ||
} | ||
}, | ||
emits: ['update:modelValue', 'change', 'clickBracket'], | ||
setup: function setup(__props, _ref) { | ||
_ref.emit; | ||
var props = __props; | ||
var selfModel = vue.ref(false); | ||
var slots = vue.useSlots(); | ||
var hasSlot = !!slots['default']; | ||
var id = 'id-' + Math.random().toString(36).substring(2); | ||
var className = vue.computed(function () { | ||
var className = 'hb-checkbox'; | ||
if (props.shape) className += " hb-checkbox--".concat(props.shape); | ||
if (props.size) className += " hb-checkbox--".concat(props.size); | ||
if (props.useBracket) className += " hb-checkbox--bracket"; | ||
if (props.animation) className += " hb-checkbox--animation"; | ||
return className; | ||
}); | ||
var checkboxStyle = vue.computed(function () { | ||
var checkboxStyle = {}; | ||
return checkboxStyle; | ||
}); | ||
vue.onMounted(function () { | ||
selfModel.value = props.modelValue; | ||
}); | ||
vue.watch(function () { | ||
return props.modelValue; | ||
}, function (val) { | ||
selfModel.value = val; | ||
}); | ||
return function (_ctx, _push, _parent, _attrs) { | ||
_push("<div".concat(ssrRenderAttrs(vue.mergeProps({ | ||
"class": vue.unref(className), | ||
style: vue.unref(checkboxStyle) | ||
}, _attrs)), " data-v-38625b18><input type=\"checkbox\"").concat(ssrRenderAttr("id", id)).concat(ssrRenderAttr("name", id), " class=\"hb-checkbox__input\"").concat(includeBooleanAttr(Array.isArray(selfModel.value) ? ssrLooseContain(selfModel.value, null) : selfModel.value) ? " checked" : "", " data-v-38625b18><label class=\"hb-checkbox__label\"").concat(ssrRenderAttr("for", id), " data-v-38625b18><div class=\"hb-checkbox__mark\" data-v-38625b18></div><div class=\"hb-checkbox__text\" data-v-38625b18>")); | ||
if (hasSlot) { | ||
ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent, "data-v-38625b18-s"); | ||
} else { | ||
_push("<!--[-->".concat(ssrInterpolate(props.label), "<!--]-->")); | ||
} | ||
_push("</div></label>"); | ||
if (props.useBracket) { | ||
_push("<i class=\"hb-checkbox__bracket fa-regular fa-chevron-right\" data-v-38625b18></i>"); | ||
} else { | ||
_push("<!---->"); | ||
} | ||
_push("</div>"); | ||
}; | ||
loading: { | ||
type: Boolean, | ||
"default": false | ||
}, | ||
fullMargin: { | ||
type: Number | ||
} | ||
}; | ||
script$2.__scopeId = "data-v-38625b18"; | ||
script$2.__file = "docs/.vitepress/components/hb-checkbox/index.vue"; | ||
var script$1 = { | ||
name: 'hb-button', | ||
props: { | ||
disabled: { | ||
type: Boolean, | ||
"default": false | ||
}, | ||
color: { | ||
type: String, | ||
"default": 'primary', | ||
validator: function validator(value) { | ||
return ['primary', 'kakao', 'gray'].indexOf(value) !== -1; | ||
} | ||
}, | ||
height: { | ||
type: String, | ||
"default": 'xl', | ||
validator: function validator(value) { | ||
return ['xs', 'sm', 'md', 'lg', 'xl'].indexOf(value) !== -1; | ||
} | ||
}, | ||
isFull: { | ||
type: Boolean, | ||
"default": false | ||
}, | ||
icon: { | ||
type: String, | ||
"default": '' | ||
}, | ||
iconPosition: { | ||
type: String, | ||
"default": 'right', | ||
validator: function validator(value) { | ||
return ['left', 'right'].indexOf(value) !== -1; | ||
} | ||
}, | ||
shape: { | ||
type: String, | ||
"default": 'fill', | ||
validator: function validator(value) { | ||
return ['fill', 'line', 'text'].indexOf(value) !== -1; | ||
} | ||
}, | ||
loading: { | ||
type: Boolean, | ||
"default": false | ||
}, | ||
fullMargin: { | ||
type: Number | ||
} | ||
}, | ||
data: function data() { | ||
return { | ||
hasSlot: false | ||
}; | ||
}, | ||
computed: { | ||
className: function className() { | ||
var className = 'hb-button'; | ||
if (this.color) className += " hb-button--".concat(this.color); | ||
if (this.shape) className += " hb-button--".concat(this.shape); | ||
if (this.height) className += " hb-button--".concat(this.height); | ||
if (this.type) className += " hb-button--".concat(this.type); | ||
if (this.isFull) className += " hb-button--full"; | ||
if (this.loading) className += ' fa-3x'; | ||
return className; | ||
}, | ||
data: function data() { | ||
return { | ||
hasSlot: false | ||
}; | ||
isOnlyIcon: function isOnlyIcon() { | ||
// 텍스트없고 아이콘만 있는 경우 true | ||
var result = false; | ||
if (!this.hasSlot && this.icon) result = true; | ||
return result; | ||
}, | ||
computed: { | ||
className: function className() { | ||
var className = 'hb-button'; | ||
if (this.color) className += " hb-button--".concat(this.color); | ||
if (this.shape) className += " hb-button--".concat(this.shape); | ||
if (this.height) className += " hb-button--".concat(this.height); | ||
if (this.type) className += " hb-button--".concat(this.type); | ||
if (this.isFull) className += " hb-button--full"; | ||
if (this.loading) className += ' fa-3x'; | ||
return className; | ||
}, | ||
isOnlyIcon: function isOnlyIcon() { | ||
// 텍스트없고 아이콘만 있는 경우 true | ||
var result = false; | ||
if (!this.hasSlot && this.icon) result = true; | ||
return result; | ||
}, | ||
computedIcon: function computedIcon() { | ||
if (this.loading) return 'fa-solid fa-spinner fa-spin'; | ||
return this.icon; | ||
}, | ||
computedIconPosition: function computedIconPosition() { | ||
if (this.loading) return 'right'; | ||
return this.iconPosition; | ||
}, | ||
buttonStyle: function buttonStyle() { | ||
var buttonStyle = {}; | ||
// full 인 경우 마진세팅. | ||
if (this.isFull && this.fullMargin) { | ||
buttonStyle['width'] = "calc(100% - ".concat(this.fullMargin * 2, "px)"); | ||
buttonStyle['margin'] = "0 ".concat(this.fullMargin, "px"); | ||
} | ||
return buttonStyle; | ||
} | ||
computedIcon: function computedIcon() { | ||
if (this.loading) return 'fa-solid fa-spinner fa-spin'; | ||
return this.icon; | ||
}, | ||
methods: { | ||
handleClick: function handleClick(evt) { | ||
this.$emit('click', evt); | ||
computedIconPosition: function computedIconPosition() { | ||
if (this.loading) return 'right'; | ||
return this.iconPosition; | ||
}, | ||
buttonStyle: function buttonStyle() { | ||
var buttonStyle = {}; | ||
// full 인 경우 마진세팅. | ||
if (this.isFull && this.fullMargin) { | ||
buttonStyle['width'] = "calc(100% - ".concat(this.fullMargin * 2, "px)"); | ||
buttonStyle['margin'] = "0 ".concat(this.fullMargin, "px"); | ||
} | ||
}, | ||
mounted: function mounted() { | ||
var that = this; | ||
setTimeout(function () { | ||
that.hasSlot = !!that.$slots['default']; | ||
}); | ||
return buttonStyle; | ||
} | ||
}; | ||
function ssrRender$1(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) { | ||
_push("<button".concat(ssrRenderAttrs(vue.mergeProps({ | ||
type: "button", | ||
"class": $options.className, | ||
style: $options.buttonStyle, | ||
disabled: $props.disabled | ||
}, _attrs)), " data-v-6210de47>")); | ||
if ($props.icon && $options.computedIconPosition === 'left') { | ||
_push("<i class=\"".concat(ssrRenderClass([$props.icon, "hb-button__icon--left"]), "\" data-v-6210de47></i>")); | ||
} else { | ||
_push("<!---->"); | ||
}, | ||
methods: { | ||
handleClick: function handleClick(evt) { | ||
this.$emit('click', evt); | ||
} | ||
_push("<span class=\"".concat(ssrRenderClass({ | ||
'hb-button__text': $data.hasSlot | ||
}), "\" data-v-6210de47>")); | ||
ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent, "data-v-6210de47-s"); | ||
_push("</span>"); | ||
if ($options.computedIcon && $options.computedIconPosition === 'right') { | ||
_push("<i class=\"".concat(ssrRenderClass([$options.computedIcon, "hb-button__icon--right"]), "\" data-v-6210de47></i>")); | ||
} else { | ||
_push("<!---->"); | ||
} | ||
_push("</button>"); | ||
}, | ||
mounted: function mounted() { | ||
var that = this; | ||
setTimeout(function () { | ||
that.hasSlot = !!that.$slots['default']; | ||
}); | ||
} | ||
}; | ||
script$1.ssrRender = ssrRender$1; | ||
script$1.__scopeId = "data-v-6210de47"; | ||
script$1.__file = "docs/.vitepress/components/hb-button/index.vue"; | ||
var _hoisted_1 = ["disabled"]; | ||
function render$1(_ctx, _cache, $props, $setup, $data, $options) { | ||
return vue.openBlock(), vue.createElementBlock("button", { | ||
type: "button", | ||
"class": vue.normalizeClass($options.className), | ||
style: vue.normalizeStyle($options.buttonStyle), | ||
disabled: $props.disabled, | ||
onClick: _cache[0] || (_cache[0] = function () { | ||
return $options.handleClick && $options.handleClick.apply($options, arguments); | ||
}) | ||
}, [$props.icon && $options.computedIconPosition === 'left' ? (vue.openBlock(), vue.createElementBlock("i", { | ||
key: 0, | ||
"class": vue.normalizeClass([$props.icon, "hb-button__icon--left"]) | ||
}, null, 2 /* CLASS */)) : vue.createCommentVNode("v-if", true), vue.createElementVNode("span", { | ||
"class": vue.normalizeClass({ | ||
'hb-button__text': $data.hasSlot | ||
}) | ||
}, [vue.renderSlot(_ctx.$slots, "default")], 2 /* CLASS */), $options.computedIcon && $options.computedIconPosition === 'right' ? (vue.openBlock(), vue.createElementBlock("i", { | ||
key: 1, | ||
"class": vue.normalizeClass([$options.computedIcon, "hb-button__icon--right"]) | ||
}, null, 2 /* CLASS */)) : vue.createCommentVNode("v-if", true)], 14 /* CLASS, STYLE, PROPS */, _hoisted_1); | ||
} | ||
var script = { | ||
name: 'hb-button-wrap', | ||
props: { | ||
isFull: { | ||
type: Boolean, | ||
"default": false | ||
}, | ||
gridRatio: { | ||
type: String | ||
}, | ||
isFloat: { | ||
type: Boolean, | ||
"default": false | ||
} | ||
script$1.render = render$1; | ||
script$1.__scopeId = "data-v-6210de47"; | ||
script$1.__file = "docs/.vitepress/components/hb-button/index.vue"; | ||
var script = { | ||
name: 'hb-button-wrap', | ||
props: { | ||
isFull: { | ||
type: Boolean, | ||
"default": false | ||
}, | ||
computed: { | ||
className: function className() { | ||
var className = 'hb-button-wrap'; | ||
if (this.isFull) className += " hb-button-wrap--full"; | ||
if (this.isFloat) className += " hb-button-wrap--float"; | ||
if (this.gridRatio) className += " hb-button-wrap--grid"; | ||
return className; | ||
}, | ||
buttonWrapStyle: function buttonWrapStyle() { | ||
var buttonWrapStyle = {}; | ||
if (this.gridRatio) { | ||
buttonWrapStyle['grid-template-columns'] = this.gridRatio; | ||
} | ||
return buttonWrapStyle; | ||
gridRatio: { | ||
type: String | ||
}, | ||
isFloat: { | ||
type: Boolean, | ||
"default": false | ||
} | ||
}, | ||
computed: { | ||
className: function className() { | ||
var className = 'hb-button-wrap'; | ||
if (this.isFull) className += " hb-button-wrap--full"; | ||
if (this.isFloat) className += " hb-button-wrap--float"; | ||
if (this.gridRatio) className += " hb-button-wrap--grid"; | ||
return className; | ||
}, | ||
buttonWrapStyle: function buttonWrapStyle() { | ||
var buttonWrapStyle = {}; | ||
if (this.gridRatio) { | ||
buttonWrapStyle['grid-template-columns'] = this.gridRatio; | ||
} | ||
return buttonWrapStyle; | ||
} | ||
}; | ||
function ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) { | ||
_push("<div".concat(ssrRenderAttrs(vue.mergeProps({ | ||
"class": $options.className, | ||
style: $options.buttonWrapStyle | ||
}, _attrs)), " data-v-2b59b4a6>")); | ||
ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent, "data-v-2b59b4a6-s"); | ||
_push("</div>"); | ||
} | ||
}; | ||
script.ssrRender = ssrRender; | ||
script.__scopeId = "data-v-2b59b4a6"; | ||
script.__file = "docs/.vitepress/components/hb-button-wrap/index.vue"; | ||
function render(_ctx, _cache, $props, $setup, $data, $options) { | ||
return vue.openBlock(), vue.createElementBlock("div", { | ||
"class": vue.normalizeClass($options.className), | ||
style: vue.normalizeStyle($options.buttonWrapStyle) | ||
}, [vue.renderSlot(_ctx.$slots, "default")], 6 /* CLASS, STYLE */); | ||
} | ||
var components = { | ||
HbCheckbox: script$2, | ||
HbButton: script$1, | ||
HbButtonWrap: script | ||
}; | ||
var index = { | ||
install: function install(app, options) { | ||
for (var componentKey in components) { | ||
console.log('componentKey', componentKey); | ||
app.component(componentKey, components[componentKey]); | ||
} | ||
script.render = render; | ||
script.__scopeId = "data-v-2b59b4a6"; | ||
script.__file = "docs/.vitepress/components/hb-button-wrap/index.vue"; | ||
var components = { | ||
HbCheckbox: script$2, | ||
HbButton: script$1, | ||
HbButtonWrap: script | ||
}; | ||
var index = { | ||
install: function install(app, options) { | ||
for (var componentKey in components) { | ||
console.log('componentKey', componentKey); | ||
app.component(componentKey, components[componentKey]); | ||
} | ||
}; | ||
} | ||
}; | ||
exports.HbButton = script$1; | ||
exports.HbButtonWrap = script; | ||
exports.HbCheckbox = script$2; | ||
exports.default = index; | ||
exports.HbButton = script$1; | ||
exports.HbButtonWrap = script; | ||
exports.HbCheckbox = script$2; | ||
exports.default = index; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); |
@@ -6,3 +6,3 @@ { | ||
], | ||
"version": "0.5.21", | ||
"version": "0.5.22", | ||
"main": "dist/index.js", | ||
@@ -9,0 +9,0 @@ "module": "dist/index.es.js", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1
66631
1603