Skip to content

Instantly share code, notes, and snippets.

@zew13
Created August 21, 2022 01:55
Show Gist options
  • Save zew13/b94dc8a152cc678d252f6ccec65c9e3c to your computer and use it in GitHub Desktop.
Save zew13/b94dc8a152cc678d252f6ccec65c9e3c to your computer and use it in GitHub Desktop.
const UI_PREFIX = 'i-';
function $ELEMENT(name,o) {
return customElements.define(UI_PREFIX+name,o)
}
import { i18nOnMount, I18N } from './i18n.js';
// node_modules/.pnpm/[email protected]/node_modules/svelte/internal/index.mjs
function noop() {
}
function run(fn) {
return fn();
}
function blank_object() {
return /* @__PURE__ */ Object.create(null);
}
function run_all(fns) {
fns.forEach(run);
}
function is_function(thing) {
return typeof thing === "function";
}
function safe_not_equal(a, b) {
return a != a ? b == b : a !== b || (a && typeof a === "object" || typeof a === "function");
}
function is_empty(obj) {
return Object.keys(obj).length === 0;
}
var is_hydrating = false;
function start_hydrating() {
is_hydrating = true;
}
function end_hydrating() {
is_hydrating = false;
}
function append(target, node) {
target.appendChild(node);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor || null);
}
function detach(node) {
node.parentNode.removeChild(node);
}
function destroy_each(iterations, detaching) {
for (let i = 0; i < iterations.length; i += 1) {
if (iterations[i])
iterations[i].d(detaching);
}
}
function element(name) {
return document.createElement(name);
}
function text(data) {
return document.createTextNode(data);
}
function space() {
return text(" ");
}
function empty() {
return text("");
}
function listen(node, event, handler, options) {
node.addEventListener(event, handler, options);
return () => node.removeEventListener(event, handler, options);
}
function prevent_default(fn) {
return function(event) {
event.preventDefault();
return fn.call(this, event);
};
}
function attr(node, attribute, value) {
if (value == null)
node.removeAttribute(attribute);
else if (node.getAttribute(attribute) !== value)
node.setAttribute(attribute, value);
}
function set_custom_element_data(node, prop, value) {
if (prop in node) {
node[prop] = typeof node[prop] === "boolean" && value === "" ? true : value;
} else {
attr(node, prop, value);
}
}
function children(element2) {
return Array.from(element2.childNodes);
}
function set_data(text2, data) {
data = "" + data;
if (text2.wholeText !== data)
text2.data = data;
}
function set_input_value(input, value) {
input.value = value == null ? "" : value;
}
function select_option(select, value) {
for (let i = 0; i < select.options.length; i += 1) {
const option = select.options[i];
if (option.__value === value) {
option.selected = true;
return;
}
}
select.selectedIndex = -1;
}
function select_value(select) {
const selected_option = select.querySelector(":checked") || select.options[0];
return selected_option && selected_option.__value;
}
function attribute_to_object(attributes) {
const result = {};
for (const attribute of attributes) {
result[attribute.name] = attribute.value;
}
return result;
}
var current_component;
function set_current_component(component) {
current_component = component;
}
function get_current_component() {
if (!current_component)
throw new Error("Function called outside component initialization");
return current_component;
}
function onMount(fn) {
get_current_component().$$.on_mount.push(fn);
}
var dirty_components = [];
var binding_callbacks = [];
var render_callbacks = [];
var flush_callbacks = [];
var resolved_promise = Promise.resolve();
var update_scheduled = false;
function schedule_update() {
if (!update_scheduled) {
update_scheduled = true;
resolved_promise.then(flush);
}
}
function add_render_callback(fn) {
render_callbacks.push(fn);
}
var seen_callbacks = /* @__PURE__ */ new Set();
var flushidx = 0;
function flush() {
const saved_component = current_component;
do {
while (flushidx < dirty_components.length) {
const component = dirty_components[flushidx];
flushidx++;
set_current_component(component);
update(component.$$);
}
set_current_component(null);
dirty_components.length = 0;
flushidx = 0;
while (binding_callbacks.length)
binding_callbacks.pop()();
for (let i = 0; i < render_callbacks.length; i += 1) {
const callback = render_callbacks[i];
if (!seen_callbacks.has(callback)) {
seen_callbacks.add(callback);
callback();
}
}
render_callbacks.length = 0;
} while (dirty_components.length);
while (flush_callbacks.length) {
flush_callbacks.pop()();
}
update_scheduled = false;
seen_callbacks.clear();
set_current_component(saved_component);
}
function update($$) {
if ($$.fragment !== null) {
$$.update();
run_all($$.before_update);
const dirty = $$.dirty;
$$.dirty = [-1];
$$.fragment && $$.fragment.p($$.ctx, dirty);
$$.after_update.forEach(add_render_callback);
}
}
var outroing = /* @__PURE__ */ new Set();
function transition_in(block, local) {
if (block && block.i) {
outroing.delete(block);
block.i(local);
}
}
var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : global;
function mount_component(component, target, anchor, customElement) {
const { fragment, on_mount, on_destroy, after_update } = component.$$;
fragment && fragment.m(target, anchor);
if (!customElement) {
add_render_callback(() => {
const new_on_destroy = on_mount.map(run).filter(is_function);
if (on_destroy) {
on_destroy.push(...new_on_destroy);
} else {
run_all(new_on_destroy);
}
component.$$.on_mount = [];
});
}
after_update.forEach(add_render_callback);
}
function destroy_component(component, detaching) {
const $$ = component.$$;
if ($$.fragment !== null) {
run_all($$.on_destroy);
$$.fragment && $$.fragment.d(detaching);
$$.on_destroy = $$.fragment = null;
$$.ctx = [];
}
}
function make_dirty(component, i) {
if (component.$$.dirty[0] === -1) {
dirty_components.push(component);
schedule_update();
component.$$.dirty.fill(0);
}
component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
}
function init(component, options, instance5, create_fragment5, not_equal, props, append_styles, dirty = [-1]) {
const parent_component = current_component;
set_current_component(component);
const $$ = component.$$ = {
fragment: null,
ctx: null,
props,
update: noop,
not_equal,
bound: blank_object(),
on_mount: [],
on_destroy: [],
on_disconnect: [],
before_update: [],
after_update: [],
context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
callbacks: blank_object(),
dirty,
skip_bound: false,
root: options.target || parent_component.$$.root
};
append_styles && append_styles($$.root);
let ready = false;
$$.ctx = instance5 ? instance5(component, options.props || {}, (i, ret, ...rest) => {
const value = rest.length ? rest[0] : ret;
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
if (!$$.skip_bound && $$.bound[i])
$$.bound[i](value);
if (ready)
make_dirty(component, i);
}
return ret;
}) : [];
$$.update();
ready = true;
run_all($$.before_update);
$$.fragment = create_fragment5 ? create_fragment5($$.ctx) : false;
if (options.target) {
if (options.hydrate) {
start_hydrating();
const nodes = children(options.target);
$$.fragment && $$.fragment.l(nodes);
nodes.forEach(detach);
} else {
$$.fragment && $$.fragment.c();
}
if (options.intro)
transition_in(component.$$.fragment);
mount_component(component, options.target, options.anchor, options.customElement);
end_hydrating();
flush();
}
set_current_component(parent_component);
}
var SvelteElement;
if (typeof HTMLElement === "function") {
SvelteElement = class extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
}
connectedCallback() {
const { on_mount } = this.$$;
this.$$.on_disconnect = on_mount.map(run).filter(is_function);
for (const key in this.$$.slotted) {
this.appendChild(this.$$.slotted[key]);
}
}
attributeChangedCallback(attr2, _oldValue, newValue) {
this[attr2] = newValue;
}
disconnectedCallback() {
run_all(this.$$.on_disconnect);
}
$destroy() {
destroy_component(this, 1);
this.$destroy = noop;
}
$on(type, callback) {
const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
callbacks.push(callback);
return () => {
const index = callbacks.indexOf(callback);
if (index !== -1)
callbacks.splice(index, 1);
};
}
$set($$props) {
if (this.$$set && !is_empty($$props)) {
this.$$.skip_bound = true;
this.$$set($$props);
this.$$.skip_bound = false;
}
}
};
}
// src/lib/str2li.coffee
function str2li_default(li) {
var i, iter, r;
r = [];
iter = li[Symbol.iterator]();
for (i of iter) {
r.push([i, iter.next().value]);
}
return r;
}
// src/I18n.svelte
function get_each_context(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[2] = list[i];
return child_ctx;
}
function create_if_block(ctx) {
let select;
let mounted;
let dispose;
let each_value = ctx[1];
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
}
return {
c() {
select = element("select");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
attr(select, "class", "ico");
if (ctx[0] === void 0)
add_render_callback(() => ctx[13].call(select));
},
m(target, anchor) {
insert(target, select, anchor);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(select, null);
}
select_option(select, ctx[0]);
if (!mounted) {
dispose = listen(select, "change", ctx[13]);
mounted = true;
}
},
p(ctx2, dirty) {
if (dirty & 2) {
each_value = ctx2[1];
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx2, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block(child_ctx);
each_blocks[i].c();
each_blocks[i].m(select, null);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value.length;
}
if (dirty & 3) {
select_option(select, ctx2[0]);
}
},
d(detaching) {
if (detaching)
detach(select);
destroy_each(each_blocks, detaching);
mounted = false;
dispose();
}
};
}
function create_each_block(ctx) {
let option;
let t_value = ctx[2][1] + "";
let t;
let option_value_value;
return {
c() {
option = element("option");
t = text(t_value);
option.__value = option_value_value = ctx[2][0];
option.value = option.__value;
},
m(target, anchor) {
insert(target, option, anchor);
append(option, t);
},
p(ctx2, dirty) {
if (dirty & 2 && t_value !== (t_value = ctx2[2][1] + ""))
set_data(t, t_value);
if (dirty & 2 && option_value_value !== (option_value_value = ctx2[2][0])) {
option.__value = option_value_value;
option.value = option.__value;
}
},
d(detaching) {
if (detaching)
detach(option);
}
};
}
function create_fragment(ctx) {
let if_block_anchor;
let if_block = ctx[1] && create_if_block(ctx);
return {
c() {
if (if_block)
if_block.c();
if_block_anchor = empty();
this.c = noop;
},
m(target, anchor) {
if (if_block)
if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
},
p(ctx2, [dirty]) {
if (ctx2[1]) {
if (if_block) {
if_block.p(ctx2, dirty);
} else {
if_block = create_if_block(ctx2);
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
},
i: noop,
o: noop,
d(detaching) {
if (if_block)
if_block.d(detaching);
if (detaching)
detach(if_block_anchor);
}
};
}
function instance($$self, $$props, $$invalidate) {
var L, _li, default_lang, exist, i, j, len, map, ref, set, val_lang_li;
let { lang } = $$props;
let { li } = $$props;
let { change = noop } = $$props;
set = noop;
exist = (lang2) => {
if (lang2) {
if (!map.has(lang2)) {
lang2 = lang2.split("-")[0];
if (!map.has(lang2)) {
return;
}
}
return lang2;
}
};
L = localStorage;
function select_change_handler() {
lang = select_value(this);
$$invalidate(0, lang), $$invalidate(3, li), $$invalidate(6, _li), $$invalidate(1, val_lang_li), $$invalidate(11, ref), $$invalidate(9, j), $$invalidate(10, len), $$invalidate(8, exist), $$invalidate(2, i), $$invalidate(7, default_lang), $$invalidate(5, L), $$invalidate(4, change);
$$invalidate(1, val_lang_li), $$invalidate(3, li), $$invalidate(6, _li), $$invalidate(11, ref), $$invalidate(9, j), $$invalidate(10, len), $$invalidate(8, exist), $$invalidate(2, i), $$invalidate(7, default_lang), $$invalidate(0, lang), $$invalidate(5, L), $$invalidate(4, change);
}
$$self.$$set = ($$props2) => {
if ("lang" in $$props2)
$$invalidate(0, lang = $$props2.lang);
if ("li" in $$props2)
$$invalidate(3, li = $$props2.li);
if ("change" in $$props2)
$$invalidate(4, change = $$props2.change);
};
$$self.$$.update = () => {
if ($$self.$$.dirty & 4095) {
$: {
if (li) {
$$invalidate(6, _li = li.split("|"));
$$invalidate(1, val_lang_li = str2li_default(_li));
map = new Map(val_lang_li);
$$invalidate(11, ref = navigator.languages);
for ($$invalidate(9, j = 0), $$invalidate(10, len = ref.length); j < len; $$invalidate(9, j++, j)) {
$$invalidate(2, i = ref[j]);
$$invalidate(7, default_lang = exist(i));
if (default_lang) {
break;
}
}
$$invalidate(7, default_lang = default_lang || _li[0]);
$$invalidate(12, set = () => {
if (lang === default_lang) {
delete L.lang;
} else {
$$invalidate(5, L.lang = lang, L);
}
return change(lang);
});
if (!lang) {
$$invalidate(0, lang = exist(L.lang) || default_lang);
}
}
}
}
if ($$self.$$.dirty & 4097) {
$: {
set(lang);
}
}
};
return [
lang,
val_lang_li,
i,
li,
change,
L,
_li,
default_lang,
exist,
j,
len,
ref,
set,
select_change_handler
];
}
const I18n = class extends SvelteElement {
constructor(options) {
super();
this.shadowRoot.innerHTML = `<style>select{appearance:none;border:2px solid #000;cursor:pointer;display:inline-block;font-size:inherit;font-weight:500;height:2em;padding:2px 1.25em 2px 0;text-align:center;-webkit-user-select:none;user-select:none;width:7.5em}select.ico{padding-left:1.75em}select:hover{filter:invert(40%) sepia(84%) saturate(5021%) hue-rotate(1deg) brightness(103%) contrast(103%)}select:active{box-shadow:0 0 4px inset}select:focus{filter:invert(29%) sepia(93%) saturate(2662%) hue-rotate(216deg) brightness(94%) contrast(83%);outline:0}select{background:var(--svg-i18n) 0.375em 50%/1.125em no-repeat, var(--svg-nabla) no-repeat scroll 95% 60%}</style>`;
init(
this,
{
target: this.shadowRoot,
props: attribute_to_object(this.attributes),
customElement: true
},
instance,
create_fragment,
safe_not_equal,
{ lang: 0, li: 3, change: 4 },
null
);
if (options) {
if (options.target) {
insert(options.target, this, options.anchor);
}
if (options.props) {
this.$set(options.props);
flush();
}
}
}
static get observedAttributes() {
return ["lang", "li", "change"];
}
get lang() {
return this.$$.ctx[0];
}
set lang(lang) {
this.$$set({ lang });
flush();
}
get li() {
return this.$$.ctx[3];
}
set li(li) {
this.$$set({ li });
flush();
}
get change() {
return this.$$.ctx[4];
}
set change(change) {
this.$$set({ change });
flush();
}
};
export const iI18n=()=>{ if(customElements.get(UI_PREFIX+'i18n'))return; return $ELEMENT("i18n",I18n) }
// src/MailNew.svelte
function create_fragment2(ctx) {
let li;
let input;
let label;
let mounted;
let dispose;
return {
c() {
li = element("li");
input = element("input");
label = element("label");
label.textContent = "邮件";
this.c = noop;
attr(input, "placeholder", " ");
attr(input, "type", "text");
attr(input, "id", "iMailNew");
input.required = true;
attr(label, "for", "iMailNew");
},
m(target, anchor) {
insert(target, li, anchor);
append(li, input);
set_input_value(input, ctx[0]);
append(li, label);
if (!mounted) {
dispose = listen(input, "input", ctx[1]);
mounted = true;
}
},
p(ctx2, [dirty]) {
if (dirty & 1 && input.value !== ctx2[0]) {
set_input_value(input, ctx2[0]);
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching)
detach(li);
mounted = false;
dispose();
}
};
}
function instance2($$self, $$props, $$invalidate) {
var mail;
console.log(1);
mail = "123G$";
function input_input_handler() {
mail = this.value;
$$invalidate(0, mail);
}
return [mail, input_input_handler];
}
const MailNew = class extends SvelteElement {
constructor(options) {
super();
this.shadowRoot.innerHTML = `<style>input:is([type=text],
[type=password]){border:1px solid #ccc;border-radius:0;box-sizing:border-box;font-size:1em;margin-top:1em;outline:0;padding:1em;width:100%}input:is([type=text],
[type=password]):-webkit-autofill{-webkit-background-clip:text;background-clip:text}input:is([type=text],
[type=password]):autofill{-webkit-background-clip:text;background-clip:text}input:is([type=text],
[type=password])+label{background:#fff;color:#999;font-weight:400;left:0.8em;padding:0 0.1em 0 0.2em;position:absolute;top:0.3em;transition:all 0.3s}input:is([type=text],
[type=password]):focus{border-color:#36d;color:#000}input:is([type=text],
[type=password]):focus+label{color:#36d}input:is([type=text],
[type=password]):hover{border-color:#f40}input:is([type=text],
[type=password]):hover+label{color:#f40}input:is([type=text],
[type=password]):disabled{text-indent:2.85em}input:is([type=text],
[type=password]):disabled{background:#f9f9f9;color:#999;display:inline-block;position:relative;-webkit-user-select:none;user-select:none}input:is([type=text],
[type=password]):disabled+label{background:#fafafa;border-left:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;color:#444;font-size:1.2em;left:1em;line-height:2em;padding:0.55em 0.6em 0.45em;position:absolute;text-align:center;top:0.5em;-webkit-user-select:none;user-select:none}input:is([type=text],
[type=password]):disabled:hover{border:1px solid #ccc}input:is([type=text],
[type=password]):placeholder-shown+label{background:transparent;color:#999;cursor:text;left:1em;top:1.8em}</style>`;
init(
this,
{
target: this.shadowRoot,
props: attribute_to_object(this.attributes),
customElement: true
},
instance2,
create_fragment2,
safe_not_equal,
{},
null
);
if (options) {
if (options.target) {
insert(options.target, this, options.anchor);
}
}
}
};
export const iMailNew=()=>{ if(customElements.get(UI_PREFIX+'mail-new'))return; return $ELEMENT("mail-new",MailNew) }
// src/Form.svelte
function create_else_block(ctx) {
let t_value = ctx[5][2] + "";
let t;
return {
c() {
t = text(t_value);
},
m(target, anchor) {
insert(target, t, anchor);
},
p(ctx2, dirty) {
if (dirty & 32 && t_value !== (t_value = ctx2[5][2] + ""))
set_data(t, t_value);
},
d(detaching) {
if (detaching)
detach(t);
}
};
}
function create_if_block2(ctx) {
let t0_value = ctx[5][7] + "";
let t0;
let t1;
let t2_value = ctx[5][3] + "";
let t2;
let t3;
let t4_value = ctx[5][6] + "";
let t4;
return {
c() {
t0 = text(t0_value);
t1 = space();
t2 = text(t2_value);
t3 = space();
t4 = text(t4_value);
},
m(target, anchor) {
insert(target, t0, anchor);
insert(target, t1, anchor);
insert(target, t2, anchor);
insert(target, t3, anchor);
insert(target, t4, anchor);
},
p(ctx2, dirty) {
if (dirty & 32 && t0_value !== (t0_value = ctx2[5][7] + ""))
set_data(t0, t0_value);
if (dirty & 32 && t2_value !== (t2_value = ctx2[5][3] + ""))
set_data(t2, t2_value);
if (dirty & 32 && t4_value !== (t4_value = ctx2[5][6] + ""))
set_data(t4, t4_value);
},
d(detaching) {
if (detaching)
detach(t0);
if (detaching)
detach(t1);
if (detaching)
detach(t2);
if (detaching)
detach(t3);
if (detaching)
detach(t4);
}
};
}
function create_fragment3(ctx) {
let form_1;
let li;
let input0;
let label0;
let t0;
let button;
let button_disabled_value;
let footer;
let p;
let input1;
let label1;
let t1_value = ctx[5][0] + "";
let t1;
let a0;
let t2_value = ctx[5][8] + "";
let t2;
let a1;
let t3_value = ctx[5][5] + "";
let t3;
let mounted;
let dispose;
function select_block_type(ctx2, dirty) {
if (ctx2[3])
return create_if_block2;
return create_else_block;
}
let current_block_type = select_block_type(ctx, -1);
let if_block = current_block_type(ctx);
return {
c() {
form_1 = element("form");
li = element("li");
input0 = element("input");
label0 = element("label");
t0 = text(ctx[7]);
button = element("button");
if_block.c();
footer = element("footer");
p = element("p");
input1 = element("input");
label1 = element("label");
t1 = text(t1_value);
a0 = element("a");
t2 = text(t2_value);
a1 = element("a");
t3 = text(t3_value);
this.c = noop;
attr(input0, "placeholder", " ");
attr(input0, "type", "text");
attr(input0, "id", "iFormMail");
input0.required = true;
attr(label0, "for", "iFormMail");
button.disabled = button_disabled_value = !ctx[3];
attr(button, "type", "submit");
attr(input1, "id", "iFormAgree");
attr(input1, "type", "checkbox");
attr(label1, "for", "iFormAgree");
attr(a0, "href", ctx[1]);
attr(a1, "href", ctx[0]);
},
m(target, anchor) {
insert(target, form_1, anchor);
append(form_1, li);
append(li, input0);
set_input_value(input0, ctx[2]);
append(li, label0);
append(label0, t0);
append(form_1, button);
if_block.m(button, null);
append(form_1, footer);
append(footer, p);
append(p, input1);
input1.checked = ctx[3];
append(p, label1);
append(label1, t1);
append(p, a0);
append(a0, t2);
append(footer, a1);
append(a1, t3);
ctx[12](form_1);
if (!mounted) {
dispose = [
listen(input0, "input", ctx[10]),
listen(input1, "change", ctx[11]),
listen(form_1, "submit", prevent_default(function() {
if (is_function(ctx[6]))
ctx[6].apply(this, arguments);
}))
];
mounted = true;
}
},
p(new_ctx, [dirty]) {
ctx = new_ctx;
if (dirty & 4 && input0.value !== ctx[2]) {
set_input_value(input0, ctx[2]);
}
if (dirty & 128)
set_data(t0, ctx[7]);
if (current_block_type === (current_block_type = select_block_type(ctx, dirty)) && if_block) {
if_block.p(ctx, dirty);
} else {
if_block.d(1);
if_block = current_block_type(ctx);
if (if_block) {
if_block.c();
if_block.m(button, null);
}
}
if (dirty & 8 && button_disabled_value !== (button_disabled_value = !ctx[3])) {
button.disabled = button_disabled_value;
}
if (dirty & 8) {
input1.checked = ctx[3];
}
if (dirty & 32 && t1_value !== (t1_value = ctx[5][0] + ""))
set_data(t1, t1_value);
if (dirty & 32 && t2_value !== (t2_value = ctx[5][8] + ""))
set_data(t2, t2_value);
if (dirty & 2) {
attr(a0, "href", ctx[1]);
}
if (dirty & 32 && t3_value !== (t3_value = ctx[5][5] + ""))
set_data(t3, t3_value);
if (dirty & 1) {
attr(a1, "href", ctx[0]);
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching)
detach(form_1);
if_block.d();
ctx[12](null);
mounted = false;
run_all(dispose);
}
};
}
function instance3($$self, $$props, $$invalidate) {
var WAY, account, agree, form, i18n, submit, tip;
let { a_pwd_reset } = $$props;
let { a_agree } = $$props;
const focus = () => {
var ref;
if ((ref = form.getElementsByTagName("input")[0]) != null) {
ref.focus();
}
};
WAY = [];
tip = "";
const way = (...li) => {
var w;
$$invalidate(7, tip = []);
w = [];
li.forEach(([k, func]) => {
tip.push(i18n[k]);
w.push(func);
});
WAY = w;
$$invalidate(7, tip = tip.join(" / "));
};
submit = () => {
var f;
for (f of WAY) {
if (f(account)) {
break;
}
}
};
onMount(() => {
focus();
});
agree = true;
onMount(i18nOnMount(() => {
$$invalidate(5, i18n = I18N);
}));
function input0_input_handler() {
account = this.value;
$$invalidate(2, account);
}
function input1_change_handler() {
agree = this.checked;
$$invalidate(3, agree);
}
function form_1_binding($$value) {
binding_callbacks[$$value ? "unshift" : "push"](() => {
form = $$value;
$$invalidate(4, form);
});
}
$$self.$$set = ($$props2) => {
if ("a_pwd_reset" in $$props2)
$$invalidate(0, a_pwd_reset = $$props2.a_pwd_reset);
if ("a_agree" in $$props2)
$$invalidate(1, a_agree = $$props2.a_agree);
};
return [
a_pwd_reset,
a_agree,
account,
agree,
form,
i18n,
submit,
tip,
focus,
way,
input0_input_handler,
input1_change_handler,
form_1_binding
];
}
const Form = class extends SvelteElement {
constructor(options) {
super();
this.shadowRoot.innerHTML = `<style>input:is([type=text],
[type=password]){border:1px solid #ccc;border-radius:0;box-sizing:border-box;font-size:1em;margin-top:1em;outline:0;padding:1em;width:100%}input:is([type=text],
[type=password]):-webkit-autofill{-webkit-background-clip:text;background-clip:text}input:is([type=text],
[type=password]):autofill{-webkit-background-clip:text;background-clip:text}input:is([type=text],
[type=password])+label{background:#fff;color:#999;font-weight:400;left:0.8em;padding:0 0.1em 0 0.2em;position:absolute;top:0.3em;transition:all 0.3s}input:is([type=text],
[type=password]):focus{border-color:#36d;color:#000}input:is([type=text],
[type=password]):focus+label{color:#36d}input:is([type=text],
[type=password]):hover{border-color:#f40}input:is([type=text],
[type=password]):hover+label{color:#f40}input:is([type=text],
[type=password]):disabled{text-indent:2.85em}input:is([type=text],
[type=password]):disabled{background:#f9f9f9;color:#999;display:inline-block;position:relative;-webkit-user-select:none;user-select:none}input:is([type=text],
[type=password]):disabled+label{background:#fafafa;border-left:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;color:#444;font-size:1.2em;left:1em;line-height:2em;padding:0.55em 0.6em 0.45em;position:absolute;text-align:center;top:0.5em;-webkit-user-select:none;user-select:none}input:is([type=text],
[type=password]):disabled:hover{border:1px solid #ccc}input:is([type=text],
[type=password]):placeholder-shown+label{background:transparent;color:#999;cursor:text;left:1em;top:1.8em}input[type=checkbox]{appearance:none;border:0.15em solid currentColor;color:currentColor;cursor:pointer;display:grid;flex-shrink:0;font:inherit;height:1.15em;margin:0;margin-top:2px;padding:0;place-content:center;transform:scale(0.9);width:1.15em}input[type=checkbox]::before{background-color:#999;clip-path:polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);content:'';height:0.65em;transform:scale(0);transform-origin:bottom left;transition:120ms transform ease-in-out;width:0.65em}input[type=checkbox]:checked::before{transform:scale(1)}input[type=checkbox]:disabled{cursor:not-allowed}input[type=checkbox]:hover{border-color:#f40;color:#f40}input[type=checkbox]:hover+label{color:#f40}input[type=checkbox]:focus{color:#f40}input[type=checkbox]:focus+label{color:#f40}input[type=checkbox]:focus:checked{background:#f40}input[type=checkbox]:focus:checked:before{background:#fff}input[type=checkbox]:checked:hover{background-color:var(--checked-color);border-color:var(--checked-color);color:var(--checked-color)}input[type=checkbox]:checked:hover::before{background-color:#fff}input[type=checkbox]:checked:hover+label{color:var(--checked-color)}button{background-image:var(--btn-bg-img);background-size:200% auto;border:0;border-radius:0;color:#fff;cursor:pointer;display:block;font-size:1em;font-weight:700;margin-top:1em;padding:1em;text-align:center;touch-action:manipulation;transition:0.3s;-webkit-user-select:none;user-select:none;width:100%}button:hover{background-position:right center;color:#fff}button:hover,button:active{box-shadow:0 0 3px #000 inset}button:active{transform:scale(0.95)}button[disabled]{box-shadow:0 0 2em #000 inset;cursor:not-allowed;filter:grayscale(100%);opacity:0.4}form>button[type=submit]{margin-top:1.5em}form>li{list-style:none;position:relative}form>footer{align-items:center;display:flex;font-size:0.875em;justify-content:space-between;margin:0.5em 0 0;-webkit-user-select:none;user-select:none}form>footer>p{align-items:center;display:flex}form>footer>p input[type=checkbox]{margin-right:0.3125em}form>footer>p a{border-bottom:2px solid #ccc;margin-bottom:-4px;margin-left:3px;padding-bottom:2px}form>footer>p a:hover{border-color:#f40}form>footer a,form>footer{color:#999}form>footer a{font-weight:normal;text-align:center;text-decoration:none}form>footer a:hover{color:#f40}form>footer>a:last-child{text-align:right}</style>`;
init(
this,
{
target: this.shadowRoot,
props: attribute_to_object(this.attributes),
customElement: true
},
instance3,
create_fragment3,
safe_not_equal,
{
a_pwd_reset: 0,
a_agree: 1,
focus: 8,
way: 9
},
null
);
if (options) {
if (options.target) {
insert(options.target, this, options.anchor);
}
if (options.props) {
this.$set(options.props);
flush();
}
}
}
static get observedAttributes() {
return ["a_pwd_reset", "a_agree", "focus", "way"];
}
get a_pwd_reset() {
return this.$$.ctx[0];
}
set a_pwd_reset(a_pwd_reset) {
this.$$set({ a_pwd_reset });
flush();
}
get a_agree() {
return this.$$.ctx[1];
}
set a_agree(a_agree) {
this.$$set({ a_agree });
flush();
}
get focus() {
return this.$$.ctx[8];
}
get way() {
return this.$$.ctx[9];
}
};
export const iForm=()=>{ if(customElements.get(UI_PREFIX+'form'))return; return $ELEMENT("form",Form) }
// src/User.svelte
function create_fragment4(ctx) {
let main;
let slot2;
let i_form;
return {
c() {
main = element("main");
slot2 = element("slot");
slot2.innerHTML = `<slot name="logo"></slot><slot name="org"></slot>`;
i_form = element(UI_PREFIX+"form");
this.c = noop;
attr(slot2, "name", "head");
set_custom_element_data(i_form, "a_agree", ctx[2]);
set_custom_element_data(i_form, "a_pwd_reset", ctx[1]);
},
m(target, anchor) {
insert(target, main, anchor);
append(main, slot2);
append(main, i_form);
ctx[3](i_form);
},
p(ctx2, [dirty]) {
if (dirty & 4) {
set_custom_element_data(i_form, "a_agree", ctx2[2]);
}
if (dirty & 2) {
set_custom_element_data(i_form, "a_pwd_reset", ctx2[1]);
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching)
detach(main);
ctx[3](null);
}
};
}
function instance4($$self, $$props, $$invalidate) {
var lang;
lang = "zh";
let { a_pwd_reset = "/usr/pwd/reset" } = $$props;
let { a_agree = "/usr/agree" } = $$props;
let { form } = $$props;
function i_form_binding($$value) {
binding_callbacks[$$value ? "unshift" : "push"](() => {
form = $$value;
$$invalidate(0, form);
});
}
$$self.$$set = ($$props2) => {
if ("a_pwd_reset" in $$props2)
$$invalidate(1, a_pwd_reset = $$props2.a_pwd_reset);
if ("a_agree" in $$props2)
$$invalidate(2, a_agree = $$props2.a_agree);
if ("form" in $$props2)
$$invalidate(0, form = $$props2.form);
};
return [form, a_pwd_reset, a_agree, i_form_binding];
}
const User = class extends SvelteElement {
constructor(options) {
super();
this.shadowRoot.innerHTML = `<style>slot[name=head]{align-items:center;display:flex;justify-content:space-evenly;margin:0;padding-bottom:0.5em;-webkit-user-select:none;user-select:none}</style>`;
init(
this,
{
target: this.shadowRoot,
props: attribute_to_object(this.attributes),
customElement: true
},
instance4,
create_fragment4,
safe_not_equal,
{ a_pwd_reset: 1, a_agree: 2, form: 0 },
null
);
if (options) {
if (options.target) {
insert(options.target, this, options.anchor);
}
if (options.props) {
this.$set(options.props);
flush();
}
}
}
static get observedAttributes() {
return ["a_pwd_reset", "a_agree", "form"];
}
get a_pwd_reset() {
return this.$$.ctx[1];
}
set a_pwd_reset(a_pwd_reset) {
this.$$set({ a_pwd_reset });
flush();
}
get a_agree() {
return this.$$.ctx[2];
}
set a_agree(a_agree) {
this.$$set({ a_agree });
flush();
}
get form() {
return this.$$.ctx[0];
}
set form(form) {
this.$$set({ form });
flush();
}
};
export const iUser=()=>{ if(customElements.get(UI_PREFIX+'user'))return; iForm(); return $ELEMENT("user",User) }
//!/usr/bin/env coffee
//# sourceMappingURL=index.js.map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment